Rice Pastry API

rice.p2p.scribe
Class ScribePolicy.DefaultScribePolicy

java.lang.Object
  extended by rice.p2p.scribe.ScribePolicy.DefaultScribePolicy
All Implemented Interfaces:
ScribePolicy
Direct Known Subclasses:
ScribePolicy.LimitedScribePolicy, ScribeRegrTest.TestScribePolicy, SplitStreamScribePolicy
Enclosing interface:
ScribePolicy

public static class ScribePolicy.DefaultScribePolicy
extends java.lang.Object
implements ScribePolicy

The default policy for Scribe, which always allows new children to join and adds children in the order in which they are provided, implicitly providing a depth-first search.

Version:
$Id: ScribePolicy.java 4098 2008-02-13 09:36:33Z jeffh $
Author:
amislove

Nested Class Summary
 
Nested classes/interfaces inherited from interface rice.p2p.scribe.ScribePolicy
ScribePolicy.DefaultScribePolicy, ScribePolicy.LimitedScribePolicy
 
Field Summary
protected  Environment environment
           
 
Constructor Summary
ScribePolicy.DefaultScribePolicy(Environment env)
           
 
Method Summary
 java.util.List<Topic> allowSubscribe(Scribe scribe, NodeHandle source, java.util.List<Topic> topics, ScribeContent content)
          If you don't override the deprecated allowSubscribe(), This method always return true;
 boolean allowSubscribe(SubscribeMessage message, ScribeClient[] clients, NodeHandle[] children)
          This method should be deprecated, but is here for reverse compatibility.
 void childAdded(Topic topic, NodeHandle child)
          Informs this policy that a child was added to a topic - the topic is free to ignore this upcall if it doesn't care.
 void childRemoved(Topic topic, NodeHandle child)
          Informs this policy that a child was removed from a topic - the topic is free to ignore this upcall if it doesn't care.
 void directAnycast(AnycastMessage message, NodeHandle parent, java.util.Collection<NodeHandle> theChildren)
          Simply adds the parent and children in order, which implements a depth-first-search.
 ScribeContent divideContent(java.util.List<Topic> theTopics, ScribeContent content)
          This method is called when the ScribeImpl splits a SubscribeMessage into multiple parts.
 void intermediateNode(ScribeMessage message)
          This is invoked whenever this message arrives on any overlay node, this gives the ScribeClient's power to tap into some datastructures they might wanna edit
 void recvAnycastFail(Topic topic, NodeHandle failedAtNode, ScribeContent content)
          This notifies us when we receive a failure for a anycast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

environment

protected Environment environment
Constructor Detail

ScribePolicy.DefaultScribePolicy

public ScribePolicy.DefaultScribePolicy(Environment env)
Method Detail

allowSubscribe

public java.util.List<Topic> allowSubscribe(Scribe scribe,
                                            NodeHandle source,
                                            java.util.List<Topic> topics,
                                            ScribeContent content)
If you don't override the deprecated allowSubscribe(), This method always return true;

Specified by:
allowSubscribe in interface ScribePolicy
Parameters:
message - The subscribe message in question
children - The list of children who are currently subscribed
clients - The list of clients are are currently subscribed
Returns:
the topics to accept

allowSubscribe

public boolean allowSubscribe(SubscribeMessage message,
                              ScribeClient[] clients,
                              NodeHandle[] children)
This method should be deprecated, but is here for reverse compatibility. We changed the allowSubscribe() method, but classes that extend DefaultScribePolicy object could make a mistake and not override the new one.

Parameters:
message -
clients -
children -
Returns:

directAnycast

public void directAnycast(AnycastMessage message,
                          NodeHandle parent,
                          java.util.Collection<NodeHandle> theChildren)
Simply adds the parent and children in order, which implements a depth-first-search. randomly picks a child

Specified by:
directAnycast in interface ScribePolicy
Parameters:
message - The anycast message in question
parent - Our current parent for this message's topic
children - Our current children for this message's topic

childAdded

public void childAdded(Topic topic,
                       NodeHandle child)
Informs this policy that a child was added to a topic - the topic is free to ignore this upcall if it doesn't care.

Specified by:
childAdded in interface ScribePolicy
Parameters:
topic - The topic to unsubscribe from
child - The child that was added

childRemoved

public void childRemoved(Topic topic,
                         NodeHandle child)
Informs this policy that a child was removed from a topic - the topic is free to ignore this upcall if it doesn't care.

Specified by:
childRemoved in interface ScribePolicy
Parameters:
topic - The topic to unsubscribe from
child - The child that was removed

intermediateNode

public void intermediateNode(ScribeMessage message)
Description copied from interface: ScribePolicy
This is invoked whenever this message arrives on any overlay node, this gives the ScribeClient's power to tap into some datastructures they might wanna edit

Specified by:
intermediateNode in interface ScribePolicy

recvAnycastFail

public void recvAnycastFail(Topic topic,
                            NodeHandle failedAtNode,
                            ScribeContent content)
Description copied from interface: ScribePolicy
This notifies us when we receive a failure for a anycast

Specified by:
recvAnycastFail in interface ScribePolicy

divideContent

public ScribeContent divideContent(java.util.List<Topic> theTopics,
                                   ScribeContent content)
Description copied from interface: ScribePolicy
This method is called when the ScribeImpl splits a SubscribeMessage into multiple parts. If you modify the content, you must make a copy, as the same content will be passed in for the other divisions of the SubscribeMessage. ScribeContent's are not naturally copyable, so Scribe cannot make a copy apriori.

Specified by:
divideContent in interface ScribePolicy
Parameters:
theTopics - topics going to a particular location
content - the content that may need to be divided
Returns:
the content if not changed, a new ScribeContent if changed

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection