Rice Pastry API

rice.pastry.socket
Class SocketPastryNode

java.lang.Object
  extended by java.util.Observable
      extended by rice.pastry.PastryNode
          extended by rice.pastry.dist.DistPastryNode
              extended by rice.pastry.socket.SocketPastryNode
All Implemented Interfaces:
LivenessProvider<NodeHandle>, Destructable, Node, NodeHandleFactory

public class SocketPastryNode
extends DistPastryNode

An Socket-based Pastry node, which has two threads - one thread for performing route set and leaf set maintainance, and another thread for listening on the sockets and performing all non-blocking I/O.

Version:
$Id: SocketPastryNode.java 3777 2007-07-12 12:00:17Z jeffh $
Author:
Alan Mislove

Field Summary
 
Fields inherited from class rice.pastry.dist.DistPastryNode
leafSetMaintFreq, leafSetRoutineMaintenance, routeSetMaintFreq, routeSetRoutineMaintenance, timer
 
Fields inherited from class rice.pastry.PastryNode
apps, isDestroyed, joinFailed, joinFailedReason, leafSet, localhandle, logger, myNodeId, router, routeSet
 
Constructor Summary
protected SocketPastryNode(Id id, Environment e)
          Constructor
 
Method Summary
 void acceptAppSocket(SocketAppSocket socket, int appId)
           
 void addLivenessListener(LivenessListener<NodeHandle> name)
           
 boolean checkLiveness(NodeHandle i, java.util.Map<java.lang.String,java.lang.Integer> options)
          Returns wether a new notification will occur.
 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 handle, AppSocketReceiver receiver, PastryAppl appl, int timeout)
          Called by PastryAppl to ask the transport layer to open a Socket to its counterpart on another node.
 void destroy()
          Makes this node resign from the network.
 void doneNode(NodeHandle[] bootstrap)
          Called after the node is initialized.
 Bootstrapper getBootstrapper()
           
 int getLiveness(NodeHandle i, java.util.Map<java.lang.String,java.lang.Integer> options)
           
 SocketSourceRouteManager getSocketSourceRouteManager()
          Returns the SocketSourceRouteManager for this pastry node.
 int proximity(NodeHandle nh)
          The proximity of the node handle.
 NodeHandle readNodeHandle(InputBuffer buf)
           
 boolean removeLivenessListener(LivenessListener<NodeHandle> name)
           
 PMessageReceipt send(NodeHandle handle, Message message, PMessageNotification deliverActToMe, java.util.Map<java.lang.String,java.lang.Integer> options)
          Deliver message to the NodeHandle.
 void setSocketElements(EpochInetSocketAddress address, int lsmf, int rsmf)
          Helper method which allows the WirePastryNodeFactory to initialize a number of the pastry node's elements.
 void setSocketSourceRouteManager(SocketSourceRouteManager srManager)
           
 void testFireWall(NodeHandle bootstrap, Continuation c, int timeout)
           
 void testFireWall(NodeHandle bootstrap, Continuation c, int timeout, int tries)
          Try multiple times...
 java.lang.String toString()
          Prints out a String representation of this node
 
Methods inherited from class rice.pastry.dist.DistPastryNode
addNetworkListener, broadcastChannelClosed, broadcastChannelOpened, broadcastReceivedListeners, broadcastSentListeners, getNetworkListeners, getTimer, initiateJoin, nodeIsReady, process, scheduleMsg, scheduleMsg, scheduleMsgAtFixedRate, scheduleMsgExpBackoff
 
Methods inherited from class rice.pastry.PastryNode
addDestructable, addLeafSetListener, addLeafSetObserver, addRouteSetListener, addRouteSetObserver, buildEndpoint, deleteLeafSetListener, deleteLeafSetObserver, deleteRouteSetObserver, getDefaultReadyStrategy, getEnvironment, getId, getIdFactory, getLeafSet, getLocalHandle, getLocalNodeHandle, getMessageDispatch, getNodeId, getRouter, getRoutingTable, isClosest, isReady, joinFailed, joinFailed, joinFailedReason, nodeIsReady, notifyReadyObservers, receiveMessage, receiveMessage, registerApp, registerApplication, registerReceiver, 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
 

Constructor Detail

SocketPastryNode

protected SocketPastryNode(Id id,
                           Environment e)
Constructor

Parameters:
id - The NodeId of this Pastry node.
Method Detail

getSocketSourceRouteManager

public SocketSourceRouteManager getSocketSourceRouteManager()
Returns the SocketSourceRouteManager for this pastry node.

Returns:
The SocketSourceRouteManager for this pastry node.

setSocketElements

public void setSocketElements(EpochInetSocketAddress address,
                              int lsmf,
                              int rsmf)
Helper method which allows the WirePastryNodeFactory to initialize a number of the pastry node's elements.

Parameters:
address - The address of this pastry node.
manager - The socket manager for this pastry node.
lsmf - Leaf set maintenance frequency. 0 means never.
rsmf - Route set maintenance frequency. 0 means never.
sManager - The new SocketElements value
pingManager - The new SocketElements value
pool - The new SocketElements value

doneNode

public void doneNode(NodeHandle[] bootstrap)
Called after the node is initialized.

Overrides:
doneNode in class DistPastryNode
Parameters:
bootstrap - The node which this node should boot off of.

toString

public java.lang.String toString()
Prints out a String representation of this node

Overrides:
toString in class PastryNode
Returns:
a String

destroy

public void destroy()
Makes this node resign from the network. Is designed to be used for debugging and testing. If run on the SelectorThread, then destroys now. Other threads cause a task to be placed on the selector, and destroyed asap. Make sure to call super.destroy() !!!

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

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:

setSocketSourceRouteManager

public void setSocketSourceRouteManager(SocketSourceRouteManager srManager)

send

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

Specified by:
send in class PastryNode
Returns:

testFireWall

public void testFireWall(NodeHandle bootstrap,
                         Continuation c,
                         int timeout,
                         int tries)
Try multiple times... it turned out that trying only once was failing often.

Parameters:
bootstrap -
c -
timeout -
tries -

testFireWall

public void testFireWall(NodeHandle bootstrap,
                         Continuation c,
                         int timeout)

connect

public SocketRequestHandle connect(NodeHandle handle,
                                   AppSocketReceiver receiver,
                                   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

acceptAppSocket

public void acceptAppSocket(SocketAppSocket socket,
                            int appId)
                     throws AppSocketException
Throws:
AppSocketException

readNodeHandle

public NodeHandle readNodeHandle(InputBuffer buf)
                          throws java.io.IOException
Throws:
java.io.IOException

proximity

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

Specified by:
proximity in class PastryNode
Returns:

getBootstrapper

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

addLivenessListener

public void addLivenessListener(LivenessListener<NodeHandle> name)

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.

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)

removeLivenessListener

public boolean removeLivenessListener(LivenessListener<NodeHandle> name)

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection