|
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
public class 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 | |
|---|---|
java.util.LinkedList |
appSockets
|
long |
BACKOFF_INITIAL
|
int |
BACKOFF_LIMIT
|
static byte[] |
HEADER_DIRECT
|
static int |
HEADER_SIZE
|
protected static byte[] |
HEADER_SOURCE_ROUTE
|
protected Logger |
logger
|
int |
MAX_OPEN_SOCKETS
|
int |
MAX_OPEN_SOURCE_ROUTES
|
int |
NUM_PING_TRIES
|
static byte[] |
PASTRY_MAGIC_NUMBER
|
int |
PING_DELAY
|
float |
PING_JITTER
|
protected RandomSource |
random
|
int |
SOCKET_BUFFER_SIZE
|
java.util.Hashtable |
sockets
|
static int |
TOTAL_HEADER_SIZE
|
int |
WRITE_WAIT_TIME
|
| Constructor Summary | |
|---|---|
SocketCollectionManager(SocketPastryNode node,
SocketSourceRouteManager manager,
EpochInetSocketAddress bindAddress,
EpochInetSocketAddress proxyAddress,
RandomSource random)
Constructs a new SocketManager. |
|
| Method Summary | |
|---|---|
void |
accept(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface. |
protected void |
appSocketClosed(SocketAppSocket sas)
Method which is designed to be called *ONCE THE SOCKET HAS BEEN CLOSED*. |
protected void |
appSocketOpened(SocketAppSocket sas)
|
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 |
closeOneSocket()
TODO: Add also checking the top of the AppSocketQueue |
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 |
connect(SourceRoute path,
int appId,
AppSocketReceiver receiver,
int timeout)
Method which sends a message across the wire. |
void |
declaredDead(EpochInetSocketAddress address)
Method which should be called when a remote node is declared dead. |
void |
destroy()
Makes this node resign from the network. |
int |
getNumSockets()
|
int |
getNumSourceRoutes()
|
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 |
openAppSocket(SourceRoute path,
int appId,
AppSocketReceiver connector,
int timeout)
Method which opens a socket to a given remote node handle, and updates the bookkeeping to keep track of this socket |
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 |
send(SourceRoute path,
SocketBuffer message,
SocketSourceRouteManager.AddressManager am)
Method which sends a message across the wire. |
protected boolean |
sendInternal(SourceRoute path,
SocketBuffer message)
Method which sends a message across the wire. |
protected void |
socketClosed(SourceRoute path,
rice.pastry.socket.SocketManager manager)
Method which is designed to be called *ONCE THE SOCKET HAS BEEN CLOSED*. |
protected void |
socketOpened(SourceRoute path,
rice.pastry.socket.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 final int MAX_OPEN_SOCKETS
public final int MAX_OPEN_SOURCE_ROUTES
public final int SOCKET_BUFFER_SIZE
public final int PING_DELAY
public final float PING_JITTER
public final int NUM_PING_TRIES
public final int WRITE_WAIT_TIME
public final long BACKOFF_INITIAL
public final int BACKOFF_LIMIT
public static final byte[] HEADER_DIRECT
protected static final byte[] HEADER_SOURCE_ROUTE
public static final int HEADER_SIZE
public static final byte[] PASTRY_MAGIC_NUMBER
public static final int TOTAL_HEADER_SIZE
public java.util.Hashtable sockets
public java.util.LinkedList appSockets
protected Logger logger
protected RandomSource random
| Constructor Detail |
|---|
public SocketCollectionManager(SocketPastryNode node,
SocketSourceRouteManager manager,
EpochInetSocketAddress bindAddress,
EpochInetSocketAddress proxyAddress,
RandomSource random)
throws java.io.IOException
node - The pastry node this manager is servingport - The port number which this manager is listening onpool - DESCRIBE THE PARAMETERaddress - The address to claim the node is at (for proxying)
java.io.IOException| Method Detail |
|---|
public void bootstrap(SourceRoute path,
Message message)
throws java.io.IOException
message - The message to sendaddress - The address to send the message to
java.io.IOException
public void send(SourceRoute path,
SocketBuffer message,
SocketSourceRouteManager.AddressManager am)
message - The message to sendaddress - The address to send the message to
public void connect(SourceRoute path,
int appId,
AppSocketReceiver receiver,
int timeout)
message - The message to sendaddress - The address to send the message topublic void ping(SourceRoute route)
route - The route to useprotected void checkLiveness(SourceRoute path)
address - DESCRIBE THE PARAMETERpublic boolean isOpen(SourceRoute route)
route - The route
public void declaredDead(EpochInetSocketAddress address)
address - The address which was declared dead
protected boolean sendInternal(SourceRoute path,
SocketBuffer message)
message - The message to sendpath - The path to send the message alongpublic void accept(java.nio.channels.SelectionKey key)
accept in class SelectionKeyHandlerkey - The key which is acceptable.
protected void openSocket(SourceRoute path,
boolean bootstrap)
address - The address of the remote node
protected void openAppSocket(SourceRoute path,
int appId,
AppSocketReceiver connector,
int timeout)
address - The address of the remote nodeprotected void closeSocket(SourceRoute path)
address - The address of the remote nodeprotected SourceRoute getSocketToClose()
protected void socketOpened(SourceRoute path,
rice.pastry.socket.SocketManager manager)
address - The address of the remote nodemanager - The manager for the remote addressprotected void appSocketOpened(SocketAppSocket sas)
protected void closeOneSocket()
protected void socketClosed(SourceRoute path,
rice.pastry.socket.SocketManager manager)
address - The address of the remote nodemanager - The manager for the remote addressprotected void appSocketClosed(SocketAppSocket sas)
address - The address of the remote nodemanager - The manager for the remote addressprotected void socketUpdated(SourceRoute path)
address - The address of the remote nodeprotected void sourceRouteOpened(SocketCollectionManager.SourceRouteManager manager)
address - The address of the remote nodemanager - The manager for the remote addressprotected void sourceRouteClosed(SocketCollectionManager.SourceRouteManager manager)
address - The address of the remote nodemanager - The manager for the remote addressprotected void sourceRouteUpdated(SocketCollectionManager.SourceRouteManager manager)
manager - The manager with activity
public void destroy()
throws java.io.IOException
java.io.IOExceptionpublic int getNumSourceRoutes()
public int getNumSockets()
public void stall()
public PingManager getPingManager()
route - The route to useprl - The listener
|
Rice Pastry API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||