|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrice.p2p.scribe.ScribeImpl
public class ScribeImpl
Nested Class Summary | |
---|---|
class |
ScribeImpl.TopicManager
Class which keeps track of a given topic |
Field Summary | |
---|---|
java.util.HashMap<NodeHandle,java.util.List<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.List<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 |
protected NodeHandle |
handle
the local node handle |
static int |
INFO_2
|
int |
MAINTENANCE_INTERVAL
The interval with which to perform maintenance |
int |
MESSAGE_TIMEOUT
the timeout for a subscribe message |
protected ScribePolicy |
policy
this scribe's policy |
java.util.Hashtable<Topic,ScribeImpl.TopicManager> |
topics
the hashtable of topic -> TopicManager |
Constructor Summary | |
---|---|
ScribeImpl(Node node,
ScribePolicy policy,
java.lang.String instance)
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 void |
addChild(Topic topic,
NodeHandle child,
int id)
Adds a child to the given topic, using the specified sequence number in the ack message sent to the child. |
boolean |
allChildrenContains(Topic t,
NodeHandle child)
|
boolean |
allChildrenContainsChild(NodeHandle child)
|
boolean |
allParentsContains(Topic t,
NodeHandle parent)
|
boolean |
allParentsContainsParent(NodeHandle parent)
|
void |
anycast(Topic topic,
RawScribeContent content)
|
void |
anycast(Topic topic,
RawScribeContent content,
NodeHandle hint)
|
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) |
void |
deliver(Id id,
Message message)
This method is called on the application at the destination node for the given id. |
void |
destroy()
|
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 |
ScribeClient[] |
getClients(Topic topic)
Returns the list of clients for a given topic |
ScribeContentDeserializer |
getContentDeserializer()
|
Environment |
getEnvironment()
|
Id |
getId()
Returns the Id of the local node |
NodeHandle |
getParent(Topic topic)
Returns the parent for a given topic |
ScribePolicy |
getPolicy()
Returns the current policy for this scribe object |
NodeHandle |
getRoot(Topic topic)
|
Topic[] |
getTopics(ScribeClient client)
Returns the list of topics the given client is subscribed to. |
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)
|
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 |
void |
setContentDeserializer(ScribeContentDeserializer deserializer)
|
void |
setPolicy(ScribePolicy policy)
Sets the current policy for this scribe object |
void |
subscribe(Topic topic,
ScribeClient client)
Subscribes the given client to the provided topic. |
void |
subscribe(Topic topic,
ScribeClient client,
RawScribeContent content)
|
void |
subscribe(Topic topic,
ScribeClient client,
RawScribeContent content,
NodeHandle hint)
|
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. |
Topic[] |
topicsAsChild(NodeHandle child)
This returns the topics for which the parameter 'child' is a Scribe tree child of the local node |
Topic[] |
topicsAsParent(NodeHandle parent)
This returns the topics for which the parameter 'parent' is a Scribe tree parent of the local node |
java.lang.String |
toString()
|
void |
unsubscribe(Topic topic,
ScribeClient client)
Unsubscribes the given client from the provided topic.getId |
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 |
updateAllChildren(NodeHandle child,
Topic t,
boolean wasAdded)
|
void |
updateAllParents(NodeHandle parent,
Topic t,
boolean wasAdded)
|
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> topics
protected ScribePolicy policy
protected Endpoint endpoint
protected NodeHandle handle
public java.util.HashMap<NodeHandle,java.util.List<Topic>> allChildren
public java.util.HashMap<NodeHandle,java.util.List<Topic>> allParents
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 ScribeMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public Environment getEnvironment()
getEnvironment
in interface Scribe
public ScribePolicy getPolicy()
getPolicy
in interface Scribe
public void setPolicy(ScribePolicy policy)
setPolicy
in interface Scribe
policy
- The current policy for this scribepublic Id getId()
public int numChildren(Topic topic)
numChildren
in interface Scribe
public boolean containsTopic(Topic topic)
containsTopic
in interface Scribe
public ScribeClient[] getClients(Topic topic)
topic
- The topic to return the clients of
public NodeHandle[] getChildren(Topic topic)
getChildren
in interface Scribe
topic
- The topic to return the children of
public NodeHandle getParent(Topic topic)
getParent
in interface Scribe
topic
- The topic to return the parent of
public boolean isRoot(Topic topic)
isRoot
in interface Scribe
topic
- The topic in question
public NodeHandle getRoot(Topic topic)
protected void ackMessageReceived(SubscribeAckMessage message)
message
- The ackMessagepublic boolean containsChild(Topic topic, NodeHandle child)
containsChild
in interface Scribe
public void subscribe(Topic topic, ScribeClient client)
subscribe
in interface Scribe
topic
- The topic to subscribe toclient
- The client to give messages topublic void subscribe(Topic topic, ScribeClient client, ScribeContent content)
subscribe
in interface Scribe
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)
Scribe
subscribe
in interface Scribe
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)
subscribe
in interface Scribe
public void subscribe(Topic topic, ScribeClient client, RawScribeContent content, NodeHandle hint)
subscribe
in interface Scribe
public void unsubscribe(Topic topic, ScribeClient client)
unsubscribe
in interface Scribe
topic
- The topic to unsubscribe fromclient
- The client to unsubscribepublic void publish(Topic topic, ScribeContent content)
publish
in interface Scribe
topic
- The topic to publish tocontent
- The content to publishpublic void publish(Topic topic, RawScribeContent content)
publish
in interface Scribe
public void anycast(Topic topic, ScribeContent content)
anycast
in interface Scribe
topic
- The topic to anycast tocontent
- The content to anycastpublic void anycast(Topic topic, ScribeContent content, NodeHandle hint)
Scribe
anycast
in interface Scribe
topic
- The topic to anycast tocontent
- The content to anycasthint
- the first hop of the Anycastpublic void anycast(Topic topic, RawScribeContent content)
anycast
in interface Scribe
public void anycast(Topic topic, RawScribeContent content, NodeHandle hint)
anycast
in interface Scribe
public void addChild(Topic topic, NodeHandle child)
addChild
in interface Scribe
topic
- The topic to add the child tochild
- The child to addprotected void addChild(Topic topic, NodeHandle child, int id)
topic
- The topicchild
- THe child to addid
- THe seuqnce numberpublic void removeChild(Topic topic, NodeHandle child)
removeChild
in interface Scribe
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 Topic[] getTopics(ScribeClient client)
getTopics
in interface Scribe
client
- The client in question
protected void recvAnycastFail(Topic topic, NodeHandle failedAtNode, ScribeContent content)
public void updateAllChildren(NodeHandle child, Topic t, boolean wasAdded)
public boolean allChildrenContains(Topic t, NodeHandle child)
public boolean allChildrenContainsChild(NodeHandle child)
public void updateAllParents(NodeHandle parent, Topic t, boolean wasAdded)
public boolean allParentsContains(Topic t, NodeHandle parent)
public boolean allParentsContainsParent(NodeHandle parent)
public void printAllParentsDataStructure()
public void printAllChildrenDataStructure()
public Topic[] topicsAsParent(NodeHandle parent)
Scribe
topicsAsParent
in interface Scribe
public Topic[] topicsAsChild(NodeHandle child)
Scribe
topicsAsChild
in interface Scribe
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.
public void deliver(Id id, Message message)
deliver
in interface Application
id
- The destination id of the messagemessage
- The message being sentpublic void update(NodeHandle handle, boolean joined)
update
in interface Application
handle
- The handle that has joined/leftjoined
- Whether the node has joined or leftpublic void destroy()
destroy
in interface Destructable
destroy
in interface Scribe
public void setContentDeserializer(ScribeContentDeserializer deserializer)
setContentDeserializer
in interface Scribe
public ScribeContentDeserializer getContentDeserializer()
getContentDeserializer
in interface Scribe
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |