Rice Pastry API

rice.pastry.socket
Class SocketNodeHandle

java.lang.Object
  extended byjava.util.Observable
      extended byrice.p2p.commonapi.NodeHandle
          extended byrice.pastry.NodeHandle
              extended byrice.pastry.dist.DistNodeHandle
                  extended byrice.pastry.socket.SocketNodeHandle
All Implemented Interfaces:
LocalNodeI, MessageReceiver, java.util.Observer, java.io.Serializable

public class SocketNodeHandle
extends DistNodeHandle

Class which represents the address and nodeId of a remote node. In the socket protocol, it simply represents this information - all other details are managed by the local nodes.

Version:
$Id: SocketNodeHandle.java,v 1.28 2005/06/07 22:02:11 jeffh Exp $
Author:
Alan Mislove
See Also:
Serialized Form

Field Summary
static int DEFAULT_PROXIMITY
          DESCRIBE THE FIELD
protected  EpochInetSocketAddress eaddress
          DESCRIBE THE FIELD
static int LIVENESS_DEAD_FOREVER
          DESCRIBE THE FIELD
 
Fields inherited from class rice.pastry.dist.DistNodeHandle
address, epoch, nodeId
 
Fields inherited from class rice.pastry.NodeHandle
LIVENESS_ALIVE, LIVENESS_DEAD, LIVENESS_SUSPECTED, localnode
 
Fields inherited from class rice.p2p.commonapi.NodeHandle
DECLARED_DEAD, DECLARED_LIVE, PROXIMITY_CHANGED
 
Constructor Summary
SocketNodeHandle(EpochInetSocketAddress address, NodeId nodeId)
          Constructor
 
Method Summary
 void afterSetLocalNode()
          Method which registers this handle with the node that it is currently on.
 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.
 boolean equals(java.lang.Object obj)
          Equivalence relation for nodehandles.
 EpochInetSocketAddress getEpochAddress()
          Gets the EpochAddress attribute of the SocketNodeHandle object
 int getLiveness()
          Returns the last known liveness information about the Pastry node associated with this handle.
 int hashCode()
          Hash codes for node handles.
 boolean isLocal()
          Method which returns whether or not this node handle is on its home node.
 boolean ping()
          Ping the node.
 int proximity()
          Returns the last known proximity information about the Pastry node associated with this handle.
 void receiveMessage(Message msg)
          Called to send a message to the node corresponding to this handle.
 java.lang.String toString()
          Returns a String representation of this DistNodeHandle.
protected  void update(java.lang.Object update)
          Method which allows the observers of this socket node handle to be updated.
 void update(java.util.Observable o, java.lang.Object obj)
          DESCRIBE THE METHOD
 
Methods inherited from class rice.pastry.dist.DistNodeHandle
getAddress, getEpoch, getNodeId
 
Methods inherited from class rice.pastry.NodeHandle
assertLocalNode, getId, getLocalNode, isAlive, setLocalNode
 
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, wait, wait, wait
 

Field Detail

eaddress

protected EpochInetSocketAddress eaddress
DESCRIBE THE FIELD


LIVENESS_DEAD_FOREVER

public static final int LIVENESS_DEAD_FOREVER
DESCRIBE THE FIELD

See Also:
Constant Field Values

DEFAULT_PROXIMITY

public static int DEFAULT_PROXIMITY
DESCRIBE THE FIELD

Constructor Detail

SocketNodeHandle

public SocketNodeHandle(EpochInetSocketAddress address,
                        NodeId nodeId)
Constructor

Parameters:
nodeId - This node handle's node Id.
address - DESCRIBE THE PARAMETER
Method Detail

getEpochAddress

public EpochInetSocketAddress getEpochAddress()
Gets the EpochAddress attribute of the SocketNodeHandle object

Returns:
The EpochAddress value

getLiveness

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

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

isLocal

public boolean isLocal()
Method which returns whether or not this node handle is on its home node.

Returns:
Whether or not this handle is local

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.

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

receiveMessage

public void receiveMessage(Message msg)
Called to send a message to the node corresponding to this handle.

Parameters:
msg - Message to be delivered, may or may not be routeMessage.

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.

Overrides:
bootstrap in class NodeHandle
Parameters:
msg - the bootstrap message.

toString

public java.lang.String toString()
Returns a String representation of this DistNodeHandle. This method is designed to be called by clients using the node handle, and is provided in order to ensure that the right node handle is being talked to.

Specified by:
toString in class DistNodeHandle
Returns:
A String representation of the node handle.

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

proximity

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

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

afterSetLocalNode

public void afterSetLocalNode()
Method which registers this handle with the node that it is currently on.

Overrides:
afterSetLocalNode in class NodeHandle

update

public void update(java.util.Observable o,
                   java.lang.Object obj)
DESCRIBE THE METHOD

Parameters:
o - DESCRIBE THE PARAMETER
obj - DESCRIBE THE PARAMETER

update

protected 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