Rice Pastry API

rice.pastry.transport
Class TLPastryNode

java.lang.Object
  extended by java.util.Observable
      extended by rice.pastry.PastryNode
          extended by rice.pastry.transport.TLPastryNode
All Implemented Interfaces:
LivenessListener<NodeHandle>, LivenessProvider<NodeHandle>, ProximityListener<NodeHandle>, ProximityProvider<NodeHandle>, TransportLayerCallback<NodeHandle,RawMessage>, Destructable, Node, NodeHandleFactory

public class TLPastryNode
extends PastryNode
implements TransportLayerCallback<NodeHandle,RawMessage>, LivenessListener<NodeHandle>, ProximityListener<NodeHandle>


Field Summary
static byte CONNECTION_NO_ACCEPTOR
           
static byte CONNECTION_NO_APP
           
static byte CONNECTION_OK
           
static byte CONNECTION_UNKNOWN
           
static byte CONNECTION_UNKNOWN_ERROR
           
protected  ScheduledMessage joinEvent
           
protected  int leafSetMaintFreq
           
protected  ScheduledMessage leafSetRoutineMaintenance
           
protected  LivenessProvider<NodeHandle> livenessProvider
           
protected  int routeSetMaintFreq
           
protected  ScheduledMessage routeSetRoutineMaintenance
           
 
Fields inherited from class rice.pastry.PastryNode
apps, isDestroyed, joinFailed, joinFailedReason, leafSet, localhandle, logger, myNodeId, router, routeSet
 
Fields inherited from interface org.mpisws.p2p.transport.liveness.LivenessListener
LIVENESS_ALIVE, LIVENESS_DEAD, LIVENESS_DEAD_FOREVER, LIVENESS_SUSPECTED
 
Fields inherited from interface org.mpisws.p2p.transport.proximity.ProximityProvider
DEFAULT_PROXIMITY
 
Constructor Summary
TLPastryNode(Id id, Environment e)
           
 
Method Summary
protected  void acceptAppSocket(int appId)
           
 void addLivenessListener(LivenessListener<NodeHandle> name)
           
 void addProximityListener(ProximityListener<NodeHandle> listener)
           
 boolean checkLiveness(NodeHandle i, java.util.Map<java.lang.String,java.lang.Integer> options)
          Returns wether a new notification will occur.
 void clearState(NodeHandle i)
          Force layer to clear the existing state related to the Identifier.
 NodeHandle coalesce(NodeHandle newHandle)
          Needed for legacy java deserialization of NodeHanlde because we aren't given any other way to do this properly such as a protected constructor.
 SocketRequestHandle connect(NodeHandle i2, AppSocketReceiver deliverSocketToMe, PastryAppl appl, int timeout)
          Called by PastryAppl to ask the transport layer to open a Socket to its counterpart on another node.
 void destroy()
          Method which kills a PastryNode.
 void doneNode(java.util.Collection<NodeHandle> bootstrap)
          Called after the node is initialized.
 void doneNode(NodeHandle[] bootstrap)
           
 Bootstrapper getBootstrapper()
           
 int getLiveness(NodeHandle i, java.util.Map<java.lang.String,java.lang.Integer> options)
           
 LivenessProvider<NodeHandle> getLivenessProvider()
           
 ProximityProvider<NodeHandle> getProxProvider()
           
 TransportLayer<NodeHandle,RawMessage> getTL()
           
 void incomingSocket(P2PSocket<NodeHandle> s)
          Notification of a new socket.
 void initiateJoin(NodeHandle[] bootstrap)
          Overridden by derived classes to initiate the join process
 void livenessChanged(NodeHandle i, int val, java.util.Map<java.lang.String,java.lang.Integer> options)
          Called when the liveness changes.
 void messageReceived(NodeHandle i, RawMessage m, java.util.Map<java.lang.String,java.lang.Integer> options)
          Called when a new message is received.
 void nodeIsReady()
          Overridden by derived classes, and invoked when the node has joined successfully.
protected  void notifyLivenessListeners(NodeHandle i, int val, java.util.Map<java.lang.String,java.lang.Integer> options)
           
 int proximity(NodeHandle nh)
          The proximity of the node handle.
 void proximityChanged(NodeHandle i, int val, java.util.Map<java.lang.String,java.lang.Integer> options)
           
 NodeHandle readNodeHandle(InputBuffer buf)
           
 void registerReceiver(int address, PastryAppl receiver)
          Registers a message receiver with this Pastry node.
 boolean removeLivenessListener(LivenessListener<NodeHandle> name)
           
 boolean removeProximityListener(ProximityListener<NodeHandle> listener)
           
 ScheduledMessage scheduleMsg(Message msg, long delay)
          Schedule the specified message to be sent to the local node after a specified delay.
 ScheduledMessage scheduleMsg(Message msg, long delay, long period)
          Schedule the specified message for repeated fixed-delay delivery to the local node, beginning after the specified delay.
 ScheduledMessage scheduleMsgAtFixedRate(Message msg, long delay, long period)
          Schedule the specified message for repeated fixed-rate delivery to the local node, beginning after the specified delay.
 ExponentialBackoffScheduledMessage scheduleMsgExpBackoff(Message msg, long delay, long initialPeriod, double expBase)
           
 PMessageReceipt send(NodeHandle handle, Message msg, PMessageNotification deliverAckToMe, java.util.Map<java.lang.String,java.lang.Integer> tempOptions)
          Deliver message to the NodeHandle.
 void setSocketElements(NodeHandle localhandle, int lsmf, int rsmf, TransportLayer<NodeHandle,RawMessage> tl, LivenessProvider<NodeHandle> livenessProvider, ProximityProvider<NodeHandle> proxProvider, Deserializer deserializer, NodeHandleFactory handleFactory, Bootstrapper boot)
           
 java.lang.String toString()
           
 
Methods inherited from class rice.pastry.PastryNode
addDestructable, addLeafSetListener, addLeafSetObserver, addNetworkListener, addRouteSetListener, addRouteSetObserver, buildEndpoint, deleteLeafSetListener, deleteLeafSetObserver, deleteRouteSetObserver, getDefaultReadyStrategy, getEnvironment, getId, getIdFactory, getLeafSet, getLocalHandle, getLocalNodeHandle, getMessageDispatch, getNodeId, getRouter, getRoutingTable, isClosest, isReady, joinFailed, joinFailed, joinFailedReason, nodeIsReady, notifyReadyObservers, process, receiveMessage, receiveMessage, registerApp, registerApplication, removeDestructable, removeRouteSetListener, setElements, setMessageDispatch, setReady, setReady, setReadyStrategy
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONNECTION_UNKNOWN_ERROR

public static final byte CONNECTION_UNKNOWN_ERROR
See Also:
Constant Field Values

CONNECTION_UNKNOWN

public static final byte CONNECTION_UNKNOWN
See Also:
Constant Field Values

CONNECTION_OK

public static final byte CONNECTION_OK
See Also:
Constant Field Values

CONNECTION_NO_APP

public static final byte CONNECTION_NO_APP
See Also:
Constant Field Values

CONNECTION_NO_ACCEPTOR

public static final byte CONNECTION_NO_ACCEPTOR
See Also:
Constant Field Values

joinEvent

protected ScheduledMessage joinEvent

leafSetMaintFreq

protected int leafSetMaintFreq

routeSetMaintFreq

protected int routeSetMaintFreq

leafSetRoutineMaintenance

protected ScheduledMessage leafSetRoutineMaintenance

routeSetRoutineMaintenance

protected ScheduledMessage routeSetRoutineMaintenance

livenessProvider

protected LivenessProvider<NodeHandle> livenessProvider
Constructor Detail

TLPastryNode

public TLPastryNode(Id id,
                    Environment e)
Method Detail

registerReceiver

public void registerReceiver(int address,
                             PastryAppl receiver)
Description copied from class: PastryNode
Registers a message receiver with this Pastry node.

Overrides:
registerReceiver in class PastryNode
Parameters:
address - the address that the receiver will be at.
receiver - the message receiver.

coalesce

public NodeHandle coalesce(NodeHandle newHandle)
Description copied from interface: NodeHandleFactory
Needed for legacy java deserialization of NodeHanlde because we aren't given any other way to do this properly such as a protected constructor.

Specified by:
coalesce in interface NodeHandleFactory
Specified by:
coalesce in class PastryNode
Returns:

connect

public SocketRequestHandle connect(NodeHandle i2,
                                   AppSocketReceiver deliverSocketToMe,
                                   PastryAppl appl,
                                   int timeout)
Description copied from class: PastryNode
Called by PastryAppl to ask the transport layer to open a Socket to its counterpart on another node.

Specified by:
connect in class PastryNode

incomingSocket

public void incomingSocket(P2PSocket<NodeHandle> s)
                    throws java.io.IOException
Description copied from interface: TransportLayerCallback
Notification of a new socket.

Specified by:
incomingSocket in interface TransportLayerCallback<NodeHandle,RawMessage>
Parameters:
s - the incoming socket
Throws:
java.io.IOException

acceptAppSocket

protected void acceptAppSocket(int appId)
                        throws AppSocketException
Throws:
AppSocketException

scheduleMsgExpBackoff

public ExponentialBackoffScheduledMessage scheduleMsgExpBackoff(Message msg,
                                                                long delay,
                                                                long initialPeriod,
                                                                double expBase)

initiateJoin

public void initiateJoin(NodeHandle[] bootstrap)
Description copied from class: PastryNode
Overridden by derived classes to initiate the join process

Specified by:
initiateJoin in class PastryNode
Parameters:
bootstrap - Node handle to bootstrap with.

nodeIsReady

public void nodeIsReady()
Description copied from class: PastryNode
Overridden by derived classes, and invoked when the node has joined successfully. This one is for backwards compatability. It will soon be deprecated.

Specified by:
nodeIsReady in class PastryNode

proximity

public int proximity(NodeHandle nh)
Description copied from class: PastryNode
The proximity of the node handle.

Specified by:
proximity in interface ProximityProvider<NodeHandle>
Specified by:
proximity in class PastryNode

scheduleMsg

public ScheduledMessage scheduleMsg(Message msg,
                                    long delay)
Schedule the specified message to be sent to the local node after a specified delay. Useful to provide timeouts.

Specified by:
scheduleMsg in class PastryNode
Parameters:
msg - a message that will be delivered to the local node after the specified delay
delay - time in milliseconds before message is to be delivered
Returns:
the scheduled event object; can be used to cancel the message

scheduleMsg

public ScheduledMessage scheduleMsg(Message msg,
                                    long delay,
                                    long period)
Schedule the specified message for repeated fixed-delay delivery to the local node, beginning after the specified delay. Subsequent executions take place at approximately regular intervals separated by the specified period. Useful to initiate periodic tasks.

Specified by:
scheduleMsg in class PastryNode
Parameters:
msg - a message that will be delivered to the local node after the specified delay
delay - time in milliseconds before message is to be delivered
period - time in milliseconds between successive message deliveries
Returns:
the scheduled event object; can be used to cancel the message

scheduleMsgAtFixedRate

public ScheduledMessage scheduleMsgAtFixedRate(Message msg,
                                               long delay,
                                               long period)
Schedule the specified message for repeated fixed-rate delivery to the local node, beginning after the specified delay. Subsequent executions take place at approximately regular intervals, separated by the specified period.

Specified by:
scheduleMsgAtFixedRate in class PastryNode
Parameters:
msg - a message that will be delivered to the local node after the specified delay
delay - time in milliseconds before message is to be delivered
period - time in milliseconds between successive message deliveries
Returns:
the scheduled event object; can be used to cancel the message

send

public PMessageReceipt send(NodeHandle handle,
                            Message msg,
                            PMessageNotification deliverAckToMe,
                            java.util.Map<java.lang.String,java.lang.Integer> tempOptions)
Description copied from class: PastryNode
Deliver message to the NodeHandle.

Specified by:
send in class PastryNode
Returns:

messageReceived

public void messageReceived(NodeHandle i,
                            RawMessage m,
                            java.util.Map<java.lang.String,java.lang.Integer> options)
                     throws java.io.IOException
Description copied from interface: TransportLayerCallback
Called when a new message is received.

Specified by:
messageReceived in interface TransportLayerCallback<NodeHandle,RawMessage>
Parameters:
i - The node it is coming from
m - the message
options - describe how the message arrived (udp/tcp, encrypted etc)
Throws:
java.io.IOException - if there is a problem decoding the message

readNodeHandle

public NodeHandle readNodeHandle(InputBuffer buf)
                          throws java.io.IOException
Specified by:
readNodeHandle in interface NodeHandleFactory
Throws:
java.io.IOException

getBootstrapper

public Bootstrapper getBootstrapper()
Specified by:
getBootstrapper in class PastryNode

setSocketElements

public void setSocketElements(NodeHandle localhandle,
                              int lsmf,
                              int rsmf,
                              TransportLayer<NodeHandle,RawMessage> tl,
                              LivenessProvider<NodeHandle> livenessProvider,
                              ProximityProvider<NodeHandle> proxProvider,
                              Deserializer deserializer,
                              NodeHandleFactory handleFactory,
                              Bootstrapper boot)

doneNode

public void doneNode(java.util.Collection<NodeHandle> bootstrap)
Called after the node is initialized.

Parameters:
bootstrap - The node which this node should boot off of.

doneNode

public void doneNode(NodeHandle[] bootstrap)

toString

public java.lang.String toString()
Overrides:
toString in class PastryNode

destroy

public void destroy()
Description copied from class: PastryNode
Method which kills a PastryNode. Note, this doesn't implicitly kill the environment. Make sure to call super.destroy() !!!

Specified by:
destroy in interface Destructable
Overrides:
destroy in class PastryNode

livenessChanged

public void livenessChanged(NodeHandle i,
                            int val,
                            java.util.Map<java.lang.String,java.lang.Integer> options)
Description copied from interface: LivenessListener
Called when the liveness changes.

Specified by:
livenessChanged in interface LivenessListener<NodeHandle>

addLivenessListener

public void addLivenessListener(LivenessListener<NodeHandle> name)
Specified by:
addLivenessListener in interface LivenessProvider<NodeHandle>

removeLivenessListener

public boolean removeLivenessListener(LivenessListener<NodeHandle> name)
Specified by:
removeLivenessListener in interface LivenessProvider<NodeHandle>

notifyLivenessListeners

protected void notifyLivenessListeners(NodeHandle i,
                                       int val,
                                       java.util.Map<java.lang.String,java.lang.Integer> options)

checkLiveness

public boolean checkLiveness(NodeHandle i,
                             java.util.Map<java.lang.String,java.lang.Integer> options)
Description copied from interface: LivenessProvider
Returns wether a new notification will occur. Will return false if a liveness check has recently completed. Will return true if a new liveness check starts, or an existing one is in progress.

Specified by:
checkLiveness in interface LivenessProvider<NodeHandle>
Parameters:
i - the node to check
Returns:
true if there will be an update (either a ping, or a change in liveness) false if there won't be an update due to bandwidth concernts

getLiveness

public int getLiveness(NodeHandle i,
                       java.util.Map<java.lang.String,java.lang.Integer> options)
Specified by:
getLiveness in interface LivenessProvider<NodeHandle>

proximityChanged

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

getLivenessProvider

public LivenessProvider<NodeHandle> getLivenessProvider()

getProxProvider

public ProximityProvider<NodeHandle> getProxProvider()

getTL

public TransportLayer<NodeHandle,RawMessage> getTL()

clearState

public void clearState(NodeHandle i)
Description copied from interface: LivenessProvider
Force layer to clear the existing state related to the Identifier. Usually if there is reason to believe a node has returned.

Specified by:
clearState in interface LivenessProvider<NodeHandle>

addProximityListener

public void addProximityListener(ProximityListener<NodeHandle> listener)
Specified by:
addProximityListener in interface ProximityProvider<NodeHandle>

removeProximityListener

public boolean removeProximityListener(ProximityListener<NodeHandle> listener)
Specified by:
removeProximityListener in interface ProximityProvider<NodeHandle>

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection