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
      rice.pastry.PastryNode

All Implemented Interfaces:
  MessageReceiver, Node

Direct Known Subclasses:
  DirectPastryNode, DistPastryNode

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.42 2005/03/11 00:58:11 jeffh Exp $
Author:
  Andrew Ladd

Field Summary
`protected java.util.Vector` | `apps` DESCRIBE THE FIELD
`static java.lang.String` | `EC_NO_CODE_AVAILABLE` DESCRIBE THE FIELD
`protected NodeHandle` | `localhandle` DESCRIBE THE FIELD
`protected NodeId` | `myNodeId` DESCRIBE THE FIELD
`protected java.util.WeakHashMap` | `nodeHandleSet` This hash map helps us coalesce the nodeHandles so that there is only one reference of each maps NodeHandle -> WeakReference(NodeHandle)

Constructor Summary
`protected` | `PastryNode(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.
`java.lang.String` | `getErrorString(int errorCode)` Gets the ErrorString 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
`LocalNodeI` | `getLocalNodeI(LocalNodeI lni)` Gets the LocalNodeI attribute of the PastryNode object
`MessageDispatch` | `getMessageDispatch()` FOR TESTING ONLY - DO NOT USE!
`NodeId` | `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(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()` Gets the Ready attribute of the PastryNode object
`void` | `messageNotSent(Message m, int errorCode)` DESCRIBE THE METHOD
`abstract void` | `nodeIsReady()` Overridden by derived classes, and invoked when the node has joined successfully.
`void` | `receiveMessage(Message msg)` message receiver interface.
`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(Credentials cred, Address address, MessageReceiver receiver)` Registers a message receiver with this Pastry node.
`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.
`void` | `setElements(NodeHandle lh, PastrySecurityManager sm, 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
`java.lang.String` | `toString()` DESCRIBE THE METHOD

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### myNodeId

    protected NodeId myNodeId

  DESCRIBE THE FIELD

### localhandle

    protected NodeHandle localhandle

  DESCRIBE THE FIELD

### apps

    protected java.util.Vector apps

  DESCRIBE THE FIELD

### nodeHandleSet

    protected java.util.WeakHashMap nodeHandleSet

  This hash map helps us coalesce the nodeHandles so that there is only one reference of each maps NodeHandle -> WeakReference(NodeHandle)

### EC_NO_CODE_AVAILABLE

    public static java.lang.String EC_NO_CODE_AVAILABLE

  DESCRIBE THE FIELD

Constructor Detail

### PastryNode

    protected PastryNode(NodeId id)

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

Parameters:
  `id` - DESCRIBE THE PARAMETER

Method Detail

### getLocalNodeI

    public LocalNodeI getLocalNodeI(LocalNodeI lni)

  Gets the LocalNodeI attribute of the PastryNode object

  Parameters:
    `lni` - DESCRIBE THE PARAMETER
  Returns:
    The LocalNodeI value

### getLocalNodeHandle

    public NodeHandle getLocalNodeHandle()

  Gets the LocalNodeHandle attribute of the PastryNode object

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

### getLocalHandle

    public NodeHandle getLocalHandle()

  Gets the LocalHandle attribute of the PastryNode object

  Returns:
    The LocalHandle value

### getNodeId

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

### getErrorString

    public java.lang.String getErrorString(int errorCode)

  Gets the ErrorString attribute of the PastryNode object

  Parameters:
    `errorCode` - DESCRIBE THE PARAMETER
  Returns:
    The ErrorString value

### setElements

    public void setElements(NodeHandle lh,
                            PastrySecurityManager sm,
                            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.
    `sm` - Security manager.
    `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

### nodeIsReady

    public abstract void nodeIsReady()

  Overridden by derived classes, and invoked when the node has joined successfully.

### initiateJoin

    public abstract void initiateJoin(NodeHandle bootstrap)

  Overridden by derived classes to initiate the join process

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

### 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(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` - DESCRIBE THE PARAMETER

### registerReceiver

    public void registerReceiver(Credentials cred,
                                 Address address,
                                 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(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()

  DESCRIBE THE METHOD

  Returns:
    DESCRIBE THE RETURN VALUE

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

### messageNotSent

    public void messageNotSent(Message m,
                               int errorCode)

  DESCRIBE THE METHOD

  Parameters:
    `m` - DESCRIBE THE PARAMETER
    `errorCode` - DESCRIBE THE PARAMETER

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.