Rice Pastry API

rice.pastry.pns
Class PNSApplication

java.lang.Object
  extended by rice.pastry.client.PastryAppl
      extended by rice.pastry.pns.PNSApplication
All Implemented Interfaces:
ProximityListener<NodeHandle>, ProximityNeighborSelector

public class PNSApplication
extends PastryAppl
implements ProximityNeighborSelector, ProximityListener<NodeHandle>

Can request LeafSet, RouteRow, Proximity of nodes, implemts the PNS algorithim. TODO: Make use the environment's clock for the wait() calls.

Author:
Jeff Hoye

Field Summary
static int DEFAULT_PROXIMITY
           
protected  Environment environment
           
protected  java.util.Hashtable<NodeHandle,java.lang.Integer> pingCache
          Hashtable which keeps track of temporary ping values, which are only used during the getNearest() method
protected  byte rtBase
           
protected  Timer timer
           
 
Fields inherited from class rice.pastry.client.PastryAppl
address, deserializer, instance, logger, options, receiver, thePastryNode
 
Constructor Summary
PNSApplication(PastryNode pn)
           
 
Method Summary
protected  void addToWaitingForLeafSet(NodeHandle handle, Continuation<LeafSet,java.lang.Exception> c)
           
protected  void addToWaitingForRouteRow(NodeHandle handle, int row, Continuation<RouteSet[],java.lang.Exception> c)
           
 LeafSet getLeafSet(NodeHandle handle)
          This method returns the remote leafset of the provided handle to the caller, in a protocol-dependent fashion.
 Cancellable getLeafSet(NodeHandle handle, Continuation<LeafSet,java.lang.Exception> c)
          Non-blocking version.
 NodeHandle[] getNearest(NodeHandle seed)
          This method implements the algorithm in the Pastry locality paper for finding a close node the the current node through iterative leafset and route row requests.
 void getNearHandles(java.util.Collection<NodeHandle> bootHandles, Continuation<java.util.Collection<NodeHandle>,java.lang.Exception> deliverResultToMe)
           
 int getProximity(NodeHandle handle)
          This method determines and returns the proximity of the current local node the provided NodeHandle.
 void getProximity(NodeHandle handle, Continuation<java.lang.Integer,java.io.IOException> c)
          Non-blocking version, no timeout.
 RouteSet[] getRouteRow(NodeHandle handle, short row)
          This method returns the remote route row of the provided handle to the caller, in a protocol-dependent fashion.
 Cancellable getRouteRow(NodeHandle handle, short row, Continuation<RouteSet[],java.lang.Exception> c)
          Non-blocking version.
 void messageForAppl(Message msg)
          Called by pastry when a message arrives for this application.
protected  int proximity(NodeHandle handle)
          Method which checks to see if we have a cached value of the remote ping, and if not, initiates a ping and then caches the value
 void proximityChanged(NodeHandle i, int newProximity, java.util.Map<java.lang.String,java.lang.Integer> options)
           
protected  boolean removeFromWaitingForLeafSet(NodeHandle handle, Continuation<LeafSet,java.lang.Exception> c)
           
protected  boolean removeFromWaitingForRouteRow(NodeHandle handle, int row, Continuation<RouteSet[],java.lang.Exception> c)
           
 NodeHandle[] sortedProximityCache()
           
 
Methods inherited from class rice.pastry.client.PastryAppl
accept, canReceiveSocket, connect, deliverWhenNotReady, destroy, enrouteMessage, finishReceiveSocket, getAddress, getDeserializer, getLeafSet, getNodeHandle, getNodeId, getRoutingTable, isClosest, leafSetChange, notifyReady, receiveMessage, receiveMessageInternal, register, routeMsg, routeMsgDirect, routeSetChange, setDeserializer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROXIMITY

public static final int DEFAULT_PROXIMITY
See Also:
Constant Field Values

pingCache

protected java.util.Hashtable<NodeHandle,java.lang.Integer> pingCache
Hashtable which keeps track of temporary ping values, which are only used during the getNearest() method


rtBase

protected final byte rtBase

environment

protected Environment environment

timer

protected Timer timer
Constructor Detail

PNSApplication

public PNSApplication(PastryNode pn)
Method Detail

messageForAppl

public void messageForAppl(Message msg)
Description copied from class: PastryAppl
Called by pastry when a message arrives for this application.

Specified by:
messageForAppl in class PastryAppl
Parameters:
msg - the message that is arriving.

getNearHandles

public void getNearHandles(java.util.Collection<NodeHandle> bootHandles,
                           Continuation<java.util.Collection<NodeHandle>,java.lang.Exception> deliverResultToMe)
Specified by:
getNearHandles in interface ProximityNeighborSelector

getLeafSet

public LeafSet getLeafSet(NodeHandle handle)
                   throws java.io.IOException
This method returns the remote leafset of the provided handle to the caller, in a protocol-dependent fashion. Note that this method may block while sending the message across the wire.

Parameters:
handle - The node to connect to
Returns:
The leafset of the remote node
Throws:
java.io.IOException

getLeafSet

public Cancellable getLeafSet(NodeHandle handle,
                              Continuation<LeafSet,java.lang.Exception> c)
Non-blocking version.

Parameters:
handle -
c -
Returns:
Throws:
java.io.IOException

removeFromWaitingForLeafSet

protected boolean removeFromWaitingForLeafSet(NodeHandle handle,
                                              Continuation<LeafSet,java.lang.Exception> c)

addToWaitingForLeafSet

protected void addToWaitingForLeafSet(NodeHandle handle,
                                      Continuation<LeafSet,java.lang.Exception> c)

getRouteRow

public RouteSet[] getRouteRow(NodeHandle handle,
                              short row)
                       throws java.io.IOException
This method returns the remote route row of the provided handle to the caller, in a protocol-dependent fashion. Note that this method may block while sending the message across the wire.

Parameters:
handle - The node to connect to
row - The row number to retrieve
Returns:
The route row of the remote node
Throws:
java.io.IOException

getRouteRow

public Cancellable getRouteRow(NodeHandle handle,
                               short row,
                               Continuation<RouteSet[],java.lang.Exception> c)
Non-blocking version.

Parameters:
handle -
row -
c -
Returns:
Throws:
java.io.IOException

addToWaitingForRouteRow

protected void addToWaitingForRouteRow(NodeHandle handle,
                                       int row,
                                       Continuation<RouteSet[],java.lang.Exception> c)

removeFromWaitingForRouteRow

protected boolean removeFromWaitingForRouteRow(NodeHandle handle,
                                               int row,
                                               Continuation<RouteSet[],java.lang.Exception> c)

getProximity

public int getProximity(NodeHandle handle)
This method determines and returns the proximity of the current local node the provided NodeHandle. This will need to be done in a protocol- dependent fashion and may need to be done in a special way. Timeout of 5 seconds.

Parameters:
handle - The handle to determine the proximity of
Returns:
The proximity of the provided handle

getProximity

public void getProximity(NodeHandle handle,
                         Continuation<java.lang.Integer,java.io.IOException> c)
Non-blocking version, no timeout. TODO: Make this fail early if faulty.

Parameters:
handle -
c -

proximityChanged

public void proximityChanged(NodeHandle i,
                             int newProximity,
                             java.util.Map<java.lang.String,java.lang.Integer> options)
Specified by:
proximityChanged in interface ProximityListener<NodeHandle>

proximity

protected int proximity(NodeHandle handle)
Method which checks to see if we have a cached value of the remote ping, and if not, initiates a ping and then caches the value

Parameters:
handle - The handle to ping
Returns:
The proximity of the handle

sortedProximityCache

public NodeHandle[] sortedProximityCache()

getNearest

public NodeHandle[] getNearest(NodeHandle seed)
This method implements the algorithm in the Pastry locality paper for finding a close node the the current node through iterative leafset and route row requests. The seed node provided is any node in the network which is a member of the pastry ring. This algorithm is designed to work in a protocol-independent manner, using the getResponse(Message) method provided by subclasses.

Parameters:
seed - Any member of the pastry ring
Returns:
A node suitable to boot off of (which is close the this node)

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection