Rice Pastry API

rice.scribe.messaging
Class MessageAnycast

java.lang.Object
  |
  +--rice.pastry.messaging.Message
        |
        +--rice.scribe.messaging.ScribeMessage
              |
              +--rice.scribe.messaging.MessageAnycast
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DirectScribeMaintenanceTest.TestAnycastMessage

public class MessageAnycast
extends ScribeMessage
implements java.io.Serializable

MessageAnycast is used whenever a Scribe node wishes to anycast to a particular topic. This method implements the DFS of the scribe topic tree. Applications which want different handling of anycast messages, might sub-class this class to write their own tree traversal algorithms. Whenever a local node receives anycast message for a topic after doing the DFS, it invokes the anycastHandler() on applications registered for this topic. If local applications can satisfy the request of anycast, then anycast message is not routed furthur otherwise tree traversal is continued. If no node is able to satisfy the anycast request, the faultHandler() method is invoked, where application specific handling can be done.

Version:
$Id: MessageAnycast.java,v 1.9 2003/01/30 05:09:28 atuls Exp $
Author:
Atul Singh
See Also:
Serialized Form

Field Summary
 
Fields inherited from class rice.scribe.messaging.ScribeMessage
m_source, m_topicId
 
Constructor Summary
MessageAnycast(rice.pastry.messaging.Address addr, rice.pastry.NodeHandle source, rice.pastry.NodeId topicId, rice.pastry.security.Credentials cred)
          Constructor
 
Method Summary
 int alreadySeenSize()
          Method returns the number of nodes visited during the DFS.
 void faultHandler(rice.scribe.Scribe scribe)
          Method to notify that anycast has failed.
 void handleDeliverMessage(rice.scribe.Scribe scribe, rice.scribe.Topic topic)
          This method is called whenever the scribe node receives a message for itself and wants to process it.
 boolean handleForwardMessage(rice.scribe.Scribe scribe, rice.scribe.Topic topic)
          This method is called whenever the scribe node forwards a message in the scribe network.
 java.lang.String toString()
           
 
Methods inherited from class rice.scribe.messaging.ScribeMessage
getData, getSource, getTopicId, setData
 
Methods inherited from class rice.pastry.messaging.Message
getCredentials, getDate, getDestination, getSenderId, getStream, hasPriority, setPriority, setSenderId, stamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageAnycast

public MessageAnycast(rice.pastry.messaging.Address addr,
                      rice.pastry.NodeHandle source,
                      rice.pastry.NodeId topicId,
                      rice.pastry.security.Credentials cred)
Constructor

Parameters:
addr - the address of the scribe receiver.
source - the node generating the message.
topicId - the topic to which this message refers to.
cred - the credentials associated with the mesasge.
Method Detail

handleDeliverMessage

public void handleDeliverMessage(rice.scribe.Scribe scribe,
                                 rice.scribe.Topic topic)
This method is called whenever the scribe node receives a message for itself and wants to process it. The processing is delegated by scribe to the message.

Specified by:
handleDeliverMessage in class ScribeMessage
Parameters:
scribe - the scribe application.
topic - the topic within the scribe application.

handleForwardMessage

public boolean handleForwardMessage(rice.scribe.Scribe scribe,
                                    rice.scribe.Topic topic)
This method is called whenever the scribe node forwards a message in the scribe network. The processing is delegated by scribe to the message. This method implements the DFS of the scribe topic tree. Applications which want different handling of anycast messages, should overwrite this method. Implementation policy --- The anycast message is routed first to the leaves of the topic tree and there applications are given upcalls (in form of anycastHandler() upcalls) and checked to see if furthur DFS has to be carried out. Then, message is routed to other nodes of the tree. If a node doesnt have application registered for this topic, then message is routed furthur.

Specified by:
handleForwardMessage in class ScribeMessage
Parameters:
scribe - the scribe application.
topic - the topic within the scribe application.
Returns:
true if the message should be routed further, false otherwise.

alreadySeenSize

public int alreadySeenSize()
Method returns the number of nodes visited during the DFS.

Returns:
number of nodes already seen during the DFS

faultHandler

public void faultHandler(rice.scribe.Scribe scribe)
Method to notify that anycast has failed. Derived classes can do more application-specific handling of such cases.

Parameters:
scribe - The scribe object present on the local node

toString

public java.lang.String toString()
Specified by:
toString in class ScribeMessage

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection