Rice Pastry API

rice.p2p.splitstream
Class Stripe

java.lang.Object
  extended by rice.p2p.splitstream.Stripe
All Implemented Interfaces:
ScribeClient

public class Stripe
extends java.lang.Object
implements ScribeClient

This class encapsulates all data about an individual stripe. It is the basic unit in the system. It is rooted at the stripeId for the stripe. It is through the stripe that data is sent. It can be subscribed to in which case data is recieved or it can be unsubscribed from. A stripe can have some number of children and controlling this is the way that bandwidth is controlled. If a stripe is dropped then it searches for a new parent.

Version:
$Id: Stripe.java 4654 2009-01-08 16:33:07Z jeffh $
Author:
Ansley Post, Alan Mislove, Atul Singh

Field Summary
protected  Channel channel
          This stripe's channel
protected  java.util.Vector<SplitStreamClient> clients
          The list of SplitStreamClients interested in data from this client
protected  java.util.Hashtable<Topic,java.lang.Integer> failed
          The count of failed subscribe messages
protected  java.lang.String instance
           
protected  boolean isPrimary
          A flag whether or not this stripe is the primary stripe for this node
 int MAX_FAILED_SUBSCRIPTION
          The maximum number of failed subscriptions
protected  Scribe scribe
          The scribe object
protected  StripeId stripeId
          The stripeId for this stripe
protected  Topic topic
          The topic corresponding to this stripeId
 
Constructor Summary
Stripe(StripeId stripeId, Scribe scribe, java.lang.String instance, Channel channel, int maxFailedSubscriptions)
          The constructor used when creating a stripe from scratch.
 
Method Summary
 boolean anycast(Topic topic, ScribeContent content)
          This method is invoked when an anycast is received for a topic which this client is interested in.
 void childAdded(Topic topic, NodeHandle child)
          Informs this client that a child was added to a topic in which it was interested in.
 void childRemoved(Topic topic, NodeHandle child)
          Informs this client that a child was removed from a topic in which it was interested in.
 void deliver(Topic topic, ScribeContent content)
          This method is invoked when a message is delivered for a topic this client is interested in.
 NodeHandle[] getChildren()
          Utility method.
 NodeHandle getParent()
          Utility method.
 StripeId getStripeId()
          gets the StripeID for this stripe
 boolean isPrimary()
          Returns whether or not this stripe is the primary stripe for the local node
 boolean isRoot()
          Utility method.
 boolean isSubscribed()
          get the state of the Stripe
 void publish(byte[] data)
          Publishes the given data to this stripe
 void subscribe(SplitStreamClient client)
          Adds a client to this stripe - the client will be informed whenever data arrives for this stripe
 void subscribeFailed(Topic topic)
          Informs this client that a subscription failed
 java.lang.String toString()
          Returns a String representation of this Stripe
 void unsubscribe(SplitStreamClient client)
          Removes a client from this stripe - the client will no longer be informed whenever data arrives for this stripe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_FAILED_SUBSCRIPTION

public final int MAX_FAILED_SUBSCRIPTION
The maximum number of failed subscriptions


stripeId

protected StripeId stripeId
The stripeId for this stripe


topic

protected Topic topic
The topic corresponding to this stripeId


scribe

protected Scribe scribe
The scribe object


isPrimary

protected boolean isPrimary
A flag whether or not this stripe is the primary stripe for this node


clients

protected java.util.Vector<SplitStreamClient> clients
The list of SplitStreamClients interested in data from this client


channel

protected Channel channel
This stripe's channel


failed

protected java.util.Hashtable<Topic,java.lang.Integer> failed
The count of failed subscribe messages


instance

protected java.lang.String instance
Constructor Detail

Stripe

public Stripe(StripeId stripeId,
              Scribe scribe,
              java.lang.String instance,
              Channel channel,
              int maxFailedSubscriptions)
The constructor used when creating a stripe from scratch.

Parameters:
stripeId - the stripeId that this stripe will be rooted at
scribe - the scribe the stripe is running on top of
Method Detail

getStripeId

public StripeId getStripeId()
gets the StripeID for this stripe

Returns:
theStripeID

isPrimary

public boolean isPrimary()
Returns whether or not this stripe is the primary stripe for the local node

Returns:
Whether or not this stripe is primary

isSubscribed

public boolean isSubscribed()
get the state of the Stripe

Returns:
the State the stripe is in

subscribe

public void subscribe(SplitStreamClient client)
Adds a client to this stripe - the client will be informed whenever data arrives for this stripe

Parameters:
client - The client to add

unsubscribe

public void unsubscribe(SplitStreamClient client)
Removes a client from this stripe - the client will no longer be informed whenever data arrives for this stripe

Parameters:
client - The client to remove

publish

public void publish(byte[] data)
Publishes the given data to this stripe

Parameters:
data - The data to publish

anycast

public boolean anycast(Topic topic,
                       ScribeContent content)
This method is invoked when an anycast is received for a topic which this client is interested in. The client should return whether or not the anycast should continue.

Specified by:
anycast in interface ScribeClient
Parameters:
topic - The topic the message was anycasted to
content - The content which was anycasted
Returns:
Whether or not the anycast should continue

deliver

public void deliver(Topic topic,
                    ScribeContent content)
This method is invoked when a message is delivered for a topic this client is interested in.

Specified by:
deliver in interface ScribeClient
Parameters:
topic - The topic the message was published to
content - The content which was published

childAdded

public void childAdded(Topic topic,
                       NodeHandle child)
Informs this client that a child was added to a topic in which it was interested in.

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

childRemoved

public void childRemoved(Topic topic,
                         NodeHandle child)
Informs this client that a child was removed from a topic in which it was interested in.

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

subscribeFailed

public void subscribeFailed(Topic topic)
Informs this client that a subscription failed

Specified by:
subscribeFailed in interface ScribeClient
Parameters:
topic - The topic that failed

toString

public java.lang.String toString()
Returns a String representation of this Stripe

Overrides:
toString in class java.lang.Object
Returns:
A String representing this stripe

getChildren

public NodeHandle[] getChildren()
Utility method. Returns the list of children for this stripe.

Returns:
A array of children.

getParent

public NodeHandle getParent()
Utility method. Returns the parent for this topic in the scribe tree.

Returns:
Parent for this topic.

isRoot

public boolean isRoot()
Utility method. Checks if local node is root for this topic.

Returns:
True/False depending on if local node is root for this topic

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection