ePOST API

rice.pastry
Class NodeHandle

java.lang.Object
  extended by java.util.Observable
      extended by rice.p2p.commonapi.NodeHandle
          extended by rice.pastry.NodeHandle
All Implemented Interfaces:
java.io.Serializable, MessageReceiver
Direct Known Subclasses:
DirectNodeHandle, DistNodeHandle, LeafSetTest.TestNodeHandle

public abstract class NodeHandle
extends NodeHandle
implements MessageReceiver

Interface for handles to remote nodes.

Version:
$Id: NodeHandle.java 3038 2006-02-07 10:01:01Z jeffh $
Author:
Andrew Ladd
See Also:
Serialized Form

Field Summary
static int LIVENESS_ALIVE
           
static int LIVENESS_DEAD
           
static int LIVENESS_SUSPECTED
           
protected  PastryNode localnode
           
protected  Logger logger
           
 
Fields inherited from class rice.p2p.commonapi.NodeHandle
DECLARED_DEAD, DECLARED_LIVE, PROXIMITY_CHANGED
 
Constructor Summary
NodeHandle()
           
 
Method Summary
 void assertLocalNode()
          May be called from handle etc methods to ensure that local node has been set, either on construction or on deserialization/receivemsg.
 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.
abstract  boolean equals(java.lang.Object obj)
          Equality operator for nodehandles.
 Id getId()
          Returns this node's id.
abstract  int getLiveness()
          A more detailed version of isAlive().
 PastryNode getLocalNode()
          Accessor method.
abstract  NodeId getNodeId()
          Gets the nodeId of this Pastry node.
abstract  int hashCode()
          Hash codes for nodehandles.
 boolean isAlive()
          Returns the last known liveness information about the Pastry node associated with this handle.
abstract  boolean ping()
          Ping the node.
abstract  int proximity()
          Returns the last known proximity information about the Pastry node associated with this handle.
 
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, toString, wait, wait, wait
 
Methods inherited from interface rice.pastry.messaging.MessageReceiver
receiveMessage
 

Field Detail

LIVENESS_ALIVE

public static final int LIVENESS_ALIVE
See Also:
Constant Field Values

LIVENESS_SUSPECTED

public static final int LIVENESS_SUSPECTED
See Also:
Constant Field Values

LIVENESS_DEAD

public static final int LIVENESS_DEAD
See Also:
Constant Field Values

localnode

protected transient PastryNode localnode

logger

protected transient Logger logger
Constructor Detail

NodeHandle

public NodeHandle()
Method Detail

getNodeId

public abstract NodeId getNodeId()
Gets the nodeId of this Pastry node.

Returns:
the node id.

getId

public Id getId()
Description copied from class: NodeHandle
Returns this node's id.

Specified by:
getId in class NodeHandle
Returns:
The corresponding node's id.

isAlive

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

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

getLiveness

public abstract int getLiveness()
A more detailed version of isAlive(). This can return 3 states:

Returns:
LIVENESS_ALIVE, LIVENESS_SUSPECTED, LIVENESS_DEAD

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.

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

proximity

public abstract 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 abstract 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.

Returns:
true if node is currently alive.

getLocalNode

public final PastryNode getLocalNode()
Accessor method.


assertLocalNode

public void assertLocalNode()
May be called from handle etc methods to ensure that local node has been set, either on construction or on deserialization/receivemsg.


equals

public abstract boolean equals(java.lang.Object obj)
Equality operator for nodehandles.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a nodehandle object
Returns:
true if they are equal, false otherwise.

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.

Parameters:
msg - the bootstrap message.

hashCode

public abstract int hashCode()
Hash codes for nodehandles.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code.

ePOST API

Copyright © 2001-2005 - Rice Pastry.