ePOST API

rice.p2p.multiring
Class MultiringNode

java.lang.Object
  extended by rice.p2p.multiring.MultiringNode
All Implemented Interfaces:
Node, ScribeClient

public class MultiringNode
extends java.lang.Object
implements Node, ScribeClient

Version:
$Id: MultiringNode.java 2808 2005-11-22 14:38:49Z jeffh $
Author:
Alan Mislove

Field Summary
protected  MultiringNodeCollection collection
          The collection, which keeps track of the other nodes on the ring node
protected  java.util.Hashtable endpoints
          The list of all of the endpoints connected to this node
protected  Environment environment
          The environment
protected  MultiringIdFactory factory
          A cached IdFactory for internal use
protected  Logger logger
           
protected  Node node
          The node which this mulitring node is wrapping
protected  Id ringId
          The Id which represents the current ring this node is a member of
protected  Scribe scribe
          The Scribe application which the node uses to do routing
 
Constructor Summary
MultiringNode(Id ringId, Node node)
          Constructor
MultiringNode(Id ringId, Node node, MultiringNode existing)
          Constructor
 
Method Summary
 boolean anycast(Topic topic, ScribeContent content)
          This method is invoked when an anycast is received for a topic which this client is interested in.
 void childAdded(Topic topic, NodeHandle child)
          Informs this client that a child was added to a topic in which it was interested in.
 void childRemoved(Topic topic, NodeHandle child)
          Informs this client that a child was removed from a topic in which it was interested in.
 void deliver(Topic topic, ScribeContent content)
          This method is invoked when a message is delivered for a topic this client is interested in.
 MultiringNodeCollection getCollection()
          Returns the collection this node is a member of
 Environment getEnvironment()
          Getter for the environment.
 Id getId()
          Returns the Id of this node
 IdFactory getIdFactory()
          Returns a factory for Ids specific to this node's protocol.
 NodeHandle getLocalNodeHandle()
          Returns a handle to the local node.
 Node getNode()
          Returns this mutliring node's internal node
 Id getNodeId()
          Returns the underlying id of this node
 Id getRingId()
          Returns the ringId of this node
protected  void nodeAdded(Id otherRingId)
          Method which is used to inform the node that another node has been added to the collection.
 Endpoint registerApplication(Application application, int port)
          This returns a Endpoint specific to the given application and instance name to the application, which the application can then use in order to send an receive messages.
 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 subscribeFailed(Topic topic)
          Informs the client that a subscribe on the given topic failed - the client should retry the subscribe or take appropriate action.
 java.lang.String toString()
          Prints out the string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node

protected Node node
The node which this mulitring node is wrapping


ringId

protected Id ringId
The Id which represents the current ring this node is a member of


scribe

protected Scribe scribe
The Scribe application which the node uses to do routing


collection

protected MultiringNodeCollection collection
The collection, which keeps track of the other nodes on the ring node


endpoints

protected java.util.Hashtable endpoints
The list of all of the endpoints connected to this node


factory

protected MultiringIdFactory factory
A cached IdFactory for internal use


environment

protected Environment environment
The environment


logger

protected Logger logger
Constructor Detail

MultiringNode

public MultiringNode(Id ringId,
                     Node node)
Constructor

Parameters:
node - The node which this multiring node is wrapping
ringId - The Id of this node's ring

MultiringNode

public MultiringNode(Id ringId,
                     Node node,
                     MultiringNode existing)
Constructor

Parameters:
node - The node which this multiring node is wrapping
ringId - The Id of this node's ring
existing - An existing node which this node should pair with
Method Detail

getLocalNodeHandle

public NodeHandle getLocalNodeHandle()
Description copied from interface: Node
Returns a handle to the local node. This node handle is serializable, and can therefore be sent to other nodes in the network and still be valid.

Specified by:
getLocalNodeHandle in interface Node
Returns:
A NodeHandle referring to the local node.

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.

registerApplication

public Endpoint registerApplication(Application application,
                                    int port)
This returns a Endpoint specific to the given application and instance name to the application, which the application can then use in order to send an receive messages. This method allows advanced developers to specify which "port" on the node they wish their application to register as. This "port" determines which of the applications on top of the node should receive an incoming message. NOTE: Use of this method of registering applications is recommended only for advanced users - 99% of all applications should just use the other registerApplication

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

getId

public Id getId()
Returns the Id of this node

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

getRingId

public Id getRingId()
Returns the ringId of this node

Returns:
This node's ringId

getNodeId

public Id getNodeId()
Returns the underlying id of this node

Returns:
This node's Id

getNode

public Node getNode()
Returns this mutliring node's internal node

Returns:
The wrapped node

getCollection

public MultiringNodeCollection getCollection()
Returns the collection this node is a member of

Returns:
This node's collection

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.

nodeAdded

protected void nodeAdded(Id otherRingId)
Method which is used to inform the node that another node has been added to the collection. This node then joins the appropriate Scribe group to advertise this it can route directly to that node's ring.

Parameters:
id - The Id of the newly added ring

anycast

public boolean anycast(Topic topic,
                       ScribeContent content)
This method is invoked when an anycast is received for a topic which this client is interested in. The client should return whether or not the anycast should continue.

Specified by:
anycast in interface ScribeClient
Parameters:
topic - The topic the message was anycasted to
content - The content which was anycasted
Returns:
Whether or not the anycast should continue

deliver

public void deliver(Topic topic,
                    ScribeContent content)
This method is invoked when a message is delivered for a topic this client is interested in.

Specified by:
deliver in interface ScribeClient
Parameters:
topic - The topic the message was published to
content - The content which was published

childAdded

public void childAdded(Topic topic,
                       NodeHandle child)
Informs this client that a child was added to a topic in which it was interested in.

Specified by:
childAdded in interface ScribeClient
Parameters:
topic - The topic to unsubscribe from
child - The child that was added

childRemoved

public void childRemoved(Topic topic,
                         NodeHandle child)
Informs this client that a child was removed from a topic in which it was interested in.

Specified by:
childRemoved in interface ScribeClient
Parameters:
topic - The topic to unsubscribe from
child - The child that was removed

subscribeFailed

public void subscribeFailed(Topic topic)
Informs the client that a subscribe on the given topic failed - the client should retry the subscribe or take appropriate action.

Specified by:
subscribeFailed in interface ScribeClient
Parameters:
topic - The topic which the subscribe failed on

toString

public java.lang.String toString()
Prints out the string

Overrides:
toString in class java.lang.Object
Returns:
A string

getEnvironment

public Environment getEnvironment()
Getter for the environment.

Specified by:
getEnvironment in interface Node
Returns:
the environment

ePOST API

Copyright © 2001-2005 - Rice Pastry.