ePOST API

rice.pastry.socket
Class SocketNodeHandle

java.lang.Object
  extended by java.util.Observable
      extended by rice.p2p.commonapi.NodeHandle
          extended by rice.pastry.NodeHandle
              extended by rice.pastry.dist.DistNodeHandle
                  extended by rice.pastry.socket.SocketNodeHandle
All Implemented Interfaces:
java.io.Serializable, java.util.Observer, MessageReceiver

public class SocketNodeHandle
extends DistNodeHandle

Class which represents the address and nodeId of a remote node. In the socket protocol, it simply represents this information - all other details are managed by the local nodes. SocketNodeHandle can now internally exist without a NodeId. This is to get the memory management correct

Version:
$Id: SocketNodeHandle.java 3197 2006-04-11 12:30:58Z jeffh $
Author:
Alan Mislove
See Also:
Serialized Form

Field Summary
static int DEFAULT_PROXIMITY
           
protected  EpochInetSocketAddress eaddress
           
static int LIVENESS_DEAD_FOREVER
           
 
Fields inherited from class rice.pastry.dist.DistNodeHandle
address, epoch, nodeId
 
Fields inherited from class rice.pastry.NodeHandle
LIVENESS_ALIVE, LIVENESS_DEAD, LIVENESS_SUSPECTED, localnode, logger
 
Fields inherited from class rice.p2p.commonapi.NodeHandle
DECLARED_DEAD, DECLARED_LIVE, PROXIMITY_CHANGED
 
Constructor Summary
SocketNodeHandle(EpochInetSocketAddress address, NodeId nodeId)
          Constructor
 
Method Summary
 void bootstrap(Message msg)
          Method which is used by Pastry to start the bootstrapping process on the local node using this handle as the bootstrap handle.
 boolean checkLiveness()
          Method which FORCES a check of liveness of the remote node.
 boolean equals(java.lang.Object obj)
          Equivalence relation for nodehandles.
 EpochInetSocketAddress getEpochAddress()
           
 int getLiveness()
          Returns the last known liveness information about the Pastry node associated with this handle.
 int hashCode()
          Hash codes for node handles.
 boolean isLocal()
          Method which returns whether or not this node handle is on its home node.
 boolean ping()
          Ping the node.
 int proximity()
          Returns the last known proximity information about the Pastry node associated with this handle.
 void receiveMessage(Message msg)
          Called to send a message to the node corresponding to this handle.
 void setLocalNode(SocketPastryNode spn)
           
 void setNodeId(NodeId nodeId)
           
 java.lang.String toString()
          Returns a String representation of this DistNodeHandle.
protected  void update(java.lang.Object update)
          Method which allows the observers of this socket node handle to be updated.
 void update(java.util.Observable o, java.lang.Object obj)
          DESCRIBE THE METHOD
 
Methods inherited from class rice.pastry.dist.DistNodeHandle
getAddress, getEpoch, getNodeId
 
Methods inherited from class rice.pastry.NodeHandle
assertLocalNode, getId, getLocalNode, isAlive
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LIVENESS_DEAD_FOREVER

public static final int LIVENESS_DEAD_FOREVER
See Also:
Constant Field Values

DEFAULT_PROXIMITY

public static int DEFAULT_PROXIMITY

eaddress

protected EpochInetSocketAddress eaddress
Constructor Detail

SocketNodeHandle

public SocketNodeHandle(EpochInetSocketAddress address,
                        NodeId nodeId)
Constructor

Parameters:
nodeId - This node handle's node Id.
address - DESCRIBE THE PARAMETER
Method Detail

getEpochAddress

public EpochInetSocketAddress getEpochAddress()

getLiveness

public int getLiveness()
Returns the last known liveness information about the Pastry node associated with this handle. Invoking this method does not cause network activity.

Specified by:
getLiveness in class NodeHandle
Returns:
true if the node is alive, false otherwise.

checkLiveness

public boolean checkLiveness()
Method which FORCES a check of liveness of the remote node. Note that this method should ONLY be called by internal Pastry maintenance algorithms - this is NOT to be used by applications. Doing so will likely cause a blowup of liveness traffic.

Overrides:
checkLiveness in class NodeHandle
Returns:
true if node is currently alive.

isLocal

public boolean isLocal()
Method which returns whether or not this node handle is on its home node.

Returns:
Whether or not this handle is local

receiveMessage

public void receiveMessage(Message msg)
Called to send a message to the node corresponding to this handle.

Parameters:
msg - Message to be delivered, may or may not be routeMessage.

bootstrap

public void bootstrap(Message msg)
Method which is used by Pastry to start the bootstrapping process on the local node using this handle as the bootstrap handle. Default behavior is simply to call receiveMessage(msg), but transport layer implementations may care to perform other tasks by overriding this method, since the node is not technically part of the ring yet.

Overrides:
bootstrap in class NodeHandle
Parameters:
msg - the bootstrap message.

toString

public java.lang.String toString()
Returns a String representation of this DistNodeHandle. This method is designed to be called by clients using the node handle, and is provided in order to ensure that the right node handle is being talked to.

Specified by:
toString in class DistNodeHandle
Returns:
A String representation of the node handle.

equals

public boolean equals(java.lang.Object obj)
Equivalence relation for nodehandles. They are equal if and only if their corresponding NodeIds are equal.

Specified by:
equals in class DistNodeHandle
Parameters:
obj - the other nodehandle .
Returns:
true if they are equal, false otherwise.

hashCode

public int hashCode()
Hash codes for node handles. It is the hashcode of their corresponding NodeId's.

Specified by:
hashCode in class DistNodeHandle
Returns:
a hash code.

proximity

public int proximity()
Returns the last known proximity information about the Pastry node associated with this handle. Invoking this method does not cause network activity. Smaller values imply greater proximity. The exact nature and interpretation of the proximity metric implementation-specific.

Specified by:
proximity in class NodeHandle
Returns:
the proximity metric value

ping

public boolean ping()
Ping the node. Refreshes the cached liveness status and proximity value of the Pastry node associated with this. Invoking this method causes network activity.

Specified by:
ping in class NodeHandle
Returns:
true if node is currently alive.

update

public void update(java.util.Observable o,
                   java.lang.Object obj)
DESCRIBE THE METHOD

Parameters:
o - DESCRIBE THE PARAMETER
obj - DESCRIBE THE PARAMETER

update

protected void update(java.lang.Object update)
Method which allows the observers of this socket node handle to be updated. This method sets this object as changed, and then sends out the update.

Parameters:
update - The update

setNodeId

public void setNodeId(NodeId nodeId)

setLocalNode

public void setLocalNode(SocketPastryNode spn)

ePOST API

Copyright © 2001-2005 - Rice Pastry.