org.jppf.server.nio
Class StateTransitionManager<S extends Enum<S>,T extends Enum<T>>

java.lang.Object
  extended by org.jppf.server.nio.StateTransitionManager<S,T>
Type Parameters:
S - type safe enum of the possible states for a channel.
T - type safe enum of the possible state transitions for a channel.

public class StateTransitionManager<S extends Enum<S>,T extends Enum<T>>
extends Object

Instances of this class manage the state transitions of channels opened via a NioServer.

Author:
Laurent Cohen

Nested Class Summary
static class StateTransitionManager.ChannelRegistrationAction
          Abstract super class for an action to perform upon registration of a channel.
 
Field Summary
protected  ExecutorService executor
          The pool of threads used for submitting channel state transitions.
 
Constructor Summary
StateTransitionManager(NioServer<S,T> server, boolean sequential)
          Initialize this transition manager with the specified server and sequential flag.
 
Method Summary
 boolean isSequential()
          Determine whether the submission of state transitions should be performed sequentially.
 ChannelWrapper<?> registerChannel(SocketChannel channel, int ops, NioContext context, StateTransitionManager.ChannelRegistrationAction action)
          Register a channel not opened through this server.
 void submit(Runnable r)
          Submit the specified task for execution.
 void submitTransition(ChannelWrapper<?> key)
          Submit the next state transition for a specified channel.
 void transitionChannel(ChannelWrapper<?> channel, T transition)
          Transition the specified channel to the specified state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executor

protected ExecutorService executor
The pool of threads used for submitting channel state transitions.

Constructor Detail

StateTransitionManager

public StateTransitionManager(NioServer<S,T> server,
                              boolean sequential)
Initialize this transition manager with the specified server and sequential flag.

Parameters:
server - the server for which this transition manager is intended.
sequential - determines whether the submission of state transitions should be performed sequentially or through the executor thread pool.
Method Detail

submitTransition

public void submitTransition(ChannelWrapper<?> key)
Submit the next state transition for a specified channel.

Parameters:
key - the selection key that references the channel.

transitionChannel

public void transitionChannel(ChannelWrapper<?> channel,
                              T transition)
Transition the specified channel to the specified state.

Parameters:
channel - the key holding the channel and associated context.
transition - holds the new state of the channel and associated key ops.

registerChannel

public ChannelWrapper<?> registerChannel(SocketChannel channel,
                                         int ops,
                                         NioContext context,
                                         StateTransitionManager.ChannelRegistrationAction action)
Register a channel not opened through this server.

Parameters:
channel - the channel to register.
ops - the operations the channel is initially interested in.
context - the context attached to the channel.
action - an action to perform upon registration of the channel.
Returns:
a ChannelWrapper instance.

submit

public void submit(Runnable r)
Submit the specified task for execution.

Parameters:
r - the task to run.

isSequential

public boolean isSequential()
Determine whether the submission of state transitions should be performed sequentially.

Returns:
true if state transitions are sequential or false if they are in parallel.


Copyright © 2005-2010 JPPF Team.