Rice Pastry API

rice.p2p.scribe
Class ScribeImpl

java.lang.Object
  |
  +--rice.p2p.scribe.ScribeImpl
All Implemented Interfaces:
Application, Scribe

public class ScribeImpl
extends java.lang.Object
implements Scribe, Application

Version:
$Id: ScribeImpl.java,v 1.14 2003/10/22 03:16:40 amislove Exp $
Author:
Alan Mislove

Nested Class Summary
 class ScribeImpl.TopicManager
          Class which keeps track of a given topic
 
Field Summary
protected  rice.p2p.commonapi.Endpoint endpoint
          this application's endpoint
protected  rice.p2p.commonapi.NodeHandle handle
          the local node handle
protected  java.util.logging.Logger log
          the logger which we will use
static int MESSAGE_TIMEOUT
          the timeout for a subscribe message
protected  rice.p2p.scribe.ScribePolicy policy
          this scribe's policy
 java.util.Hashtable topics
          the hashtable of topic -> TopicManager
 
Constructor Summary
ScribeImpl(rice.p2p.commonapi.Node node, rice.p2p.scribe.ScribePolicy policy, java.lang.String instance)
          Constructor for Scribe
ScribeImpl(rice.p2p.commonapi.Node node, java.lang.String instance)
          Constructor for Scribe, using the default policy.
 
Method Summary
 void addChild(rice.p2p.scribe.Topic topic, rice.p2p.commonapi.NodeHandle child)
          Adds a child to the given topic
 void anycast(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeContent content)
          Anycasts the given content to a member of the given topic
 void deliver(rice.p2p.commonapi.Id id, rice.p2p.commonapi.Message message)
          This method is called on the application at the destination node for the given id.
 boolean forward(rice.p2p.commonapi.RouteMessage message)
          This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop.
 rice.p2p.commonapi.NodeHandle[] getChildren(rice.p2p.scribe.Topic topic)
          Returns the list of children for a given topic
 rice.p2p.scribe.ScribeClient[] getClients(rice.p2p.scribe.Topic topic)
          Returns the list of clients for a given topic
 rice.p2p.commonapi.Id getId()
          Returns the Id of the local node
 rice.p2p.commonapi.NodeHandle getParent(rice.p2p.scribe.Topic topic)
          Returns the parent for a given topic
 rice.p2p.scribe.ScribePolicy getPolicy()
          Returns the current policy for this scribe object
 boolean isRoot(rice.p2p.scribe.Topic topic)
          Returns whether or not this Scribe is the root for the given topic
 void publish(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeContent content)
          Publishes the given message to the topic.
 void removeChild(rice.p2p.scribe.Topic topic, rice.p2p.commonapi.NodeHandle child)
          Removes a child from the given topic
protected  void removeChild(rice.p2p.scribe.Topic topic, rice.p2p.commonapi.NodeHandle child, boolean sendDrop)
          Removes a child from the given topic
 void setPolicy(rice.p2p.scribe.ScribePolicy policy)
          Sets the current policy for this scribe object
 void subscribe(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeClient client)
          Subscribes the given client to the provided topic.
 void subscribe(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeClient client, rice.p2p.scribe.ScribeContent content)
          Subscribes the given client to the provided topic.
 void unsubscribe(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeClient client)
          Unsubscribes the given client from the provided topic.
 void update(rice.p2p.commonapi.NodeHandle handle, boolean joined)
          This method is invoked to inform the application that the given node has either joined or left the neighbor set of the local node, as the set would be returned by the neighborSet call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_TIMEOUT

public static int MESSAGE_TIMEOUT
the timeout for a subscribe message


topics

public java.util.Hashtable topics
the hashtable of topic -> TopicManager


policy

protected rice.p2p.scribe.ScribePolicy policy
this scribe's policy


endpoint

protected rice.p2p.commonapi.Endpoint endpoint
this application's endpoint


log

protected java.util.logging.Logger log
the logger which we will use


handle

protected rice.p2p.commonapi.NodeHandle handle
the local node handle

Constructor Detail

ScribeImpl

public ScribeImpl(rice.p2p.commonapi.Node node,
                  java.lang.String instance)
Constructor for Scribe, using the default policy.

Parameters:
node - The node below this Scribe implementation
instance - The unique instance name of this Scribe

ScribeImpl

public ScribeImpl(rice.p2p.commonapi.Node node,
                  rice.p2p.scribe.ScribePolicy policy,
                  java.lang.String instance)
Constructor for Scribe

Parameters:
node - The node below this Scribe implementation
policy - The policy for this Scribe
instance - The unique instance name of this Scribe
Method Detail

getPolicy

public rice.p2p.scribe.ScribePolicy getPolicy()
Returns the current policy for this scribe object

Specified by:
getPolicy in interface Scribe
Returns:
The current policy for this scribe

setPolicy

public void setPolicy(rice.p2p.scribe.ScribePolicy policy)
Sets the current policy for this scribe object

Specified by:
setPolicy in interface Scribe
Parameters:
policy - The current policy for this scribe

getId

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

Returns:
The Id of the local node

getClients

public rice.p2p.scribe.ScribeClient[] getClients(rice.p2p.scribe.Topic topic)
Returns the list of clients for a given topic

Parameters:
topic - The topic to return the clients of
Returns:
The clients of the topic

getChildren

public rice.p2p.commonapi.NodeHandle[] getChildren(rice.p2p.scribe.Topic topic)
Returns the list of children for a given topic

Specified by:
getChildren in interface Scribe
Parameters:
topic - The topic to return the children of
Returns:
The children of the topic

getParent

public rice.p2p.commonapi.NodeHandle getParent(rice.p2p.scribe.Topic topic)
Returns the parent for a given topic

Parameters:
topic - The topic to return the parent of
Returns:
The parent of the topic

isRoot

public boolean isRoot(rice.p2p.scribe.Topic topic)
Returns whether or not this Scribe is the root for the given topic

Specified by:
isRoot in interface Scribe
Parameters:
topic - The topic in question
Returns:
Whether or not we are currently the root

subscribe

public void subscribe(rice.p2p.scribe.Topic topic,
                      rice.p2p.scribe.ScribeClient client)
Subscribes the given client to the provided topic. Any message published to the topic will be delivered to the Client via the deliver() method.

Specified by:
subscribe in interface Scribe
Parameters:
topic - The topic to subscribe to
client - The client to give messages to

subscribe

public void subscribe(rice.p2p.scribe.Topic topic,
                      rice.p2p.scribe.ScribeClient client,
                      rice.p2p.scribe.ScribeContent content)
Subscribes the given client to the provided topic. Any message published to the topic will be delivered to the Client via the deliver() method.

Specified by:
subscribe in interface Scribe
Parameters:
topic - The topic to subscribe to
client - The client to give messages to
content - The content to include in the subscribe

unsubscribe

public void unsubscribe(rice.p2p.scribe.Topic topic,
                        rice.p2p.scribe.ScribeClient client)
Unsubscribes the given client from the provided topic.

Specified by:
unsubscribe in interface Scribe
Parameters:
topic - The topic to unsubscribe from
client - The client to unsubscribe

publish

public void publish(rice.p2p.scribe.Topic topic,
                    rice.p2p.scribe.ScribeContent content)
Publishes the given message to the topic.

Specified by:
publish in interface Scribe
Parameters:
topic - The topic to publish to
content - The content to publish

anycast

public void anycast(rice.p2p.scribe.Topic topic,
                    rice.p2p.scribe.ScribeContent content)
Anycasts the given content to a member of the given topic

Specified by:
anycast in interface Scribe
Parameters:
topic - The topic to anycast to
content - The content to anycast

addChild

public void addChild(rice.p2p.scribe.Topic topic,
                     rice.p2p.commonapi.NodeHandle child)
Adds a child to the given topic

Specified by:
addChild in interface Scribe
Parameters:
topic - The topic to add the child to
child - The child to add

removeChild

public void removeChild(rice.p2p.scribe.Topic topic,
                        rice.p2p.commonapi.NodeHandle child)
Removes a child from the given topic

Specified by:
removeChild in interface Scribe
Parameters:
topic - The topic to remove the child from
child - The child to remove

removeChild

protected void removeChild(rice.p2p.scribe.Topic topic,
                           rice.p2p.commonapi.NodeHandle child,
                           boolean sendDrop)
Removes a child from the given topic

Parameters:
topic - The topic to remove the child from
child - The child to remove
sendDrop - Whether or not to send a drop message to the chil

forward

public boolean forward(rice.p2p.commonapi.RouteMessage message)
This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop. Applications can change the contents of the message, specify a different nextHop (through re-routing), or completely terminate the message.

Specified by:
forward in interface Application
Parameters:
message - The message being sent, containing an internal message along with a destination key and nodeHandle next hop.
Returns:
Whether or not to forward the message further

deliver

public void deliver(rice.p2p.commonapi.Id id,
                    rice.p2p.commonapi.Message message)
This method is called on the application at the destination node for the given id.

Specified by:
deliver in interface Application
Parameters:
id - The destination id of the message
message - The message being sent

update

public void update(rice.p2p.commonapi.NodeHandle handle,
                   boolean joined)
This method is invoked to inform the application that the given node has either joined or left the neighbor set of the local node, as the set would be returned by the neighborSet call.

Specified by:
update in interface Application
Parameters:
handle - The handle that has joined/left
joined - Whether the node has joined or left

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection