solar.service.pack
Class ScribeManager

java.lang.Object
  |
  +--solar.service.pack.ScribeManager
All Implemented Interfaces:
rice.scribe.IScribeApp

public class ScribeManager
extends java.lang.Object
implements rice.scribe.IScribeApp

This is the only Scribe application that multiplexes events among PACK end-points.

Version:
$Id: ScribeManager.java,v 1.10 2003/10/05 18:50:58 glchen Exp $
Author:
Guanling Chen

Nested Class Summary
(package private) static interface ScribeManager.ScribeListener
           
 
Field Summary
protected  rice.pastry.security.Credentials _cred
           
protected  java.util.Hashtable _idtable
           
protected  ScribeManager.ScribeListener _listener
           
protected  rice.scribe.Scribe _scribe
           
 
Constructor Summary
ScribeManager(rice.pastry.PastryNode node, rice.pastry.security.Credentials cred)
           
ScribeManager(ScribeManager.ScribeListener listener, rice.pastry.PastryNode node, rice.pastry.security.Credentials cred)
           
 
Method Summary
 boolean anycastHandler(rice.scribe.messaging.ScribeMessage msg)
          Invoked by underlying scribe when it receives a anycast Message, to check if there is a local application which can take care of this anycast message.
 void create(Id topic)
          Create a mutlicast tree for specified topic.
 void faultHandler(rice.scribe.messaging.ScribeMessage msg, rice.pastry.NodeHandle faultyParent)
          Invoked by Scribe just before the "repair" SUBSCRIBE message is sent when a node suspects its parent is faulty.
 void forwardHandler(rice.scribe.messaging.ScribeMessage msg)
          Called by Scribe before the node forwards a message to its children in the multicast tree.
 java.util.List getChildren(Id topic)
          Get the children address of this node for specified topic.
 Address getNodeAddress(Id id)
          Convert a Solar ID to Pastry address.
 Address getNodeAddress(rice.pastry.NodeId nid)
          Convert a Pastry NodeID to Pastry address.
 rice.pastry.NodeId getNodeId(Id topic)
          Get/Update the Id-NodeId mapping from cache.
 Address getParent(Id topic)
          Get the parent address of this node for specified topic.
 void isNewRoot(rice.pastry.NodeId topicId)
          Upcall made by scribe to registered applications to inform them that local node is now the root for some topic, and hence can take appropriate action.
 boolean isRoot(Id topic)
          Is this node the root of specified topic.
 void join(Id topic)
          Join the mutlicast tree of specified topic.
 void multicast(Id topic, Event evt)
          Multicast an event to the tree of specified topic.
 void newParent(rice.pastry.NodeId topicId, rice.pastry.NodeHandle newParent, java.io.Serializable data)
          Upcall made by scribe to the registered applications to inform them that a new parent is found for local node in the topic tree.
 void receiveMessage(rice.scribe.messaging.ScribeMessage msg)
          up-call invoked by scribe when a publish message is 'delivered'.
 void scribeIsReady()
          Invoked when the underlying Scribe substrate is ready.
 void subscribeHandler(rice.pastry.NodeId topicId, rice.pastry.NodeHandle child, boolean wasAdded, java.io.Serializable obj)
          Invoked by Scribe after a child is added to or removed from one of the node's children tables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_listener

protected ScribeManager.ScribeListener _listener

_scribe

protected rice.scribe.Scribe _scribe

_cred

protected rice.pastry.security.Credentials _cred

_idtable

protected java.util.Hashtable _idtable
Constructor Detail

ScribeManager

public ScribeManager(ScribeManager.ScribeListener listener,
                     rice.pastry.PastryNode node,
                     rice.pastry.security.Credentials cred)

ScribeManager

public ScribeManager(rice.pastry.PastryNode node,
                     rice.pastry.security.Credentials cred)
Method Detail

isRoot

public boolean isRoot(Id topic)
Is this node the root of specified topic.


getChildren

public java.util.List getChildren(Id topic)
Get the children address of this node for specified topic.


getParent

public Address getParent(Id topic)
Get the parent address of this node for specified topic.


create

public void create(Id topic)
Create a mutlicast tree for specified topic.


join

public void join(Id topic)
Join the mutlicast tree of specified topic.


multicast

public void multicast(Id topic,
                      Event evt)
Multicast an event to the tree of specified topic.


getNodeAddress

public Address getNodeAddress(Id id)
Convert a Solar ID to Pastry address.


getNodeAddress

public Address getNodeAddress(rice.pastry.NodeId nid)
Convert a Pastry NodeID to Pastry address.


getNodeId

public rice.pastry.NodeId getNodeId(Id topic)
Get/Update the Id-NodeId mapping from cache.


scribeIsReady

public void scribeIsReady()
Invoked when the underlying Scribe substrate is ready. The Scribe substrate becomes ready as soon as the local Pastry node on which it lies is ready. In order to get this upcall it is necessary that the IScribeApp registers itself to the Scribe substrate using the registerApp() method in IScribe interface.

Specified by:
scribeIsReady in interface rice.scribe.IScribeApp

receiveMessage

public void receiveMessage(rice.scribe.messaging.ScribeMessage msg)
up-call invoked by scribe when a publish message is 'delivered'.

Specified by:
receiveMessage in interface rice.scribe.IScribeApp

forwardHandler

public void forwardHandler(rice.scribe.messaging.ScribeMessage msg)
Called by Scribe before the node forwards a message to its children in the multicast tree.

Specified by:
forwardHandler in interface rice.scribe.IScribeApp

subscribeHandler

public void subscribeHandler(rice.pastry.NodeId topicId,
                             rice.pastry.NodeHandle child,
                             boolean wasAdded,
                             java.io.Serializable obj)
Invoked by Scribe after a child is added to or removed from one of the node's children tables.

Specified by:
subscribeHandler in interface rice.scribe.IScribeApp

faultHandler

public void faultHandler(rice.scribe.messaging.ScribeMessage msg,
                         rice.pastry.NodeHandle faultyParent)
Invoked by Scribe just before the "repair" SUBSCRIBE message is sent when a node suspects its parent is faulty.

Specified by:
faultHandler in interface rice.scribe.IScribeApp

anycastHandler

public boolean anycastHandler(rice.scribe.messaging.ScribeMessage msg)
Invoked by underlying scribe when it receives a anycast Message, to check if there is a local application which can take care of this anycast message. If application can service the request of anycast message, the anycast message is not routed furthur(for DFS), else the anycast message will be furthur routed following DFS.

Specified by:
anycastHandler in interface rice.scribe.IScribeApp

isNewRoot

public void isNewRoot(rice.pastry.NodeId topicId)
Upcall made by scribe to registered applications to inform them that local node is now the root for some topic, and hence can take appropriate action.

Specified by:
isNewRoot in interface rice.scribe.IScribeApp

newParent

public void newParent(rice.pastry.NodeId topicId,
                      rice.pastry.NodeHandle newParent,
                      java.io.Serializable data)
Upcall made by scribe to the registered applications to inform them that a new parent is found for local node in the topic tree.

Specified by:
newParent in interface rice.scribe.IScribeApp