|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.p2p.scribe.ScribeImpl
public class ScribeImpl
Nested Class Summary | |
---|---|
static class |
ScribeImpl.ScribeClientConverter
Adapts an old ScribeClient to a new ScribeMultiClient This is for reverse compatibility. |
class |
ScribeImpl.TopicManager
Class which keeps track of a given topic |
Field Summary | |
---|---|
java.util.HashMap<NodeHandle,java.util.Collection<Topic>> |
allChildren
This contains a mapping of child - > all topics for which the local node has this node(hashtable key) as a child |
java.util.HashMap<NodeHandle,java.util.Collection<Topic>> |
allParents
This contains a mapping of parent - > all topics for which the local node has this node(hashtable key) as a parent |
protected Endpoint |
endpoint
this application's endpoint |
static int |
INFO_2
|
protected NodeHandle |
localHandle
the local node handle |
int |
MAINTENANCE_INTERVAL
The interval with which to perform maintenance |
int |
MESSAGE_TIMEOUT
the timeout for a subscribe message |
protected Node |
node
|
java.util.Set<Topic> |
pending
Topics that (should) have an outsanding subscription. |
protected ScribePolicy |
policy
this scribe's policy |
java.util.Set<Topic> |
roots
Topics that we are the root. |
java.util.Hashtable<Topic,ScribeImpl.TopicManager> |
topicManagers
the hashtable of topic -> TopicManager |
Fields inherited from interface rice.p2p.scribe.maintenance.MaintainableScribe |
---|
MAINTENANCE_ID |
Constructor Summary | |
---|---|
ScribeImpl(Node node,
ScribePolicy policy,
java.lang.String instance)
Constructor for Scribe |
|
ScribeImpl(Node node,
ScribePolicy policy,
java.lang.String instance,
ScribeMaintenancePolicy maintenancePolicy)
Constructor for Scribe |
|
ScribeImpl(Node node,
java.lang.String instance)
Constructor for Scribe, using the default policy. |
Method Summary | |
---|---|
protected void |
ackMessageReceived(SubscribeAckMessage message)
Internal method which processes an ack message |
void |
addChild(Topic topic,
NodeHandle child)
Adds a child to the given topic |
protected boolean |
addChildHelper(Topic topic,
NodeHandle child)
Adds a child to the given topic, using the specified sequence number in the ack message sent to the child. |
protected void |
addToAllChildren(Topic t,
NodeHandle child)
This method should be invoked after the state change in the Topic Manager has been made. |
protected void |
addToAllParents(Topic t,
NodeHandle parent)
|
boolean |
allParentsContains(Topic t,
NodeHandle parent)
|
boolean |
allParentsContainsParent(NodeHandle parent)
|
void |
anycast(Topic topic,
RawScribeContent content)
Anycasts the given content to a member of the given topic |
void |
anycast(Topic topic,
RawScribeContent content,
NodeHandle hint)
Anycasts the given content to a member of the given topic The hint helps us to implement centralized algorithms where the hint is the cachedRoot for the topic. |
void |
anycast(Topic topic,
ScribeContent content)
Anycasts the given content to a member of the given topic |
void |
anycast(Topic topic,
ScribeContent content,
NodeHandle hint)
Anycasts the given content to a member of the given topic The hint helps us to implement centralized algorithms where the hint is the cachedRoot for the topic. |
boolean |
containsChild(Topic topic,
NodeHandle child)
|
boolean |
containsTopic(Topic topic)
Returns true if there is a TopicManager associated with this topic (any parent/children/client exists) |
protected RawScribeContent |
convert(ScribeContent content)
|
void |
deliver(Id id,
Message message)
This method is called on the application at the destination node for the given id. |
void |
destroy()
|
protected void |
doSubscribe(java.util.Collection<Topic> theTopics,
ScribeMultiClient client,
RawScribeContent content,
NodeHandle hint)
This method prevents re-subscription to topics you are already a part of. |
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(Topic topic)
Returns the list of children for a given topic |
java.util.Collection<NodeHandle> |
getChildrenOfTopic(Topic topic)
|
java.util.Collection<ScribeClient> |
getClients(Topic topic)
Returns the list of clients for a given topic |
java.util.Collection<ScribeMultiClient> |
getClientsByTopic(Topic topic)
|
ScribeContentDeserializer |
getContentDeserializer()
|
Endpoint |
getEndpoint()
|
Environment |
getEnvironment()
|
Id |
getId()
Returns the Id of the local node |
protected ScribeMultiClient |
getMultiClient(ScribeClient client)
|
NodeHandle |
getParent(Topic topic)
Returns the parent for a given topic |
java.util.List<Id> |
getPathToRoot(Topic topic)
|
ScribePolicy |
getPolicy()
Returns the current policy for this scribe object |
NodeHandle |
getRoot(Topic topic)
Returns the root of the topic, if we can determine it. |
protected java.util.Collection<ScribeClient> |
getSimpleClients(java.util.Collection<ScribeMultiClient> multi)
|
ScribeImpl.TopicManager |
getTopicManager(Topic topic)
Lazy constructor. |
java.util.Collection<Topic> |
getTopics()
|
Topic[] |
getTopics(ScribeClient client)
Returns the list of topics the given client is subscribed to. |
java.util.Collection<Topic> |
getTopicsByChild(NodeHandle child)
This returns the topics for which the parameter 'child' is a Scribe tree child of the local node |
java.util.Collection<Topic> |
getTopicsByClient(ScribeClient client)
Returns the list of topics the given client is subscribed to. |
java.util.Collection<Topic> |
getTopicsByClient(ScribeMultiClient client)
|
java.util.Collection<Topic> |
getTopicsByParent(NodeHandle parent)
This returns the topics for which the parameter 'parent' is a Scribe tree parent of the local node |
protected boolean |
handleForwardSubscribeMessage(SubscribeMessage sMessage)
This is complicated because the SubscribeMessage may have many topics to subscribe to at once. |
boolean |
isRoot(Topic topic)
Returns whether or not this Scribe is the root for the given topic |
int |
numChildren(Topic topic)
|
void |
printAllChildrenDataStructure()
|
void |
printAllParentsDataStructure()
|
void |
publish(Topic topic,
RawScribeContent content)
Publishes the given message to the topic. |
void |
publish(Topic topic,
ScribeContent content)
Publishes the given message to the topic. |
protected void |
recvAnycastFail(Topic topic,
NodeHandle failedAtNode,
ScribeContent content)
|
void |
removeChild(Topic topic,
NodeHandle child)
Removes a child from the given topic |
protected void |
removeChild(Topic topic,
NodeHandle child,
boolean sendDrop)
Removes a child from the given topic |
protected void |
removeFromAllChildren(Topic t,
NodeHandle child)
Need to be holding lock: topicManagers |
protected void |
removeFromAllParents(Topic t,
NodeHandle parent)
|
void |
setContentDeserializer(ScribeContentDeserializer deserializer)
|
void |
setParent(Topic topic,
NodeHandle parent,
java.util.List<Id> pathToRoot)
|
void |
setPolicy(ScribePolicy policy)
Sets the current policy for this scribe object |
void |
subscribe(java.util.Collection<Topic> topics)
|
void |
subscribe(java.util.Collection<Topic> theTopics,
ScribeClient client,
RawScribeContent content,
NodeHandle hint)
Subscribe to multiple topics. |
void |
subscribe(java.util.Collection<Topic> theTopics,
ScribeClient client,
ScribeContent content,
NodeHandle hint)
Subscribe to multiple topics. |
void |
subscribe(java.util.Collection<Topic> theTopics,
ScribeMultiClient client,
RawScribeContent content,
NodeHandle hint)
|
void |
subscribe(java.util.Collection<Topic> theTopics,
ScribeMultiClient client,
ScribeContent content,
NodeHandle hint)
|
void |
subscribe(Topic topic,
ScribeClient client)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeClient client,
RawScribeContent content)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeClient client,
RawScribeContent content,
NodeHandle hint)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeClient client,
ScribeContent content)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeClient client,
ScribeContent content,
NodeHandle hint)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeMultiClient client)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeMultiClient client,
RawScribeContent content,
NodeHandle hint)
|
void |
subscribe(Topic topic,
ScribeMultiClient client,
ScribeContent content,
NodeHandle hint)
|
protected RawScribeContent |
toRawScribeContent(ScribeContent content)
|
java.lang.String |
toString()
|
void |
unsubscribe(java.util.Collection<Topic> topicsToUnsubscribe,
ScribeMultiClient client)
This code: for each Topic: 1) removes the client from the TopicManager 2) |
void |
unsubscribe(Topic topic,
ScribeClient client)
Unsubscribes the given client from the provided topic.getId |
void |
unsubscribe(Topic topic,
ScribeMultiClient client)
|
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. |
void |
update(java.util.Observable o,
java.lang.Object arg)
Called when a Node's liveness changes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INFO_2
public final int MAINTENANCE_INTERVAL
public final int MESSAGE_TIMEOUT
public java.util.Hashtable<Topic,ScribeImpl.TopicManager> topicManagers
protected ScribePolicy policy
protected Endpoint endpoint
protected NodeHandle localHandle
protected Node node
public java.util.HashMap<NodeHandle,java.util.Collection<Topic>> allChildren
public java.util.HashMap<NodeHandle,java.util.Collection<Topic>> allParents
public java.util.Set<Topic> roots
public java.util.Set<Topic> pending
Constructor Detail |
---|
public ScribeImpl(Node node, java.lang.String instance)
node
- The node below this Scribe implementationinstance
- The unique instance name of this Scribepublic ScribeImpl(Node node, ScribePolicy policy, java.lang.String instance)
node
- The node below this Scribe implementationpolicy
- The policy for this Scribeinstance
- The unique instance name of this Scribepublic ScribeImpl(Node node, ScribePolicy policy, java.lang.String instance, ScribeMaintenancePolicy maintenancePolicy)
node
- The node below this Scribe implementationpolicy
- The policy for this Scribeinstance
- The unique instance name of this ScribeMethod Detail |
---|
public Environment getEnvironment()
getEnvironment
in interface BaseScribe
public ScribePolicy getPolicy()
getPolicy
in interface BaseScribe
public void setPolicy(ScribePolicy policy)
setPolicy
in interface BaseScribe
policy
- The current policy for this scribepublic Id getId()
public int numChildren(Topic topic)
numChildren
in interface BaseScribe
public boolean containsTopic(Topic topic)
containsTopic
in interface BaseScribe
public java.util.Collection<ScribeClient> getClients(Topic topic)
getClients
in interface BaseScribe
topic
- The topic to return the clients of
public java.util.Collection<ScribeMultiClient> getClientsByTopic(Topic topic)
getClientsByTopic
in interface BaseScribe
protected java.util.Collection<ScribeClient> getSimpleClients(java.util.Collection<ScribeMultiClient> multi)
protected ScribeMultiClient getMultiClient(ScribeClient client)
public NodeHandle[] getChildren(Topic topic)
getChildren
in interface BaseScribe
topic
- The topic to return the children of
public java.util.Collection<NodeHandle> getChildrenOfTopic(Topic topic)
getChildrenOfTopic
in interface BaseScribe
public NodeHandle getParent(Topic topic)
getParent
in interface BaseScribe
topic
- The topic to return the parent of
public boolean isRoot(Topic topic)
isRoot
in interface BaseScribe
topic
- The topic in question
public NodeHandle getRoot(Topic topic)
BaseScribe
getRoot
in interface BaseScribe
protected void ackMessageReceived(SubscribeAckMessage message)
message
- The ackMessagepublic boolean containsChild(Topic topic, NodeHandle child)
containsChild
in interface BaseScribe
public void subscribe(java.util.Collection<Topic> topics)
public void subscribe(Topic topic, ScribeMultiClient client)
topic
- The topic to subscribe toclient
- The client to give messages topublic void subscribe(Topic topic, ScribeClient client)
subscribe
in interface BaseScribe
topic
- The topic to subscribe toclient
- The client to give messages topublic void subscribe(Topic topic, ScribeClient client, ScribeContent content)
JavaScribe
subscribe
in interface JavaScribe
topic
- The topic to subscribe toclient
- The client to give messages tocontent
- The content to include in the subscribepublic void subscribe(Topic topic, ScribeClient client, ScribeContent content, NodeHandle hint)
JavaScribe
subscribe
in interface JavaScribe
topic
- The topic to subscribe toclient
- The client to give messages tocontent
- The content to include in the subscribehint
- The first hop of the message ( Helpful to implement a centralized solution)public void subscribe(Topic topic, ScribeClient client, RawScribeContent content)
RawScribe
subscribe
in interface RawScribe
topic
- The topic to subscribe toclient
- The client to give messages tocontent
- The content to include in the subscribepublic void subscribe(Topic topic, ScribeClient client, RawScribeContent content, NodeHandle hint)
RawScribe
subscribe
in interface RawScribe
topic
- The topic to subscribe toclient
- The client to give messages tocontent
- The content to include in the subscribehint
- The first hop of the message ( Helpful to implement a centralized solution)public void subscribe(java.util.Collection<Topic> theTopics, ScribeClient client, RawScribeContent content, NodeHandle hint)
RawScribe
subscribe
in interface RawScribe
hint
- the first hoppublic void subscribe(java.util.Collection<Topic> theTopics, ScribeClient client, ScribeContent content, NodeHandle hint)
JavaScribe
subscribe
in interface JavaScribe
public void subscribe(Topic topic, ScribeMultiClient client, ScribeContent content, NodeHandle hint)
subscribe
in interface JavaScribe
public void subscribe(Topic topic, ScribeMultiClient client, RawScribeContent content, NodeHandle hint)
subscribe
in interface RawScribe
public void subscribe(java.util.Collection<Topic> theTopics, ScribeMultiClient client, ScribeContent content, NodeHandle hint)
subscribe
in interface JavaScribe
public void subscribe(java.util.Collection<Topic> theTopics, ScribeMultiClient client, RawScribeContent content, NodeHandle hint)
subscribe
in interface MaintainableScribe
subscribe
in interface RawScribe
protected RawScribeContent toRawScribeContent(ScribeContent content)
protected void doSubscribe(java.util.Collection<Topic> theTopics, ScribeMultiClient client, RawScribeContent content, NodeHandle hint)
theTopics
- client
- content
- hint
- public void unsubscribe(Topic topic, ScribeClient client)
unsubscribe
in interface BaseScribe
topic
- The topic to unsubscribe fromclient
- The client to unsubscribepublic void unsubscribe(Topic topic, ScribeMultiClient client)
unsubscribe
in interface BaseScribe
public void unsubscribe(java.util.Collection<Topic> topicsToUnsubscribe, ScribeMultiClient client)
unsubscribe
in interface BaseScribe
public void publish(Topic topic, ScribeContent content)
publish
in interface JavaScribe
topic
- The topic to publish tocontent
- The content to publishpublic void publish(Topic topic, RawScribeContent content)
RawScribe
publish
in interface RawScribe
topic
- The topic to publish tocontent
- The content to publishpublic void anycast(Topic topic, ScribeContent content)
anycast
in interface JavaScribe
topic
- The topic to anycast tocontent
- The content to anycastpublic void anycast(Topic topic, ScribeContent content, NodeHandle hint)
JavaScribe
anycast
in interface JavaScribe
topic
- The topic to anycast tocontent
- The content to anycasthint
- the first hop of the Anycastpublic void anycast(Topic topic, RawScribeContent content)
RawScribe
anycast
in interface RawScribe
topic
- The topic to anycast tocontent
- The content to anycastpublic void anycast(Topic topic, RawScribeContent content, NodeHandle hint)
RawScribe
anycast
in interface RawScribe
topic
- The topic to anycast tocontent
- The content to anycasthint
- the first hop of the Anycastpublic void addChild(Topic topic, NodeHandle child)
addChild
in interface BaseScribe
topic
- The topic to add the child tochild
- The child to addpublic void setParent(Topic topic, NodeHandle parent, java.util.List<Id> pathToRoot)
setParent
in interface MaintainableScribe
public ScribeImpl.TopicManager getTopicManager(Topic topic)
topic
-
protected boolean addChildHelper(Topic topic, NodeHandle child)
topic
- The topicchild
- THe child to addid
- The seuqnce number
public void removeChild(Topic topic, NodeHandle child)
removeChild
in interface BaseScribe
topic
- The topic to remove the child fromchild
- The child to removeprotected void removeChild(Topic topic, NodeHandle child, boolean sendDrop)
topic
- The topic to remove the child fromchild
- The child to removesendDrop
- Whether or not to send a drop message to the chilpublic java.util.Collection<Topic> getTopicsByClient(ScribeClient client)
getTopicsByClient
in interface BaseScribe
client
- The client in question
public java.util.Collection<Topic> getTopicsByClient(ScribeMultiClient client)
getTopicsByClient
in interface BaseScribe
public Topic[] getTopics(ScribeClient client)
BaseScribe
getTopics
in interface BaseScribe
client
- The client in question
protected void recvAnycastFail(Topic topic, NodeHandle failedAtNode, ScribeContent content)
protected void addToAllChildren(Topic t, NodeHandle child)
t
- child
- protected void removeFromAllChildren(Topic t, NodeHandle child)
t
- child
- protected void addToAllParents(Topic t, NodeHandle parent)
protected void removeFromAllParents(Topic t, NodeHandle parent)
public boolean allParentsContains(Topic t, NodeHandle parent)
public boolean allParentsContainsParent(NodeHandle parent)
public void printAllParentsDataStructure()
public void printAllChildrenDataStructure()
public java.util.Collection<Topic> getTopicsByParent(NodeHandle parent)
MaintainableScribe
getTopicsByParent
in interface MaintainableScribe
parent
- null/localHandle for topics rooted by uspublic java.util.Collection<Topic> getTopicsByChild(NodeHandle child)
MaintainableScribe
getTopicsByChild
in interface MaintainableScribe
public boolean forward(RouteMessage message)
forward
in interface Application
message
- The message being sent, containing an internal message along with a destination
key and nodeHandle next hop.
protected boolean handleForwardSubscribeMessage(SubscribeMessage sMessage)
sMessage
-
public void deliver(Id id, Message message)
deliver
in interface Application
id
- The destination id of the messagemessage
- The message being sentprotected RawScribeContent convert(ScribeContent content)
public void update(java.util.Observable o, java.lang.Object arg)
update
in interface java.util.Observer
public void update(NodeHandle handle, boolean joined)
update
in interface Application
handle
- The handle that has joined/leftjoined
- Whether the node has joined or leftpublic java.lang.String toString()
toString
in class java.lang.Object
public void destroy()
destroy
in interface Destructable
public Endpoint getEndpoint()
getEndpoint
in interface MaintainableScribe
public void setContentDeserializer(ScribeContentDeserializer deserializer)
setContentDeserializer
in interface RawScribe
public ScribeContentDeserializer getContentDeserializer()
getContentDeserializer
in interface RawScribe
public java.util.Collection<Topic> getTopics()
getTopics
in interface MaintainableScribe
public java.util.List<Id> getPathToRoot(Topic topic)
getPathToRoot
in interface MaintainableScribe
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |