Rice Pastry API

rice.pastry
Class PastryNode

java.lang.Object
  |
  +--rice.pastry.PastryNode
All Implemented Interfaces:
MessageReceiver, Node
Direct Known Subclasses:
DirectPastryNode, DistPastryNode, MultiRingPastryNode

public abstract class PastryNode
extends java.lang.Object
implements MessageReceiver, Node

A Pastry node is single entity in the pastry network.

Version:
$Id: PastryNode.java,v 1.36 2003/09/24 02:20:40 amislove Exp $
Author:
Andrew Ladd

Field Summary
protected  java.util.Vector apps
           
protected  rice.pastry.NodeHandle localhandle
           
protected  rice.pastry.NodeId myNodeId
           
 
Constructor Summary
protected PastryNode(rice.pastry.NodeId id)
          Constructor, with NodeId.
 
Method Summary
 void addLeafSetObserver(java.util.Observer o)
          Add a leaf set observer to the Pastry node.
 void addRouteSetObserver(java.util.Observer o)
          Add a route set observer to the Pastry node.
 void deleteLeafSetObserver(java.util.Observer o)
          Delete a leaf set observer from the Pastry node.
 void deleteRouteSetObserver(java.util.Observer o)
          Delete a route set observer from the Pastry node.
 rice.p2p.commonapi.Id getId()
          Returns the Id of this node
 rice.p2p.commonapi.IdFactory getIdFactory()
          Returns a factory for Ids specific to this node's protocol.
 rice.pastry.leafset.LeafSet getLeafSet()
           
 rice.pastry.NodeHandle getLocalHandle()
           
 rice.pastry.messaging.MessageDispatch getMessageDispatch()
          FOR TESTING ONLY - DO NOT USE!
 rice.pastry.NodeId getNodeId()
           
 rice.pastry.routing.RoutingTable getRoutingTable()
           
abstract  void initiateJoin(rice.pastry.NodeHandle bootstrap)
          Overridden by derived classes to initiate the join process
 boolean isClosest(rice.pastry.NodeId key)
          Called by the layered Pastry application to check if the local pastry node is the one that is currently closest to the object key id.
 boolean isReady()
           
abstract  void nodeIsReady()
          Overridden by derived classes, and invoked when the node has joined successfully.
 void receiveMessage(rice.pastry.messaging.Message msg)
          message receiver interface.
 void registerApp(rice.pastry.client.PastryAppl app)
          Registers an application with this pastry node.
 rice.p2p.commonapi.Endpoint registerApplication(rice.p2p.commonapi.Application application, java.lang.String instance)
          This returns a VirtualizedNode specific to the given application and instance name to the application, which the application can then use in order to send an receive messages.
 void registerReceiver(rice.pastry.security.Credentials cred, rice.pastry.messaging.Address address, rice.pastry.messaging.MessageReceiver receiver)
          Registers a message receiver with this Pastry node.
abstract  rice.pastry.ScheduledMessage scheduleMsg(rice.pastry.messaging.Message msg, long delay)
          Schedule the specified message to be sent to the local node after a specified delay.
abstract  rice.pastry.ScheduledMessage scheduleMsg(rice.pastry.messaging.Message msg, long delay, long period)
          Schedule the specified message for repeated fixed-delay delivery to the local node, beginning after the specified delay.
abstract  rice.pastry.ScheduledMessage scheduleMsgAtFixedRate(rice.pastry.messaging.Message msg, long delay, long period)
          Schedule the specified message for repeated fixed-rate delivery to the local node, beginning after the specified delay.
 void setElements(rice.pastry.NodeHandle lh, rice.pastry.security.PastrySecurityManager sm, rice.pastry.messaging.MessageDispatch md, rice.pastry.leafset.LeafSet ls, rice.pastry.routing.RoutingTable rt)
          Combined accessor method for various members of PastryNode.
 void setMessageDispatch(rice.pastry.messaging.MessageDispatch md)
           
 void setReady()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myNodeId

protected rice.pastry.NodeId myNodeId

localhandle

protected rice.pastry.NodeHandle localhandle

apps

protected java.util.Vector apps
Constructor Detail

PastryNode

protected PastryNode(rice.pastry.NodeId id)
Constructor, with NodeId. Need to set the node's ID before this node is inserted as localHandle.localNode.

Method Detail

setElements

public void setElements(rice.pastry.NodeHandle lh,
                        rice.pastry.security.PastrySecurityManager sm,
                        rice.pastry.messaging.MessageDispatch md,
                        rice.pastry.leafset.LeafSet ls,
                        rice.pastry.routing.RoutingTable rt)
Combined accessor method for various members of PastryNode. These are generated by node factories, and assigned here. Other elements specific to the wire protocol are assigned via methods set{RMI,Direct}Elements in the respective derived classes.

Parameters:
lh - Node handle corresponding to this node.
sm - Security manager.
md - Message dispatcher.
ls - Leaf set.
rt - Routing table.

getLocalHandle

public rice.pastry.NodeHandle getLocalHandle()

getNodeId

public rice.pastry.NodeId getNodeId()

isReady

public boolean isReady()

getMessageDispatch

public rice.pastry.messaging.MessageDispatch getMessageDispatch()
FOR TESTING ONLY - DO NOT USE!


setMessageDispatch

public void setMessageDispatch(rice.pastry.messaging.MessageDispatch md)

nodeIsReady

public abstract void nodeIsReady()
Overridden by derived classes, and invoked when the node has joined successfully.


initiateJoin

public abstract void initiateJoin(rice.pastry.NodeHandle bootstrap)
Overridden by derived classes to initiate the join process

Parameters:
bootstrap - Node handle to bootstrap with.

setReady

public void setReady()

isClosest

public boolean isClosest(rice.pastry.NodeId key)
Called by the layered Pastry application to check if the local pastry node is the one that is currently closest to the object key id.

Parameters:
key - the object key id
Returns:
true if the local node is currently the closest to the key.

getLeafSet

public rice.pastry.leafset.LeafSet getLeafSet()

getRoutingTable

public rice.pastry.routing.RoutingTable getRoutingTable()

addLeafSetObserver

public void addLeafSetObserver(java.util.Observer o)
Add a leaf set observer to the Pastry node.

Parameters:
o - the observer.

deleteLeafSetObserver

public void deleteLeafSetObserver(java.util.Observer o)
Delete a leaf set observer from the Pastry node.

Parameters:
o - the observer.

addRouteSetObserver

public void addRouteSetObserver(java.util.Observer o)
Add a route set observer to the Pastry node.

Parameters:
o - the observer.

deleteRouteSetObserver

public void deleteRouteSetObserver(java.util.Observer o)
Delete a route set observer from the Pastry node.

Parameters:
o - the observer.

receiveMessage

public void receiveMessage(rice.pastry.messaging.Message msg)
message receiver interface. synchronized so that the external message processing thread and the leafset/route maintenance thread won't interfere with application messages.

Specified by:
receiveMessage in interface MessageReceiver
Parameters:
msg - the message.

registerReceiver

public void registerReceiver(rice.pastry.security.Credentials cred,
                             rice.pastry.messaging.Address address,
                             rice.pastry.messaging.MessageReceiver receiver)
Registers a message receiver with this Pastry node.

Parameters:
cred - the credentials.
address - the address that the receiver will be at.
receiver - the message receiver.

registerApp

public void registerApp(rice.pastry.client.PastryAppl app)
Registers an application with this pastry node.

Parameters:
app - the application

scheduleMsg

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

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 abstract rice.pastry.ScheduledMessage scheduleMsg(rice.pastry.messaging.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.

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 abstract rice.pastry.ScheduledMessage scheduleMsgAtFixedRate(rice.pastry.messaging.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.

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

toString

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

registerApplication

public rice.p2p.commonapi.Endpoint registerApplication(rice.p2p.commonapi.Application application,
                                                       java.lang.String instance)
This returns a VirtualizedNode specific to the given application and instance name to the application, which the application can then use in order to send an receive messages.

Specified by:
registerApplication in interface Node
Parameters:
application - The Application
instance - An identifier for a given instance
Returns:
The endpoint specific to this applicationk, which can be used for message sending/receiving.

getId

public rice.p2p.commonapi.Id getId()
Returns the Id of this node

Specified by:
getId in interface Node
Returns:
This node's Id

getIdFactory

public rice.p2p.commonapi.IdFactory getIdFactory()
Returns a factory for Ids specific to this node's protocol.

Specified by:
getIdFactory in interface Node
Returns:
A factory for creating Ids.

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection