Rice Pastry API

rice.pastry.direct
Class DirectNodeHandle

java.lang.Object
  extended by java.util.Observable
      extended by rice.p2p.commonapi.NodeHandle
          extended by rice.pastry.NodeHandle
              extended by rice.pastry.socket.TransportLayerNodeHandle<NodeRecord>
                  extended by rice.pastry.direct.DirectNodeHandle
All Implemented Interfaces:
java.io.Serializable, java.util.Observer, RawSerializable

public class DirectNodeHandle
extends TransportLayerNodeHandle<NodeRecord>
implements java.util.Observer

the node handle used with the direct network

Version:
$Id: DirectNodeHandle.java 4632 2008-12-11 15:39:45Z jeffh $
Author:
Andrew Ladd, Rongmei Zhang/Y. Charlie Hu
See Also:
Serialized Form

Field Summary
 NetworkSimulator simulator
           
 
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
protected DirectNodeHandle(PastryNode ln, NetworkSimulator sim)
          Constructor for DirectNodeHandle.
 
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.
 boolean equals(java.lang.Object obj)
          Equivalence relation for nodehandles.
 NodeRecord getAddress()
           
 long getEpoch()
           
 int getLiveness()
          Gets the Alive attribute of the DirectNodeHandle object
 Id getNodeId()
          Gets the NodeId attribute of the DirectNodeHandle object
 PastryNode getRemote()
          Gets the Remote attribute of the DirectNodeHandle object
 NetworkSimulator getSimulator()
          Gets the Simulator attribute of the DirectNodeHandle object
 int hashCode()
          Hash codes for node handles.It is the hashcode of their corresponding NodeId's.
 void notifyObservers(java.lang.Object arg)
          DESCRIBE THE METHOD
 boolean ping()
          DESCRIBE THE METHOD
 int proximity()
          Deprecated.  
 void receiveMessage(Message msg)
          Deprecated. use PastryNode.send()
 void serialize(OutputBuffer buf)
           
 java.lang.String toString()
          DESCRIBE THE METHOD
 void update(java.util.Observable arg0, java.lang.Object arg1)
          Only notify if dead.
 
Methods inherited from class rice.pastry.NodeHandle
addObserver, addObserver, bootstrap, checkLiveness, countObservers, deleteObserver, deleteObservers, getId, getLocalNode, isAlive, update
 
Methods inherited from class java.util.Observable
clearChanged, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

simulator

public transient NetworkSimulator simulator
Constructor Detail

DirectNodeHandle

protected DirectNodeHandle(PastryNode ln,
                           NetworkSimulator sim)
Constructor for DirectNodeHandle.

Parameters:
ln - The local pastry node
sim - The current network simulator
Method Detail

getRemote

public PastryNode getRemote()
Gets the Remote attribute of the DirectNodeHandle object

Returns:
The Remote value

getNodeId

public Id getNodeId()
Gets the NodeId attribute of the DirectNodeHandle object

Specified by:
getNodeId in class NodeHandle
Returns:
The NodeId value

getLiveness

public int getLiveness()
Gets the Alive attribute of the DirectNodeHandle object

Specified by:
getLiveness in class NodeHandle
Returns:
The Alive value

getSimulator

public NetworkSimulator getSimulator()
Gets the Simulator attribute of the DirectNodeHandle object

Returns:
The Simulator value

notifyObservers

public void notifyObservers(java.lang.Object arg)
DESCRIBE THE METHOD

Overrides:
notifyObservers in class NodeHandle
Parameters:
arg - DESCRIBE THE PARAMETER

ping

public boolean ping()
DESCRIBE THE METHOD

Specified by:
ping in class NodeHandle
Returns:
DESCRIBE THE RETURN VALUE

assertLocalNode

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

Overrides:
assertLocalNode in class NodeHandle

proximity

public int proximity()
Deprecated. 

DESCRIBE THE METHOD

Specified by:
proximity in class NodeHandle
Returns:
DESCRIBE THE RETURN VALUE

receiveMessage

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

DESCRIBE THE METHOD

Specified by:
receiveMessage in class NodeHandle
Parameters:
msg - DESCRIBE THE PARAMETER

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 NodeHandle
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 NodeHandle
Returns:
a hash code.

toString

public java.lang.String toString()
DESCRIBE THE METHOD

Overrides:
toString in class java.lang.Object
Returns:
DESCRIBE THE RETURN VALUE

update

public void update(java.util.Observable arg0,
                   java.lang.Object arg1)
Only notify if dead. Note that this is limitied in that it's not possible to simulate a byzantine failure of a node. But that's out of the scope of the simulator. If we leave in the first arg, the node notifies DECLARED_LIVE way too often.

Specified by:
update in interface java.util.Observer

serialize

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

getAddress

public NodeRecord getAddress()
Specified by:
getAddress in class TransportLayerNodeHandle<NodeRecord>

getEpoch

public long getEpoch()
Specified by:
getEpoch in class TransportLayerNodeHandle<NodeRecord>

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection