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 3579 2007-02-07 11:49:09Z jeffh $
Author:
Alan Mislove

Nested Class Summary
static class PeriodicLeafSetProtocol.PLSPMessageDeserializer
           
 
Field Summary
 int BLS_THROTTLE
           
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 hasLease(NodeHandle nh)
          Do we have a lease from this node? Returns true if nh is null.
 boolean isReady()
           
 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)
           
 void receiveMessage(Message msg)
          Receives messages.
 void removeFromLeafsetIfPossible(NodeHandle nh)
           
 void setReady(boolean r)
           
 boolean shouldBeReady()
           
 void start()
          Called when it is time to take over as the renderstrategy.
 void stop()
           
 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

BLS_THROTTLE

public final int BLS_THROTTLE
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

stop

public void stop()
Specified by:
stop in interface ReadyStrategy

nodeSetUpdate

public void nodeSetUpdate(NodeSetEventSource nodeSetEventSource,
                          NodeHandle handle,
                          boolean added)
Specified by:
nodeSetUpdate in interface NodeSetListener

setReady

public void setReady(boolean r)
Specified by:
setReady in interface ReadyStrategy

isReady

public boolean isReady()
Specified by:
isReady in interface ReadyStrategy

shouldBeReady

public boolean shouldBeReady()

hasLease

public boolean hasLease(NodeHandle nh)
Do we have a lease from this node? Returns true if nh is null.

Parameters:
nh - the NodeHandle we are interested if we have a lease from
Returns:
if we have a lease from the NodeHandle

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

removeFromLeafsetIfPossible

public void removeFromLeafsetIfPossible(NodeHandle nh)

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection