|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrice.selector.SelectionKeyHandler
rice.pastry.socket.SocketCollectionManager
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.
Nested Class Summary | |
protected class |
SocketCollectionManager.DeadChecker
DESCRIBE THE CLASS |
protected class |
SocketCollectionManager.MessageRetry
Internal class which represents a message which is currently delayed, waiting for an open socket. |
protected class |
SocketCollectionManager.SocketAccepter
Internal class which reads the greeting message off of a newly-accepted socket. |
protected class |
SocketCollectionManager.SourceRouteManager
Private class which is tasked with maintaining a source route which goes through this node. |
Field Summary | |
static long |
BACKOFF_INITIAL
DESCRIBE THE FIELD |
static int |
BACKOFF_LIMIT
DESCRIBE THE FIELD |
static int |
BOOTSTRAP_PORT
DESCRIBE THE FIELD |
protected static byte[] |
HEADER_DIRECT
DESCRIBE THE FIELD |
static int |
HEADER_SIZE
DESCRIBE THE FIELD |
protected static byte[] |
HEADER_SOURCE_ROUTE
DESCRIBE THE FIELD |
static int |
MAX_OPEN_SOCKETS
DESCRIBE THE FIELD |
static int |
MAX_OPEN_SOURCE_ROUTES
DESCRIBE THE FIELD |
static int |
NUM_PING_TRIES
DESCRIBE THE FIELD |
static int |
PING_DELAY
DESCRIBE THE FIELD |
static int |
PING_JITTER
DESCRIBE THE FIELD |
static int |
SOCKET_BUFFER_SIZE
DESCRIBE THE FIELD |
java.util.Hashtable |
sockets
DESCRIBE THE FIELD |
static int |
WRITE_WAIT_TIME
DESCRIBE THE FIELD |
Constructor Summary | |
SocketCollectionManager(SocketPastryNode node,
SocketNodeHandlePool pool,
SocketSourceRouteManager manager,
EpochInetSocketAddress bindAddress,
EpochInetSocketAddress proxyAddress)
Constructs a new SocketManager. |
Method Summary | |
void |
accept(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface. |
void |
bootstrap(SourceRoute path,
Message message)
Method which sends bootstraps a node by sending message across the wire, using a fake IP address in the header so that the local node is not marked alive, and then closes the connection. |
protected void |
checkLiveness(SourceRoute path)
Initiates a liveness test on the given address, if the remote node does not respond, it is declared dead. |
protected void |
closeSocket(SourceRoute path)
Method which cloeses a socket to a given remote node handle, and updates the bookkeeping to keep track of this closing. |
void |
declaredDead(EpochInetSocketAddress address)
Method which should be called when a remote node is declared dead. |
int |
getNumSockets()
Gets the NumSockets attribute of the SocketCollectionManager object |
int |
getNumSourceRoutes()
Gets the NumSourceRoutes attribute of the SocketCollectionManager object |
PingManager |
getPingManager()
Method which returns the internal PingManager |
protected SourceRoute |
getSocketToClose()
Internal method which returns the next socket to be closed |
boolean |
isOpen(SourceRoute route)
Returns whether or not a socket is currently open to the given route |
protected void |
openSocket(SourceRoute path,
boolean bootstrap)
Method which opens a socket to a given remote node handle, and updates the bookkeeping to keep track of this socket |
void |
ping(SourceRoute route)
Method which suggests a ping to the remote node. |
void |
resign()
Makes this node resign from the network. |
void |
send(SourceRoute path,
Message message)
Method which sends a message across the wire. |
protected boolean |
sendInternal(SourceRoute path,
Message message)
Method which sends a message across the wire. |
protected void |
socketClosed(SourceRoute path,
rice.pastry.socket.SocketCollectionManager.SocketManager manager)
Method which is designed to be called *ONCE THE SOCKET HAS BEEN CLOSED*. |
protected void |
socketOpened(SourceRoute path,
rice.pastry.socket.SocketCollectionManager.SocketManager manager)
Method which is designed to be called by node handles when they wish to open a socket to their remote node. |
protected void |
socketUpdated(SourceRoute path)
Method which is designed to be called whenever a node has network activity. |
protected void |
sourceRouteClosed(SocketCollectionManager.SourceRouteManager manager)
Method which is designed to be called *ONCE THE SOURCE ROUTE MANAGER HAS BEEN CLOSED*. |
protected void |
sourceRouteOpened(SocketCollectionManager.SourceRouteManager manager)
Method which is designed to be called when a new source route manager is created. |
protected void |
sourceRouteUpdated(SocketCollectionManager.SourceRouteManager manager)
Method which is designed to be called whenever a source route has network activity. |
void |
stall()
Internal testing method which simulates a stall. |
Methods inherited from class rice.selector.SelectionKeyHandler |
connect, modifyKey, read, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public java.util.Hashtable sockets
public static int MAX_OPEN_SOCKETS
public static int MAX_OPEN_SOURCE_ROUTES
public static int SOCKET_BUFFER_SIZE
public static int PING_DELAY
public static int PING_JITTER
public static int NUM_PING_TRIES
public static int WRITE_WAIT_TIME
public static int BOOTSTRAP_PORT
public static long BACKOFF_INITIAL
public static int BACKOFF_LIMIT
protected static byte[] HEADER_DIRECT
protected static byte[] HEADER_SOURCE_ROUTE
public static int HEADER_SIZE
Constructor Detail |
public SocketCollectionManager(SocketPastryNode node, SocketNodeHandlePool pool, SocketSourceRouteManager manager, EpochInetSocketAddress bindAddress, EpochInetSocketAddress proxyAddress)
node
- The pastry node this manager is servingpool
- DESCRIBE THE PARAMETERmanager
- DESCRIBE THE PARAMETERbindAddress
- DESCRIBE THE PARAMETERproxyAddress
- DESCRIBE THE PARAMETERMethod Detail |
public boolean isOpen(SourceRoute route)
route
- The route
protected SourceRoute getSocketToClose()
public int getNumSourceRoutes()
public int getNumSockets()
public PingManager getPingManager()
public void bootstrap(SourceRoute path, Message message)
message
- The message to sendpath
- DESCRIBE THE PARAMETERpublic void send(SourceRoute path, Message message)
message
- The message to sendpath
- DESCRIBE THE PARAMETERpublic void ping(SourceRoute route)
route
- The route to useprotected void checkLiveness(SourceRoute path)
path
- DESCRIBE THE PARAMETERpublic void declaredDead(EpochInetSocketAddress address)
address
- The address which was declared deadprotected boolean sendInternal(SourceRoute path, Message message)
message
- The message to sendpath
- DESCRIBE THE PARAMETER
public void accept(java.nio.channels.SelectionKey key)
accept
in class SelectionKeyHandler
key
- The key which is acceptable.protected void openSocket(SourceRoute path, boolean bootstrap)
path
- DESCRIBE THE PARAMETERbootstrap
- DESCRIBE THE PARAMETERprotected void closeSocket(SourceRoute path)
path
- DESCRIBE THE PARAMETERprotected void socketOpened(SourceRoute path, rice.pastry.socket.SocketCollectionManager.SocketManager manager)
manager
- The manager for the remote addresspath
- DESCRIBE THE PARAMETERprotected void socketClosed(SourceRoute path, rice.pastry.socket.SocketCollectionManager.SocketManager manager)
manager
- The manager for the remote addresspath
- DESCRIBE THE PARAMETERprotected void socketUpdated(SourceRoute path)
path
- DESCRIBE THE PARAMETERprotected void sourceRouteOpened(SocketCollectionManager.SourceRouteManager manager)
manager
- The manager for the remote addressprotected void sourceRouteClosed(SocketCollectionManager.SourceRouteManager manager)
manager
- The manager for the remote addressprotected void sourceRouteUpdated(SocketCollectionManager.SourceRouteManager manager)
manager
- The manager with activitypublic void resign() throws java.io.IOException
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic void stall()
|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |