|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--rice.pastry.wire.SocketManager
Class which maintains all outgoing open sockets. It is responsible for keeping only MAX_OPEN_SOCKETS number of client sockets open at once. It also binds a ServerSocketChannel to the specified port and listens for incoming connections. Once a connections is established, it uses the interal SocketConnector to read the greeting message (HelloMessage) off of the stream, and hands the connection off to the appropriate node handle. Modified by glchen to use TcpNodeHandle instead of WireNodeHandle.
Nested Class Summary | |
private class |
SocketManager.SocketConnector
Private class which is tasked with reading the greeting message off of a newly connected socket. |
Field Summary | |
private java.util.HashMap |
connectors
|
private java.nio.channels.SelectionKey |
key
|
static int |
MAX_OPEN_SOCKETS
|
private java.util.LinkedList |
openSockets
|
private rice.pastry.wire.WirePastryNode |
pastryNode
|
private int |
port
|
Constructor Summary | |
SocketManager(rice.pastry.wire.WirePastryNode node,
int port,
java.nio.channels.Selector selector)
Constructs a new SocketManager. |
Method Summary | |
void |
accept(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface. |
void |
closeSocket(WireNodeHandle handle)
Method which is designed to be called by node handles which have been disconnected by the remote node. |
void |
connect(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface - should NEVER be called! |
private void |
debug(java.lang.String s)
|
void |
openSocket(WireNodeHandle handle)
Method which is designed to be called by node handles when they wish to open a socket to their remote node. |
void |
read(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface - is called whenever a key has data available. |
void |
update(WireNodeHandle handle)
Method which is designed to be called whenever a node has network activity. |
void |
wakeup()
Specified by the SelectionKeyHandler interface - does nothing. |
void |
write(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface - should NEVER be called! |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private rice.pastry.wire.WirePastryNode pastryNode
public static int MAX_OPEN_SOCKETS
private java.util.LinkedList openSockets
private java.util.HashMap connectors
private java.nio.channels.SelectionKey key
private int port
Constructor Detail |
public SocketManager(rice.pastry.wire.WirePastryNode node, int port, java.nio.channels.Selector selector)
node
- The pastry node this manager is servingport
- The port number which this manager is listening onselector
- The Selector this manager should register withMethod Detail |
public void openSocket(WireNodeHandle handle)
handle
- The handle which wishes to open a connectionpublic void closeSocket(WireNodeHandle handle)
handle
- The handle which has been disconnected.public void update(WireNodeHandle handle)
handle
- The node handle which has activity.public void accept(java.nio.channels.SelectionKey key)
accept
in interface rice.pastry.wire.SelectionKeyHandler
key
- The key which is acceptable.public void read(java.nio.channels.SelectionKey key)
read
in interface rice.pastry.wire.SelectionKeyHandler
key
- The key which is readable.public void write(java.nio.channels.SelectionKey key)
write
in interface rice.pastry.wire.SelectionKeyHandler
key
- The key which is writable.public void connect(java.nio.channels.SelectionKey key)
connect
in interface rice.pastry.wire.SelectionKeyHandler
key
- The key which is connectable.public void wakeup()
wakeup
in interface rice.pastry.wire.SelectionKeyHandler
private void debug(java.lang.String s)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |