easypastry.cast
Class CastHandler

java.lang.Object
  extended by easypastry.cast.CastHandler
All Implemented Interfaces:
CastService, rice.p2p.commonapi.Application, rice.p2p.scribe.ScribeClient, rice.p2p.scribe.ScribeMultiClient

public class CastHandler
extends java.lang.Object
implements rice.p2p.scribe.ScribeMultiClient, rice.p2p.commonapi.Application, CastService


Field Summary
protected  rice.p2p.commonapi.Endpoint endpoint
           
 
Constructor Summary
CastHandler(rice.p2p.commonapi.Node node)
          The constructor for this scribe client.
 
Method Summary
 void addDeliverListener(java.lang.String id, CastListener dsl)
          Listeners & Filters
 void addForwardFilter(java.lang.String id, java.lang.String name, CastFilter dsf)
           
 boolean anycast(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeContent content)
          Called when we receive an anycast.
 void childAdded(rice.p2p.scribe.Topic topic, rice.p2p.commonapi.NodeHandle child)
          More Scribe Methods
 void childRemoved(rice.p2p.scribe.Topic topic, rice.p2p.commonapi.NodeHandle child)
           
 void close()
           
 void deliver(rice.p2p.commonapi.Id id, rice.p2p.commonapi.Message message)
           
 void deliver(rice.p2p.scribe.Topic topic, rice.p2p.scribe.ScribeContent content)
          Called whenever we receive a published message.
 boolean forward(rice.p2p.commonapi.RouteMessage message)
          Application
 java.util.Collection<rice.p2p.commonapi.NodeHandle> getChildren(java.lang.String subject)
           
 java.util.Collection<CastFilter> getForwardFilters(java.lang.String id)
           
 rice.p2p.commonapi.NodeHandle getLocalNodeHandle()
           
 java.util.Collection<rice.p2p.commonapi.NodeHandle> getNeighbours(int num, boolean ordered)
           
 rice.p2p.commonapi.NodeHandle getParent(java.lang.String subject)
           
 rice.p2p.commonapi.IdRange getRange(rice.p2p.commonapi.NodeHandle handle, int rank, rice.p2p.commonapi.Id lkey)
           
 java.util.Collection<rice.p2p.commonapi.NodeHandle> getReplicaSet(rice.p2p.commonapi.Id id, int num)
           
 boolean isRoot(java.lang.String subject)
          Some passthrough accessors
 void removeDeliverListener(java.lang.String id)
           
 void removeForwardFiter(java.lang.String id, java.lang.String name)
           
 void sendAnycast(java.lang.String subject, CastContent content)
          Sends an anycast message.
 void sendDirect(rice.p2p.commonapi.NodeHandle destNH, CastContent content)
          Sends a direct message.
 void sendHopped(rice.p2p.commonapi.Id id, CastContent content)
          Sends a hopped message.
 void sendManycast(java.lang.String subject, CastContent content, int num)
          Sends a manycast message.
 void sendMulticast(java.lang.String subject, CastContent content)
          Sends a multicast message.
 void subscribe(java.lang.String subject)
          Subscribes to id.
 void subscribeFailed(java.util.Collection<rice.p2p.scribe.Topic> topics)
           
 void subscribeFailed(rice.p2p.scribe.Topic topic)
           
 void subscribeSuccess(java.util.Collection<rice.p2p.scribe.Topic> topics)
           
 void unsubscribe(java.lang.String subject)
          Unsubscribes to id.
 void update(rice.p2p.commonapi.NodeHandle handle, boolean joined)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endpoint

protected rice.p2p.commonapi.Endpoint endpoint
Constructor Detail

CastHandler

public CastHandler(rice.p2p.commonapi.Node node)
The constructor for this scribe client. It will construct the ScribeApplication.

Parameters:
node - the PastryNode
Method Detail

subscribe

public void subscribe(java.lang.String subject)
Description copied from interface: CastService
Subscribes to id.

Specified by:
subscribe in interface CastService

unsubscribe

public void unsubscribe(java.lang.String subject)
Description copied from interface: CastService
Unsubscribes to id.

Specified by:
unsubscribe in interface CastService

sendDirect

public void sendDirect(rice.p2p.commonapi.NodeHandle destNH,
                       CastContent content)
Description copied from interface: CastService
Sends a direct message.

Specified by:
sendDirect in interface CastService

sendHopped

public void sendHopped(rice.p2p.commonapi.Id id,
                       CastContent content)
Description copied from interface: CastService
Sends a hopped message.

Specified by:
sendHopped in interface CastService

sendAnycast

public void sendAnycast(java.lang.String subject,
                        CastContent content)
Description copied from interface: CastService
Sends an anycast message.

Specified by:
sendAnycast in interface CastService

sendManycast

public void sendManycast(java.lang.String subject,
                         CastContent content,
                         int num)
Description copied from interface: CastService
Sends a manycast message.

Specified by:
sendManycast in interface CastService

sendMulticast

public void sendMulticast(java.lang.String subject,
                          CastContent content)
Description copied from interface: CastService
Sends a multicast message.

Specified by:
sendMulticast in interface CastService

anycast

public boolean anycast(rice.p2p.scribe.Topic topic,
                       rice.p2p.scribe.ScribeContent content)
Called when we receive an anycast. If we return false, it will be delivered elsewhere. Returning true stops the message here.

Specified by:
anycast in interface rice.p2p.scribe.ScribeClient
Specified by:
anycast in interface rice.p2p.scribe.ScribeMultiClient

deliver

public void deliver(rice.p2p.scribe.Topic topic,
                    rice.p2p.scribe.ScribeContent content)
Called whenever we receive a published message.

Specified by:
deliver in interface rice.p2p.scribe.ScribeClient
Specified by:
deliver in interface rice.p2p.scribe.ScribeMultiClient

forward

public boolean forward(rice.p2p.commonapi.RouteMessage message)
Application

Specified by:
forward in interface rice.p2p.commonapi.Application

deliver

public void deliver(rice.p2p.commonapi.Id id,
                    rice.p2p.commonapi.Message message)
Specified by:
deliver in interface rice.p2p.commonapi.Application

update

public void update(rice.p2p.commonapi.NodeHandle handle,
                   boolean joined)
Specified by:
update in interface rice.p2p.commonapi.Application

addDeliverListener

public void addDeliverListener(java.lang.String id,
                               CastListener dsl)
Description copied from interface: CastService
Listeners & Filters

Specified by:
addDeliverListener in interface CastService

removeDeliverListener

public void removeDeliverListener(java.lang.String id)
Specified by:
removeDeliverListener in interface CastService

addForwardFilter

public void addForwardFilter(java.lang.String id,
                             java.lang.String name,
                             CastFilter dsf)
Specified by:
addForwardFilter in interface CastService

removeForwardFiter

public void removeForwardFiter(java.lang.String id,
                               java.lang.String name)
Specified by:
removeForwardFiter in interface CastService

getForwardFilters

public java.util.Collection<CastFilter> getForwardFilters(java.lang.String id)
Specified by:
getForwardFilters in interface CastService

childAdded

public void childAdded(rice.p2p.scribe.Topic topic,
                       rice.p2p.commonapi.NodeHandle child)
More Scribe Methods

Specified by:
childAdded in interface rice.p2p.scribe.ScribeClient
Specified by:
childAdded in interface rice.p2p.scribe.ScribeMultiClient

childRemoved

public void childRemoved(rice.p2p.scribe.Topic topic,
                         rice.p2p.commonapi.NodeHandle child)
Specified by:
childRemoved in interface rice.p2p.scribe.ScribeClient
Specified by:
childRemoved in interface rice.p2p.scribe.ScribeMultiClient

subscribeFailed

public void subscribeFailed(rice.p2p.scribe.Topic topic)
Specified by:
subscribeFailed in interface rice.p2p.scribe.ScribeClient
Specified by:
subscribeFailed in interface rice.p2p.scribe.ScribeMultiClient

subscribeFailed

public void subscribeFailed(java.util.Collection<rice.p2p.scribe.Topic> topics)
Specified by:
subscribeFailed in interface rice.p2p.scribe.ScribeMultiClient

subscribeSuccess

public void subscribeSuccess(java.util.Collection<rice.p2p.scribe.Topic> topics)
Specified by:
subscribeSuccess in interface rice.p2p.scribe.ScribeMultiClient

isRoot

public boolean isRoot(java.lang.String subject)
Description copied from interface: CastService
Some passthrough accessors

Specified by:
isRoot in interface CastService

getParent

public rice.p2p.commonapi.NodeHandle getParent(java.lang.String subject)
Specified by:
getParent in interface CastService

getChildren

public java.util.Collection<rice.p2p.commonapi.NodeHandle> getChildren(java.lang.String subject)
Specified by:
getChildren in interface CastService

getLocalNodeHandle

public rice.p2p.commonapi.NodeHandle getLocalNodeHandle()
Specified by:
getLocalNodeHandle in interface CastService

getNeighbours

public java.util.Collection<rice.p2p.commonapi.NodeHandle> getNeighbours(int num,
                                                                         boolean ordered)
Specified by:
getNeighbours in interface CastService

getReplicaSet

public java.util.Collection<rice.p2p.commonapi.NodeHandle> getReplicaSet(rice.p2p.commonapi.Id id,
                                                                         int num)
Specified by:
getReplicaSet in interface CastService

getRange

public rice.p2p.commonapi.IdRange getRange(rice.p2p.commonapi.NodeHandle handle,
                                           int rank,
                                           rice.p2p.commonapi.Id lkey)
Specified by:
getRange in interface CastService

close

public void close()
Specified by:
close in interface CastService