rice.scribe
Class Topic
- public class Topic
- Version:
- $Id: Topic.java,v 1.11 2002/09/13 05:19:25 animesh Exp $
- Author:
- Romer Gil
- Eric Engineer
- Atul Singh
- Animesh Nandi
m_topicId
protected rice.pastry.NodeId m_topicId
- This topic's identifier
m_children
protected java.util.Set m_children
- Set of NodeHandle objects for the local node's children in this topic's multicast subtree rooted at the local node.
m_parent
protected rice.pastry.NodeHandle m_parent
- Local node's parent in this topic's multicast tree
m_wantUnsubscribe
protected boolean m_wantUnsubscribe
- Flag indicating if the local node is waiting to be unsubscribed (because it still does not know parent)
m_topicManager
protected boolean m_topicManager
- Indicates whether this node is manager of this topic.
m_apps
protected java.util.Set m_apps
- Set of IScribeApps that have subscribed to this Topic.
m_heartBeatsMissed
public int m_heartBeatsMissed
- This keeps track of the number of heartbeat messages missed corresponding to this topic. This value is INCREMENTED whenever a scheduleHB() method is invoked on the scribe object. The assumption is that simultaneously the scheduleHB() method is also being invoked on the other nodes including the parent for this topic. This value is RESET whenever the local node receives a heartbeat message, publish message or MessageAckOnSubscribe from the parent for the topic.
m_scribe
public rice.scribe.Scribe m_scribe
- The scribe object on which this topic resides.
Topic
public Topic(rice.pastry.NodeId topicId,
rice.scribe.Scribe scribe)
- Constructs an empty Topic
- Parameters:
topicId
- unique id for this topic.
scribe
- the scribe system in which the topic resides.
getTopicId
public rice.pastry.NodeId getTopicId()
- Returns the topic's id
- Returns:
- topic's unique identifier
addChild
public boolean addChild(rice.pastry.NodeHandle child)
- Adds a node to the Set of children in this topic's multicast subtree rooted at this node
- Parameters:
child
- the node to be added as a child.
- Returns:
- true if the child was NOT already in the Set of children.
removeChild
public boolean removeChild(rice.pastry.NodeHandle child)
- Removes a node from the Set of children in this topic's multicast subtree rooted at this node
- Parameters:
child
- the child node to be removed from the multicast tree.
- Returns:
- true if the child node was in the Set of children.
hasChildren
public boolean hasChildren()
- Indicates if the local node has children associated with this topic.
- Returns:
- true if the local node has children associated with this topic.
getChildren
public java.util.Vector getChildren()
- This returns the most current view of the children in this topic's multicast subtree rooted at the local node. Note that additions and deletions to the returned vector do not affect the actual children set maintained by the node.
- Returns:
- vector of nodeHandle objects.
setParent
public void setParent(rice.pastry.NodeHandle parent)
- Sets the local node's parent in this topic's multicast tree.
- Parameters:
parent
- the node to be the parent.
getParent
public rice.pastry.NodeHandle getParent()
- Returns the local node's parent in this topic's multicast tree.
- Returns:
- the parent node.
subscribe
public void subscribe(rice.scribe.IScribeApp app)
- Register an application as a subscriber to this Topic, so that the application receives events related to the Topic.
- Parameters:
app
- The application to be registered.
unsubscribe
public void unsubscribe(rice.scribe.IScribeApp app)
- Unregister an application as a Subscriber to this Topic, so that the application no longer receives events regarding this Topic.
- Parameters:
app
- The application to be unregistered.
hasSubscribers
public boolean hasSubscribers()
- If this topic has any applications registered as subscribers.
- Returns:
- true if there is at least one application subscribed to this topic.
waitUnsubscribe
public void waitUnsubscribe(boolean wait)
- Sets flag indicating if the local node is waiting to be unsubscribed from this topic (because it does not yet know its parent)
- Parameters:
wait
- value to set flag
isWaitingUnsubscribe
public boolean isWaitingUnsubscribe()
- Returns true if the local node is waiting to be unsubscribed from this topic.
- Returns:
- true if local node is waiting to be unsubscribed from this topic.
topicManager
public void topicManager(boolean topicMgr)
- Sets the flag indicating whether the current node is topic manager for this topic
- Parameters:
topicMgr
- value of the flag
isTopicManager
public boolean isTopicManager()
- Return boolean indicating if the node is topic manager for the current topic.
- Returns:
- true if topic manager, false otherwise
postponeParentHandler
public void postponeParentHandler()
- Resets the number of heartbeat messages corresponding to this topic to zero. This method is called when you get a heartbeat message or a publish message or a MessageAckOnSubscribe.
addToScribe
public void addToScribe()
- Creates a topic reference on the current Scribe node. This method is called by ScribeMessage objects.
removeFromScribe
public void removeFromScribe()
- Removes this topic reference on the current Scribe node. This method is called by ScribeMessage objects.
getApps
public rice.scribe.IScribeApp[] getApps()
- Gets all the applications that wish to receive events regarding this Topic.
- Returns:
- The applications currently registered with this Topic