Rice Pastry 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, RawSerializable
Direct Known Subclasses:
LeafSetTest.TestNodeHandle, MergeTest.TestNodeHandle, TransportLayerNodeHandle

public abstract class NodeHandle
extends NodeHandle
implements RawSerializable

Interface for handles to remote nodes.

Version:
$Id: NodeHandle.java 4654 2009-01-08 16:33:07Z 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 addObserver(java.util.Observer o)
           
 void addObserver(java.util.Observer o, int priority)
           
 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.
 int countObservers()
           
 void deleteObserver(java.util.Observer o)
           
 void deleteObservers()
           
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  Id getNodeId()
          Gets the nodeId of this Pastry node.
abstract  int hashCode()
          Hash codes for nodehandles.
 boolean isAlive()
          Deprecated. use PastryNode.isAlive(NodeHandle)
 void notifyObservers(java.lang.Object arg)
           
abstract  boolean ping()
          Ping the node.
abstract  int proximity()
          Deprecated. use PastryNode.proximity() or Endpoint.proximity()
abstract  void receiveMessage(Message msg)
          Deprecated. use PastryNode.send() or Endpoint.send()
abstract  void serialize(OutputBuffer buf)
           
 void update(java.lang.Object update)
          Method which allows the observers of this socket node handle to be updated.
 
Methods inherited from class java.util.Observable
clearChanged, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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 Id 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()
Deprecated. use PastryNode.isAlive(NodeHandle)

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()
Deprecated. use PastryNode.proximity() or Endpoint.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)
               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.

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

receiveMessage

public abstract void receiveMessage(Message msg)
Deprecated. use PastryNode.send() or Endpoint.send()

Parameters:
msg -

serialize

public abstract void serialize(OutputBuffer buf)
                        throws java.io.IOException
Specified by:
serialize in interface RawSerializable
Specified by:
serialize in class NodeHandle
Throws:
java.io.IOException

addObserver

public void addObserver(java.util.Observer o)
Overrides:
addObserver in class java.util.Observable

addObserver

public void addObserver(java.util.Observer o,
                        int priority)
Parameters:
o -
priority - higher priority observers will be called first

deleteObserver

public void deleteObserver(java.util.Observer o)
Overrides:
deleteObserver in class java.util.Observable

notifyObservers

public void notifyObservers(java.lang.Object arg)
Overrides:
notifyObservers in class java.util.Observable

countObservers

public int countObservers()
Overrides:
countObservers in class java.util.Observable

deleteObservers

public void deleteObservers()
Overrides:
deleteObservers in class java.util.Observable

update

public 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

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection