|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--rice.pastry.NodeHandle | +--rice.pastry.dist.DistNodeHandle | +--rice.pastry.wire.WireNodeHandle
Class which represents a node handle in the socket-based pastry protocol. Initially, all of the messages are sent over UDP. If a message is too large to be sent over the UDP protocol (as determined by the MAX_UDP_MESSAGE_SIZE), then a socket connection is opened to the remote node. Modified by glchen to make some variable as protected instead of private.
Field Summary | |
protected java.nio.channels.SelectionKey |
key
|
private long |
lastpingtime
|
static int |
MAX_UDP_MESSAGE_SIZE
|
static int |
PING_THROTTLE
|
protected rice.pastry.wire.SocketChannelReader |
reader
|
static int |
SOCKET_BUFFER_SIZE
|
protected int |
state
|
static int |
STATE_USING_TCP
|
static int |
STATE_USING_UDP
|
static int |
STATE_USING_UDP_WAITING_FOR_TCP_DISCONNECT
|
static int |
STATE_USING_UDP_WAITING_TO_DISCONNECT
|
protected SocketChannelWriter |
writer
|
Fields inherited from class rice.pastry.dist.DistNodeHandle |
address, alive, isInPool, isLocal, nodeId |
Fields inherited from class rice.pastry.NodeHandle |
DECLARED_DEAD, DECLARED_LIVE, PROXIMITY_CHANGED |
Fields inherited from class java.util.Observable |
|
Fields inherited from interface rice.pastry.LocalNodeI |
pending |
Constructor Summary | |
WireNodeHandle(java.net.InetSocketAddress address,
rice.pastry.NodeId nid)
Constructor. |
|
WireNodeHandle(java.net.InetSocketAddress address,
rice.pastry.NodeId nid,
rice.pastry.PastryNode pn)
Alternate constructor with local Pastry node. |
Method Summary | |
void |
accept(java.nio.channels.SelectionKey key)
Requeired by the SelectionKeyHandler interface. |
private void |
close(java.util.LinkedList messages)
Private method used for closing the socket (if there is one present). |
void |
connect(java.nio.channels.SelectionKey key)
Called by the socket manager whnever this node handle needs to complete it's connection to it's remote node. |
void |
connectToRemoteNode(java.util.LinkedList messages)
Method which initiates a connection to a remote node. |
void |
disconnect()
Method that is designed to be called by the SocketManager when it wishes for this node handle to disconnect. |
private int |
getAddress(java.net.InetAddress address)
Utility method for converting an InetAddress to an int (for comparison purposes). |
int |
getState()
Returns the state of this WireNodeHandle |
protected int |
messageSize(java.lang.Object obj)
Method which returns the size of an object about to be sent over the wire. |
boolean |
pingImpl()
Ping the remote node now, and update the proximity metric. |
void |
pingResponse()
Method which is called by the SocketPingManager when a ping response comes back for this node. |
void |
pingStarted()
Method which is called by the PingMessage right before it is going to be sent across the wire. |
void |
read(java.nio.channels.SelectionKey key)
Called by the socket manager whenever there is data to be read from this node handle's remote node. |
private void |
readObject(java.io.ObjectInputStream ois)
Overridden in order to specify the default state (using UDP) |
void |
receiveMessageImpl(rice.pastry.messaging.Message msg)
Called to send a message to the node corresponding to this handle. |
void |
receiveSocketMessage(rice.pastry.wire.messaging.socket.SocketCommandMessage message)
Method which is called when a SocketCommandMessage comes across an open socket for this node handle. |
void |
sendGreetingResponse(rice.pastry.wire.messaging.socket.HelloMessage hm)
|
void |
setKey(java.nio.channels.SelectionKey key,
rice.pastry.wire.messaging.socket.SocketCommandMessage scm)
Method which sets the SelectionKey of this node handle. |
java.lang.String |
toStringImpl()
|
void |
wakeup()
Is called by the SelectorManager every time the manager is awakened. |
void |
write(java.nio.channels.SelectionKey key)
Called by the socket manager whenever this node handle has registered interest in writing to it's remote node, and the socket is ready for writing. |
Methods inherited from class rice.pastry.dist.DistNodeHandle |
addObserver, afterSetLocalNode, clearChanged, countObservers, debug, deleteObserver, deleteObservers, equals, getAddress, getIsInPool, getNodeId, hasChanged, hashCode, isAlive, markAlive, markDead, notifyObservers, notifyObservers, ping, proximity, receiveMessage, setChanged, setIsInPool, setProximity, toString, update |
Methods inherited from class rice.pastry.NodeHandle |
assertLocalNode, getId, getLocalNode, setLocalNode |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static int STATE_USING_UDP
public static int STATE_USING_TCP
public static int STATE_USING_UDP_WAITING_FOR_TCP_DISCONNECT
public static int STATE_USING_UDP_WAITING_TO_DISCONNECT
public static int MAX_UDP_MESSAGE_SIZE
public static int SOCKET_BUFFER_SIZE
public static int PING_THROTTLE
private transient long lastpingtime
protected transient rice.pastry.wire.SocketChannelReader reader
protected transient SocketChannelWriter writer
protected transient java.nio.channels.SelectionKey key
protected transient int state
Constructor Detail |
public WireNodeHandle(java.net.InetSocketAddress address, rice.pastry.NodeId nid)
address
- The address of the host on which this node residesnid
- The NodeId of this hostpublic WireNodeHandle(java.net.InetSocketAddress address, rice.pastry.NodeId nid, rice.pastry.PastryNode pn)
address
- The address of the host on which this node residesnid
- The NodeId of this hostpn
- The local Pastry nodeMethod Detail |
public int getState()
public void receiveSocketMessage(rice.pastry.wire.messaging.socket.SocketCommandMessage message)
message
- The message coming across the wire.public void receiveMessageImpl(rice.pastry.messaging.Message msg)
receiveMessageImpl
in class rice.pastry.dist.DistNodeHandle
msg
- Message to be delivered, may or may not be routeMessage.protected int messageSize(java.lang.Object obj) throws java.io.IOException
obj
- The object
java.io.IOException
public void connectToRemoteNode(java.util.LinkedList messages)
public void setKey(java.nio.channels.SelectionKey key, rice.pastry.wire.messaging.socket.SocketCommandMessage scm)
key
- The new SelectionKeyprivate int getAddress(java.net.InetAddress address)
address
- The address to convert
public void sendGreetingResponse(rice.pastry.wire.messaging.socket.HelloMessage hm)
public void disconnect()
public void accept(java.nio.channels.SelectionKey key)
accept
in interface rice.pastry.wire.SelectionKeyHandler
public void connect(java.nio.channels.SelectionKey key)
connect
in interface rice.pastry.wire.SelectionKeyHandler
public void write(java.nio.channels.SelectionKey key)
write
in interface rice.pastry.wire.SelectionKeyHandler
public void read(java.nio.channels.SelectionKey key)
read
in interface rice.pastry.wire.SelectionKeyHandler
public void wakeup()
wakeup
in interface rice.pastry.wire.SelectionKeyHandler
private void close(java.util.LinkedList messages)
messages
- The messages that need to be rerouted (or null)public boolean pingImpl()
pingImpl
in class rice.pastry.dist.DistNodeHandle
public void pingStarted()
public void pingResponse()
private void readObject(java.io.ObjectInputStream ois) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public java.lang.String toStringImpl()
toStringImpl
in class rice.pastry.dist.DistNodeHandle
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |