Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.p2p.scribe
Interface ScribePolicy

All Known Implementing Classes:
  ScribePolicy.DefaultScribePolicy, ScribePolicy.LimitedScribePolicy, ScribeRegrTest.TestScribePolicy, SplitStreamScribePolicy

    public interface ScribePolicy

Version:
  $Id: ScribePolicy.java 3671 2007-04-10 15:56:31Z jeffh $
Author:
  Alan Mislove

Nested Class Summary
`static class` | `ScribePolicy.DefaultScribePolicy` 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.
`static class` | `ScribePolicy.LimitedScribePolicy` An optional policy for Scribe, which allows up to a specified number of children per topic.

Method Summary
`java.util.List<Topic>` | `allowSubscribe(Scribe scribe, NodeHandle source, java.util.List<Topic> topics, ScribeContent content)` This method is called when the newChild is about to become our child, and the policy should return whether or not the child should be allowed to become our child.
`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> children)` This method is called when an anycast is received which is not satisfied at the local node.
`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

Method Detail

### allowSubscribe

    java.util.List<Topic> allowSubscribe(Scribe scribe,
                                         NodeHandle source,
                                         java.util.List<Topic> topics,
                                         ScribeContent content)

  This method is called when the newChild is about to become our child, and the policy should return whether or not the child should be allowed to become our child. If the length of children and clients is both 0, allowing the child to join will have the effect of implicitly subscribing this node the the given topic. For each Topic that you are willing to accept, call message.accept(Topic); Here is some example code:

       Iterator i = topics.iterator();
       while (i.hasNext()) {
         Topic topic = i.next();
         if (!accept(topic)) { // your decision on what to do for the topic
           i.remove();
         }
       }
       return topics;

  Or, to accept all:

       return topics;

  Some calls that are likely useful are:
  - scribe.getChildren(topic)
  - scribe.getClients(topic)
  If only some of the topics are accepted, the content may need to be modified. This method is allowed to modify the content.

  Parameters:
    `scribe` - the Scribe that is making the request
    `source` - the subscriber
    `topics` - the topics that are requested
    `content` - the content that came with the message
    `return` - the list that is accepted

### directAnycast

    void directAnycast(AnycastMessage message,
                       NodeHandle parent,
                       java.util.Collection<NodeHandle> children)

  This method is called when an anycast is received which is not satisfied at the local node. This method should add both the parent and child nodes to the anycast's to-search list, but this method allows different policies concerning the order of the adding as well as selectively adding nodes.

  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

    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.

  Parameters:
    `topic` - The topic to unsubscribe from
    `child` - The child that was added

### childRemoved

    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.

  Parameters:
    `topic` - The topic to unsubscribe from
    `child` - The child that was removed

### recvAnycastFail

    void recvAnycastFail(Topic topic,
                         NodeHandle failedAtNode,
                         ScribeContent content)

  This notifies us when we receive a failure for a anycast

### intermediateNode

    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

### divideContent

    ScribeContent divideContent(java.util.List<Topic> theTopics,
                                ScribeContent content)

  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.

  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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.