rice.pastry.wire
Class SelectorManager

java.lang.Object
  extended byrice.pastry.wire.SelectorManager

public class SelectorManager
extends java.lang.Object

This class is the class which handles the selector, and listens for activity. When activity occurs, it figures out who is interested in what has happened, and hands off to that object.


Field Summary
 int SELECT_WAIT_TIME
          the amount of time to wait during a selection (ms)
 
Constructor Summary
SelectorManager(WirePastryNode node)
          Constructor.
 
Method Summary
 java.nio.channels.Selector getSelector()
          Returns the selector used by this SelectorManager.
 boolean isAlive()
          Gets the Alive attribute of the SelectorManager object
 void kill()
          To be used for testing purposes only - kills the socket client by shutting down all outgoing sockets and stopping the client thread.
 void registerForWakeup(NeedsWakeUp skh)
          required to register all objects that need a routine wakeup call on the Selector thread.
 void run()
          This method starts the datagram manager listening for incoming datagrams.
 void unregisterForWakeup(NeedsWakeUp skh)
          used to unregister an object for wakeup on the Selector thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_WAIT_TIME

public int SELECT_WAIT_TIME
the amount of time to wait during a selection (ms)

Constructor Detail

SelectorManager

public SelectorManager(WirePastryNode node)
Constructor.

Parameters:
node - The pastry node this SelectorManager is serving
Method Detail

getSelector

public java.nio.channels.Selector getSelector()
Returns the selector used by this SelectorManager. NOTE: All operations using the selector which change the Selector's keySet MUST synchronize on the Selector itself. (i.e.: synchronized (selector) { channel.register(selector, ...); } ).

Returns:
The Selector used by this object.

isAlive

public boolean isAlive()
Gets the Alive attribute of the SelectorManager object

Returns:
The Alive value

registerForWakeup

public void registerForWakeup(NeedsWakeUp skh)
required to register all objects that need a routine wakeup call on the Selector thread.

Parameters:
skh - The object to call wakeup on.

unregisterForWakeup

public void unregisterForWakeup(NeedsWakeUp skh)
used to unregister an object for wakeup on the Selector thread.

Parameters:
skh - The object to stop calling wakeup on.

run

public void run()
This method starts the datagram manager listening for incoming datagrams. It is designed to be started when this thread's start() method is invoked. In this method, the DatagramManager blocks while waiting for activity. It listens on its specified port for incoming datagrams, and processes any write() requests from pastry node handles.


kill

public void kill()
To be used for testing purposes only - kills the socket client by shutting down all outgoing sockets and stopping the client thread.






Imprint-Dataprotection