Rice Pastry API

rice.pastry.standard
Class PeriodicLeafSetProtocol

java.lang.Object
  extended by rice.pastry.client.PastryAppl
      extended by rice.pastry.standard.PeriodicLeafSetProtocol
All Implemented Interfaces:
java.util.Observer, NodeSetListener, ReadyStrategy

public class PeriodicLeafSetProtocol
extends PastryAppl
implements ReadyStrategy, NodeSetListener, java.util.Observer

An implementation of a periodic-style leafset protocol

Version:
$Id: PeriodicLeafSetProtocol.java 3498 2006-12-17 20:53:03Z jeffh $
Author:
Alan Mislove

Nested Class Summary
static class PeriodicLeafSetProtocol.PLSPMessageDeserializer
           
 
Field Summary
 int BLS_THROTTLE
           
 int CHECK_LIVENESS_PERIOD
           
protected  java.util.Map lastTimeReceivedBLS
          NodeHandle -> Long remembers the TIME when we received a BLS from that NodeHandle
protected  java.util.Map lastTimeSentBLS
           
protected  LeafSet leafSet
           
 int LEASE_PERIOD
           
protected  NodeHandle localHandle
           
protected  PastryNode localNode
           
 int PING_NEIGHBOR_PERIOD
          Related to rapidly determining direct neighbor liveness.
protected  RoutingTable routeTable
           
 
Fields inherited from class rice.pastry.client.PastryAppl
address, deserializer, instance, logger, receiver, thePastryNode
 
Constructor Summary
PeriodicLeafSetProtocol(PastryNode ln, NodeHandle local, LeafSet ls, RoutingTable rt)
          Builds a periodic leafset protocol
 
Method Summary
protected  void broadcastAll()
          Broadcast the leaf set to all members of the local leaf set.
 boolean deliverWhenNotReady()
          We always want to receive messages.
 void destroy()
          Called when PastryNode is destroyed.
 boolean isReady()
          Gets the Ready attribute of the ReadyStrategy object
 void leafSetChange(NodeHandle nh, boolean wasAdded)
          Called by pastry when the leaf set changes.
 void messageForAppl(Message msg)
          Should not be called becasue we are overriding the receiveMessage() interface anyway.
 void nodeSetUpdate(NodeSetEventSource nodeSetEventSource, NodeHandle handle, boolean added)
          DESCRIBE THE METHOD
 void receiveMessage(Message msg)
          Receives messages.
 void setReady(boolean r)
          Sets the Ready attribute of the ReadyStrategy object
 boolean shouldBeReady()
           
 void start()
          Called when it is time to take over as the renderstrategy.
 void update(java.util.Observable o, java.lang.Object arg)
          Only remove the item if you did not give a lease.
 
Methods inherited from class rice.pastry.client.PastryAppl
accept, connect, enrouteMessage, getAddress, getLeafSet, getNodeHandle, getNodeId, getRoutingTable, isClosest, notifyReady, receiveMessageInternal, receiveSocket, 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

localHandle

protected NodeHandle localHandle

localNode

protected PastryNode localNode

leafSet

protected LeafSet leafSet

routeTable

protected RoutingTable routeTable

lastTimeReceivedBLS

protected java.util.Map lastTimeReceivedBLS
NodeHandle -> Long remembers the TIME when we received a BLS from that NodeHandle


lastTimeSentBLS

protected java.util.Map lastTimeSentBLS

PING_NEIGHBOR_PERIOD

public final int PING_NEIGHBOR_PERIOD
Related to rapidly determining direct neighbor liveness.


LEASE_PERIOD

public final int LEASE_PERIOD

CHECK_LIVENESS_PERIOD

public final int CHECK_LIVENESS_PERIOD

BLS_THROTTLE

public final int BLS_THROTTLE
See Also:
Constant Field Values
Constructor Detail

PeriodicLeafSetProtocol

public PeriodicLeafSetProtocol(PastryNode ln,
                               NodeHandle local,
                               LeafSet ls,
                               RoutingTable rt)
Builds a periodic leafset protocol

Method Detail

receiveMessage

public void receiveMessage(Message msg)
Receives messages.

Overrides:
receiveMessage in class PastryAppl
Parameters:
msg - the message.

broadcastAll

protected void broadcastAll()
Broadcast the leaf set to all members of the local leaf set.

Parameters:
type - the type of broadcast message used

start

public void start()
Description copied from interface: ReadyStrategy
Called when it is time to take over as the renderstrategy.

Specified by:
start in interface ReadyStrategy

nodeSetUpdate

public void nodeSetUpdate(NodeSetEventSource nodeSetEventSource,
                          NodeHandle handle,
                          boolean added)
Description copied from interface: NodeSetListener
DESCRIBE THE METHOD

Specified by:
nodeSetUpdate in interface NodeSetListener
Parameters:
nodeSetEventSource - DESCRIBE THE PARAMETER
handle - DESCRIBE THE PARAMETER
added - DESCRIBE THE PARAMETER

setReady

public void setReady(boolean r)
Description copied from interface: ReadyStrategy
Sets the Ready attribute of the ReadyStrategy object

Specified by:
setReady in interface ReadyStrategy
Parameters:
r - The new Ready value

isReady

public boolean isReady()
Description copied from interface: ReadyStrategy
Gets the Ready attribute of the ReadyStrategy object

Specified by:
isReady in interface ReadyStrategy
Returns:
The Ready value

shouldBeReady

public boolean shouldBeReady()

messageForAppl

public void messageForAppl(Message msg)
Should not be called becasue we are overriding the receiveMessage() interface anyway.

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

deliverWhenNotReady

public boolean deliverWhenNotReady()
We always want to receive messages.

Overrides:
deliverWhenNotReady in class PastryAppl
Returns:
false unless the node is a service

destroy

public void destroy()
Description copied from class: PastryAppl
Called when PastryNode is destroyed. Can be overloaded by applications.

Overrides:
destroy in class PastryAppl

leafSetChange

public void leafSetChange(NodeHandle nh,
                          boolean wasAdded)
Description copied from class: PastryAppl
Called by pastry when the leaf set changes.

Overrides:
leafSetChange in class PastryAppl
Parameters:
nh - the handle of the node that was added or removed.
wasAdded - true if the node was added, false if the node was removed.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Only remove the item if you did not give a lease.

Specified by:
update in interface java.util.Observer

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.