planet.commonapi
Class NodeHandle

java.lang.Object
  extended byjava.util.Observable
      extended byplanet.commonapi.NodeHandle
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NodeHandleImpl

public abstract class NodeHandle
extends java.util.Observable
implements java.io.Serializable

This interface is an abstraction of a node handle from the CommonAPI paper. A node handle is a handle to a known node, which conceptually includes the node's Id, as well as the node's underlying network address (such as IP/port).

Author:
Jordi Pujol 07-jul-2005
See Also:
Serialized Form

Field Summary
static java.lang.Integer DECLARED_DEAD
           
static java.lang.Integer DECLARED_LIVE
           
static java.lang.Integer PROXIMITY_CHANGED
           
 
Constructor Summary
NodeHandle()
           
 
Method Summary
abstract  Id getId()
          Returns this node's id.
abstract  int getProximity()
          Evaluates the proximity between the node who invokes this method, and the node that represents this NodeHandle.
abstract  boolean isAlive()
          Returns whether or not this node is currently alive
abstract  void setAlive(boolean alive)
          Updates the alive flag.
abstract  NodeHandle setValues(Id newValue)
          Sets the new Id for this NodeHandle, and the flag 'alive' to true.
abstract  NodeHandle setValues(Id newValue, boolean alive)
          Sets the new Id for this NodeHandle, and the flag 'alive' to the specified value.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXIMITY_CHANGED

public static final java.lang.Integer PROXIMITY_CHANGED

DECLARED_DEAD

public static final java.lang.Integer DECLARED_DEAD

DECLARED_LIVE

public static final java.lang.Integer DECLARED_LIVE
Constructor Detail

NodeHandle

public NodeHandle()
Method Detail

getId

public abstract Id getId()
Returns this node's id.

Returns:
The corresponding node's id.

isAlive

public abstract boolean isAlive()
Returns whether or not this node is currently alive

Returns:
Whether or not this node is currently alive

setAlive

public abstract void setAlive(boolean alive)
Updates the alive flag.

Parameters:
alive - New value for the alive flag.

getProximity

public abstract int getProximity()
Evaluates the proximity between the node who invokes this method, and the node that represents this NodeHandle.

Returns:
The proximity between the two nodes, who invokes and the node represented by this NodeHandle.

setValues

public abstract NodeHandle setValues(Id newValue)
Sets the new Id for this NodeHandle, and the flag 'alive' to true.

Parameters:
newValue - The new Id
Returns:
The same instance, after being updated.

setValues

public abstract NodeHandle setValues(Id newValue,
                                     boolean alive)
Sets the new Id for this NodeHandle, and the flag 'alive' to the specified value.

Parameters:
newValue - The new Id
alive - true if the NodeHandle is alive.
Returns:
The same instance, after being updated.