Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.pastry
Class PastryNode

    java.lang.Object
      java.util.Observable
          rice.pastry.PastryNode

All Implemented Interfaces:
  Destructable, Node, NodeHandleFactory

Direct Known Subclasses:
  DirectPastryNode, DistPastryNode

    public abstract class PastryNode

extends java.util.Observable
implements Destructable, Node, NodeHandleFactory

A Pastry node is single entity in the pastry network.

Version:
  $Id: PastryNode.java 3440 2006-10-30 18:27:55Z jeffh $
Author:
  Andrew Ladd

Field Summary
`protected java.util.Vector` | `apps` DESCRIBE THE FIELD
`protected boolean` | `joinFailed` DESCRIBE THE FIELD
`protected JoinFailedException` | `joinFailedReason` DESCRIBE THE FIELD
`protected LeafSet` | `leafSet` DESCRIBE THE FIELD
`protected NodeHandle` | `localhandle` DESCRIBE THE FIELD
`protected Logger` | `logger` DESCRIBE THE FIELD
`protected Id` | `myNodeId` DESCRIBE THE FIELD
`protected RoutingTable` | `routeSet` DESCRIBE THE FIELD

Constructor Summary
`protected` | `PastryNode(Id id, Environment e)` Constructor, with NodeId.

Method Summary
`Destructable` | `addDestructable(Destructable d)` Adds a feature to the Destructable attribute of the PastryNode object
`void` | `addLeafSetListener(NodeSetListener listener)` Adds the specified LeafSet listener to receive LeafSet events from this component.
`void` | `addLeafSetObserver(java.util.Observer o)` Deprecated. use addLeafSetListener
`void` | `addRouteSetListener(NodeSetListener listener)` Adds the specified RouteSet listener to receive RouteSet events from this component.
`void` | `addRouteSetObserver(java.util.Observer o)` Deprecated. use addRouteSetListener
`Endpoint` | `buildEndpoint(Application application, java.lang.String instance)` DESCRIBE THE METHOD
`abstract NodeHandle` | `coalesce(NodeHandle newHandle)` DESCRIBE THE METHOD
`abstract void` | `connect(NodeHandle handle, AppSocketReceiver receiver, PastryAppl appl, int timeout)` DESCRIBE THE METHOD
`void` | `deleteLeafSetListener(NodeSetListener listener)` DESCRIBE THE METHOD
`void` | `deleteLeafSetObserver(java.util.Observer o)` Deprecated. use deleteLeafSetListener
`void` | `deleteRouteSetObserver(java.util.Observer o)` Deprecated. use deleteRouteSetListener
`void` | `destroy()` Method which kills a PastryNode.
`Environment` | `getEnvironment()` Gets the Environment attribute of the PastryNode object
`Id` | `getId()` Returns the Id of this node
`IdFactory` | `getIdFactory()` Returns a factory for Ids specific to this node's protocol.
`LeafSet` | `getLeafSet()` Gets the LeafSet attribute of the PastryNode object
`NodeHandle` | `getLocalHandle()` Gets the LocalHandle attribute of the PastryNode object
`NodeHandle` | `getLocalNodeHandle()` Gets the LocalNodeHandle attribute of the PastryNode object
`MessageDispatch` | `getMessageDispatch()` FOR TESTING ONLY - DO NOT USE!
`Id` | `getNodeId()` Gets the NodeId attribute of the PastryNode object
`RoutingTable` | `getRoutingTable()` Gets the RoutingTable attribute of the PastryNode object
`abstract void` | `initiateJoin(NodeHandle[] bootstrap)` Overridden by derived classes to initiate the join process
`boolean` | `isClosest(Id 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()` Gets the Ready attribute of the PastryNode object
`boolean` | `joinFailed()` Returns true if there was a fatal error Joining
`void` | `joinFailed(JoinFailedException cje)` DESCRIBE THE METHOD
`JoinFailedException` | `joinFailedReason()` DESCRIBE THE METHOD
`abstract void` | `nodeIsReady()` Overridden by derived classes, and invoked when the node has joined successfully.
`void` | `nodeIsReady(boolean state)` Overridden by derived classes, and invoked when the node has joined successfully.
`void` | `notifyReadyObservers()` DESCRIBE THE METHOD
`void` | `process(Executable task, Continuation command)` Schedules a job for processing on the dedicated processing thread, should one exist.
`abstract int` | `proximity(NodeHandle nh)` DESCRIBE THE METHOD
`void` | `receiveMessage(Message msg)` message receiver interface.
`void` | `receiveMessage(RawMessageDelivery delivery)` DESCRIBE THE METHOD
`void` | `registerApp(PastryAppl app)` Registers an application with this pastry node.
`Endpoint` | `registerApplication(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(int address, PastryAppl receiver)` Registers a message receiver with this Pastry node.
`boolean` | `removeDestructable(Destructable d)` DESCRIBE THE METHOD
`void` | `removeRouteSetListener(NodeSetListener listener)` Removes the specified RouteSet listener so that it no longer receives RouteSet events from this component.
`abstract ScheduledMessage` | `scheduleMsg(Message msg, long delay)` Schedule the specified message to be sent to the local node after a specified delay.
`abstract 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.
`abstract 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.
`abstract void` | `send(NodeHandle handle, Message message)` DESCRIBE THE METHOD
`void` | `setElements(NodeHandle lh, MessageDispatch md, LeafSet ls, RoutingTable rt)` Combined accessor method for various members of PastryNode.
`void` | `setMessageDispatch(MessageDispatch md)` Sets the MessageDispatch attribute of the PastryNode object
`void` | `setReady()` Sets the Ready attribute of the PastryNode object
`void` | `setReady(boolean ready)` Sets the Ready attribute of the PastryNode object
`void` | `setReadyStrategy(ReadyStrategy rs)` Sets the ReadyStrategy attribute of the PastryNode object
`java.lang.String` | `toString()` Converts to a String representation of the object.

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`

Methods inherited from interface rice.pastry.NodeHandleFactory
`readNodeHandle`

Field Detail

### myNodeId

    protected Id myNodeId

  DESCRIBE THE FIELD

### leafSet

    protected LeafSet leafSet

  DESCRIBE THE FIELD

### routeSet

    protected RoutingTable routeSet

  DESCRIBE THE FIELD

### localhandle

    protected NodeHandle localhandle

  DESCRIBE THE FIELD

### apps

    protected java.util.Vector apps

  DESCRIBE THE FIELD

### logger

    protected Logger logger

  DESCRIBE THE FIELD

### joinFailed

    protected boolean joinFailed

  DESCRIBE THE FIELD

### joinFailedReason

    protected JoinFailedException joinFailedReason

  DESCRIBE THE FIELD

Constructor Detail

### PastryNode

    protected PastryNode(Id id,
                         Environment e)

  Constructor, with NodeId. Need to set the node's ID before this node is inserted as localHandle.localNode.

  Parameters:
    `id` - DESCRIBE THE PARAMETER
    `e` - DESCRIBE THE PARAMETER

Method Detail

### getLocalNodeHandle

    public NodeHandle getLocalNodeHandle()

  Gets the LocalNodeHandle attribute of the PastryNode object

  Specified by:
    `getLocalNodeHandle` in interface `Node`
  Returns:
    The LocalNodeHandle value

### getEnvironment

    public Environment getEnvironment()

  Gets the Environment attribute of the PastryNode object

  Specified by:
    `getEnvironment` in interface `Node`
  Returns:
    The Environment value

### getLocalHandle

    public NodeHandle getLocalHandle()

  Gets the LocalHandle attribute of the PastryNode object

  Returns:
    The LocalHandle value

### getNodeId

    public Id getNodeId()

  Gets the NodeId attribute of the PastryNode object

  Returns:
    The NodeId value

### isReady

    public boolean isReady()

  Gets the Ready attribute of the PastryNode object

  Returns:
    The Ready value

### getMessageDispatch

    public MessageDispatch getMessageDispatch()

  FOR TESTING ONLY - DO NOT USE!

  Returns:
    The MessageDispatch value

### isClosest

    public boolean isClosest(Id 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 LeafSet getLeafSet()

  Gets the LeafSet attribute of the PastryNode object

  Returns:
    The LeafSet value

### getRoutingTable

    public RoutingTable getRoutingTable()

  Gets the RoutingTable attribute of the PastryNode object

  Returns:
    The RoutingTable value

### getId

    public Id getId()

  Returns the Id of this node

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

### getIdFactory

    public 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.

### setReadyStrategy

    public void setReadyStrategy(ReadyStrategy rs)

  Sets the ReadyStrategy attribute of the PastryNode object

  Parameters:
    `rs` - The new ReadyStrategy value

### setElements

    public void setElements(NodeHandle lh,
                            MessageDispatch md,
                            LeafSet ls,
                            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.
    `md` - Message dispatcher.
    `ls` - Leaf set.
    `rt` - Routing table.

### setMessageDispatch

    public void setMessageDispatch(MessageDispatch md)

  Sets the MessageDispatch attribute of the PastryNode object

  Parameters:
    `md` - The new MessageDispatch value

### setReady

    public void setReady()

  Sets the Ready attribute of the PastryNode object

### setReady

    public void setReady(boolean ready)

  Sets the Ready attribute of the PastryNode object

  Parameters:
    `ready` - The new Ready value

### coalesce

    public abstract NodeHandle coalesce(NodeHandle newHandle)

  DESCRIBE THE METHOD

  Parameters:
    `newHandle` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE

### addDestructable

    public Destructable addDestructable(Destructable d)

  Adds a feature to the Destructable attribute of the PastryNode object

  Parameters:
    `d` - The feature to be added to the Destructable attribute
  Returns:
    DESCRIBE THE RETURN VALUE

### removeDestructable

    public boolean removeDestructable(Destructable d)

  DESCRIBE THE METHOD

  Parameters:
    `d` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE

### nodeIsReady

    public abstract void nodeIsReady()

  Overridden by derived classes, and invoked when the node has joined successfully. This one is for backwards compatability. It will soon be deprecated.

### nodeIsReady

    public void nodeIsReady(boolean state)

  Overridden by derived classes, and invoked when the node has joined successfully. This should probably be abstract, but maybe in a later version.

  Parameters:
    `state` - true when the node is ready, false when not

### initiateJoin

    public abstract void initiateJoin(NodeHandle[] bootstrap)

  Overridden by derived classes to initiate the join process

  Parameters:
    `bootstrap` - Node handle to bootstrap with.

### notifyReadyObservers

    public void notifyReadyObservers()

  DESCRIBE THE METHOD

### addLeafSetObserver

    public void addLeafSetObserver(java.util.Observer o)

  Deprecated. use addLeafSetListener

  Add a leaf set observer to the Pastry node.

  Parameters:
    `o` - the observer.

### deleteLeafSetObserver

    public void deleteLeafSetObserver(java.util.Observer o)

  Deprecated. use deleteLeafSetListener

  Delete a leaf set observer from the Pastry node.

  Parameters:
    `o` - the observer.

### addLeafSetListener

    public void addLeafSetListener(NodeSetListener listener)

  Adds the specified LeafSet listener to receive LeafSet events from this component. If listener l is null, no exception is thrown and no action is performed.

  Parameters:
    `listener` - Contains the LeafSetListener for LeafSetEvent data.

### deleteLeafSetListener

    public void deleteLeafSetListener(NodeSetListener listener)

  DESCRIBE THE METHOD

  Parameters:
    `listener` - DESCRIBE THE PARAMETER

### addRouteSetObserver

    public void addRouteSetObserver(java.util.Observer o)

  Deprecated. use addRouteSetListener

  Add a route set observer to the Pastry node.

  Parameters:
    `o` - the observer.

### deleteRouteSetObserver

    public void deleteRouteSetObserver(java.util.Observer o)

  Deprecated. use deleteRouteSetListener

  Delete a route set observer from the Pastry node.

  Parameters:
    `o` - the observer.

### addRouteSetListener

    public void addRouteSetListener(NodeSetListener listener)

  Adds the specified RouteSet listener to receive RouteSet events from this component. If listener l is null, no exception is thrown and no action is performed.

  Parameters:
    `listener` - Contains the RouteSetListener for RouteSetEvent data.

### removeRouteSetListener

    public void removeRouteSetListener(NodeSetListener listener)

  Removes the specified RouteSet listener so that it no longer receives RouteSet events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listener l is null, no exception is thrown and no action is performed.

  Parameters:
    `listener` - Contains the RouteSetListener for RouteSetEvent data.

### receiveMessage

    public void receiveMessage(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.

  Parameters:
    `msg` - DESCRIBE THE PARAMETER

### receiveMessage

    public void receiveMessage(RawMessageDelivery delivery)

  DESCRIBE THE METHOD

  Parameters:
    `delivery` - DESCRIBE THE PARAMETER

### registerReceiver

    public void registerReceiver(int address,
                                 PastryAppl receiver)

  Registers a message receiver with this Pastry node.

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

### registerApp

    public void registerApp(PastryAppl app)

  Registers an application with this pastry node.

  Parameters:
    `app` - the application

### scheduleMsg

    public abstract 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.

  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 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.

  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 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.

  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()

  Converts to a String representation of the object.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    A string representation of the object.

### registerApplication

    public Endpoint registerApplication(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.

### buildEndpoint

    public Endpoint buildEndpoint(Application application,
                                  java.lang.String instance)

  DESCRIBE THE METHOD

  Specified by:
    `buildEndpoint` in interface `Node`
  Parameters:
    `application` - DESCRIBE THE PARAMETER
    `instance` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE

### process

    public void process(Executable task,
                        Continuation command)

  Schedules a job for processing on the dedicated processing thread, should one exist. CPU intensive jobs, such as encryption, erasure encoding, or bloom filter creation should never be done in the context of the underlying node's thread, and should only be done via this method.

  Parameters:
    `task` - The task to run on the processing thread
    `command` - The command to return the result to once it's done

### destroy

    public void destroy()

  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`

### send

    public abstract void send(NodeHandle handle,
                              Message message)

  DESCRIBE THE METHOD

  Parameters:
    `handle` - DESCRIBE THE PARAMETER
    `message` - DESCRIBE THE PARAMETER

### connect

    public abstract void connect(NodeHandle handle,
                                 AppSocketReceiver receiver,
                                 PastryAppl appl,
                                 int timeout)

  DESCRIBE THE METHOD

  Parameters:
    `handle` - DESCRIBE THE PARAMETER
    `receiver` - DESCRIBE THE PARAMETER
    `appl` - DESCRIBE THE PARAMETER
    `timeout` - DESCRIBE THE PARAMETER

### proximity

    public abstract int proximity(NodeHandle nh)

  DESCRIBE THE METHOD

  Parameters:
    `nh` - DESCRIBE THE PARAMETER
  Returns:
    DESCRIBE THE RETURN VALUE

### joinFailed

    public void joinFailed(JoinFailedException cje)

  DESCRIBE THE METHOD

  Parameters:
    `cje` - DESCRIBE THE PARAMETER

### joinFailed

    public boolean joinFailed()

  Returns true if there was a fatal error Joining

  Returns:

### joinFailedReason

    public JoinFailedException joinFailedReason()

  DESCRIBE THE METHOD

  Returns:
    DESCRIBE THE RETURN VALUE

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.