Rice Pastry API

rice.pastry
Class NodeHandle

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

public abstract class NodeHandle
extends NodeHandle

Interface for handles to remote nodes.

Version:
$Id: NodeHandle.java 3274 2006-05-15 16:17:47Z jeffh $
Author:
Andrew Ladd
See Also:
Serialized Form

Field Summary
static int LIVENESS_ALIVE
          DESCRIBE THE FIELD
static int LIVENESS_DEAD
          DESCRIBE THE FIELD
static int LIVENESS_SUSPECTED
          DESCRIBE THE FIELD
protected  PastryNode localnode
          DESCRIBE THE FIELD
protected  Logger logger
          DESCRIBE THE FIELD
 
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()
          Gets the Id attribute of the NodeHandle object
abstract  int getLiveness()
          A more detailed version of isAlive().
 PastryNode getLocalNode()
          Accessor method.
abstract  Id 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.
abstract  void receiveMessage(Message msg)
          DESCRIBE THE METHOD
abstract  void serialize(OutputBuffer buf)
          DESCRIBE THE METHOD
 
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
 

Field Detail

localnode

protected transient PastryNode localnode
DESCRIBE THE FIELD


logger

protected transient Logger logger
DESCRIBE THE FIELD


LIVENESS_ALIVE

public static final int LIVENESS_ALIVE
DESCRIBE THE FIELD

See Also:
Constant Field Values

LIVENESS_SUSPECTED

public static final int LIVENESS_SUSPECTED
DESCRIBE THE FIELD

See Also:
Constant Field Values

LIVENESS_DEAD

public static final int LIVENESS_DEAD
DESCRIBE THE FIELD

See Also:
Constant Field Values
Constructor Detail

NodeHandle

public NodeHandle()
Method Detail

getNodeId

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

Returns:
the node id.

getId

public Id getId()
Gets the Id attribute of the NodeHandle object

Specified by:
getId in class NodeHandle
Returns:
The Id value

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

getLocalNode

public final PastryNode getLocalNode()
Accessor method.

Returns:
The LocalNode value

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.

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.

Parameters:
obj - a nodehandle object
Returns:
true if they are equal, false otherwise.

bootstrap

public void bootstrap(Message msg)
               throws java.io.IOException
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.
Throws:
java.io.IOException

hashCode

public abstract int hashCode()
Hash codes for nodehandles.

Returns:
a hash code.

receiveMessage

public abstract void receiveMessage(Message msg)
DESCRIBE THE METHOD

Parameters:
msg - DESCRIBE THE PARAMETER

serialize

public abstract void serialize(OutputBuffer buf)
                        throws java.io.IOException
DESCRIBE THE METHOD

Specified by:
serialize in class NodeHandle
Parameters:
buf - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection