ePOST API

rice.tutorial.lesson6
Class MyScribeClient

java.lang.Object
  extended by rice.tutorial.lesson6.MyScribeClient
All Implemented Interfaces:
Application, ScribeClient

public class MyScribeClient
extends java.lang.Object
implements ScribeClient, Application

We implement the Application interface to receive regular timed messages (see lesson5). We implement the ScribeClient interface to receive scribe messages (called ScribeContent).

Author:
Jeff Hoye

Field Summary
protected  Endpoint endpoint
          The Endpoint represents the underlieing node.
 
Constructor Summary
MyScribeClient(Node node)
          The constructor for this scribe client.
 
Method Summary
 boolean anycast(Topic topic, ScribeContent content)
          Called when we receive an anycast.
 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(Id id, Message message)
          Part of the Application interface.
 void deliver(Topic topic, ScribeContent content)
          Called whenever we receive a published message.
 boolean forward(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.
 NodeHandle[] getChildren()
           
 NodeHandle getParent()
           
 boolean isRoot()
          Some passthrough accessors for the myScribe
 void sendAnycast()
          Sends an anycast message.
 void sendMulticast()
          Sends the multicast message.
 void startPublishTask()
          Starts the publish task.
 void subscribe()
          Subscribes to myTopic.
 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.
 void update(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

endpoint

protected Endpoint endpoint
The Endpoint represents the underlieing node. By making calls on the Endpoint, it assures that the message will be delivered to a MyApp on whichever node the message is intended for.

Constructor Detail

MyScribeClient

public MyScribeClient(Node node)
The constructor for this scribe client. It will construct the ScribeApplication.

Parameters:
node - the PastryNode
Method Detail

subscribe

public void subscribe()
Subscribes to myTopic.


startPublishTask

public void startPublishTask()
Starts the publish task.


deliver

public void deliver(Id id,
                    Message message)
Part of the Application interface. Will receive PublishContent every so often.

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

sendMulticast

public void sendMulticast()
Sends the multicast message.


deliver

public void deliver(Topic topic,
                    ScribeContent content)
Called whenever we receive a published message.

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

sendAnycast

public void sendAnycast()
Sends an anycast message.


anycast

public boolean anycast(Topic topic,
                       ScribeContent content)
Called when we receive an anycast. If we return false, it will be delivered elsewhere. Returning true stops the message here.

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

childAdded

public void childAdded(Topic topic,
                       NodeHandle child)
Description copied from interface: ScribeClient
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)
Description copied from interface: ScribeClient
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)
Description copied from interface: ScribeClient
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

forward

public boolean forward(RouteMessage message)
Description copied from interface: Application
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

update

public void update(NodeHandle handle,
                   boolean joined)
Description copied from interface: Application
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

isRoot

public boolean isRoot()
Some passthrough accessors for the myScribe


getParent

public NodeHandle getParent()

getChildren

public NodeHandle[] getChildren()

ePOST API

Copyright © 2001-2005 - Rice Pastry.