|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.mcgill.cs.postina.scribe.ScribeApplication
public class ScribeApplication
The class ScribeApplication implements the client on the
scribe-layer. This class is not intended to be used by a user of Postina. It
is a mediator between Scribe and the
ScribeNetworkLayer. Important reference for this class: The
FreePastry Tutorial, http://www.freepastry.org/FreePastry/tutorial/
| Nested Class Summary | |
|---|---|
private class |
ScribeApplication.messageHandler
The inner class messageHandler is responsible for handling all incoming direct messages. |
| Field Summary | |
|---|---|
private java.util.LinkedList<PostinaClientListener> |
clientListeners
The ArrayList containing all listeners registered to the
ScribeApplication for changes on clients. |
private int |
directMessageCounter
|
private rice.p2p.commonapi.Endpoint |
endpoint
The endpoint represents the underlying node. |
private java.util.LinkedList<rice.p2p.commonapi.Message> |
incomingMessages
Incoming messages are put into this list so that they can be handled by the messagehandler. |
private static org.apache.log4j.Logger |
logger
|
private int |
messageCounter
An integer counting the number of messages that have been sent by this client. |
private java.lang.Thread |
messageHandlerThread
The thread handling the incoming message.s |
private java.util.ArrayList<PostinaMsgListener> |
msgListeners
The ArrayList containing all message listeners registered
to the ScribeApplication. |
private java.util.LinkedList<MessageID> |
outstandingAcks
This list contains the unique identifiers of all messages that have been sent and that have not yet been confirmed. |
private java.util.LinkedList<rice.p2p.scribe.Topic> |
outstandingSubscriptions
The list of subscriptions that have been issued but not yet confirmed. |
private int |
receivedMessageCounter
|
private rice.p2p.scribe.ScribeImpl |
scribe
The link to the default implementation of Scribe. |
private java.util.Hashtable<MessageID,PostinaReliableScribeTransportMessage> |
sentMessages
A buffer keeping the messages sent by this client. |
private boolean |
threadIsAlive
This boolean is only used to properly stop the thread handling the incoming direct messages. |
| Constructor Summary | |
|---|---|
ScribeApplication(rice.p2p.commonapi.Node node)
The constructor for this scribe client. |
|
| Method Summary | |
|---|---|
void |
addClientListener(PostinaClientListener listener)
This method registers a listener to changes in the client structure. |
void |
addListener(PostinaMsgListener listener)
Registers the given listener to this
ScribeApplication |
private void |
addOutstanding(java.util.Collection<rice.p2p.scribe.Topic> topics)
This method is the counterpart of removeOutstanding and adds the
given subscriptions to the list of outstanding subscriptions. |
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)
|
void |
childRemoved(rice.p2p.scribe.Topic topic,
rice.p2p.commonapi.NodeHandle child)
|
void |
deliver(rice.p2p.commonapi.Id id,
rice.p2p.commonapi.Message message)
Part of the Application interface. |
void |
deliver(rice.p2p.scribe.Topic topic,
rice.p2p.scribe.ScribeContent content)
Called whenever a published message is received. |
protected void |
destroy()
Destroy the ScribeApplication, i.e. remove it from
the P2P-network. |
protected void |
directReliableSend(rice.p2p.commonapi.NodeHandle destination,
PostinaReliableScribeTransportMessage msg)
Sends a private message directly to the client indicated. |
protected void |
directSend(rice.p2p.commonapi.NodeHandle destination,
rice.p2p.commonapi.Message msg)
Send a private message directly to the client indicated. |
boolean |
forward(rice.p2p.commonapi.RouteMessage message)
|
protected void |
informListeners(PostinaMessage message)
This method informs registered listeners about a new message. |
protected void |
publish(ScribeTopic topic,
PostinaScribeTransportMessage content)
Publishes the given ScribeTransportMessage to the given
topic. |
void |
removeClientListener(PostinaClientListener listener)
This method unregisters a listener to changes in the client structure. |
protected void |
removeListener(PostinaMsgListener listener)
Unregisters the given listener from this
ScribeApplication |
private void |
removeOutstanding(java.util.Collection<rice.p2p.scribe.Topic> topics)
This method is called when subscriptions are confirmed. It removes all confirmed subscriptions from the list of outstanding subscriptions. |
protected void |
sendRequest(rice.p2p.commonapi.NodeHandle destination,
ScribeRequestMessage requestMessage)
Sends a request to another client asking it to perform a specified action. |
protected void |
subscribe(java.util.Collection<rice.p2p.scribe.Topic> topics,
PostinaScribeTransportMessage content)
Subscribes this ScribeApplication to the
Collection of Topics. |
protected void |
subscribe(ScribeTopic topic,
PostinaScribeTransportMessage content)
Subscribes this ScribeApplication to the given
ScribeTopic. |
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)
|
protected void |
unsubscribe(java.util.Collection<rice.p2p.scribe.Topic> topics)
Unsubscribes this ScribeApplication from the
Collection of Topics. |
protected void |
unsubscribe(ScribeTopic topic)
Unsubscribes this ScribeApplication from the given
ScribeTopic. |
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 |
|---|
private static final org.apache.log4j.Logger logger
private final java.util.LinkedList<PostinaClientListener> clientListeners
ArrayList containing all listeners registered to the
ScribeApplication for changes on clients. Usually, there
is only a single listener, namely the ScribeNetworkLayer.
private final int directMessageCounter
private final rice.p2p.commonapi.Endpoint endpoint
endpoint represents the underlying node. By making
calls on the endpoint, it assures that the message will
be delivered to the application to whichever the message has to go.
private final java.util.LinkedList<rice.p2p.commonapi.Message> incomingMessages
private int messageCounter
private final java.lang.Thread messageHandlerThread
private final java.util.ArrayList<PostinaMsgListener> msgListeners
ArrayList containing all message listeners registered
to the ScribeApplication. Usually, there is only a single
listener, namely the ScribeNetworkLayer.
private final java.util.LinkedList<MessageID> outstandingAcks
private final java.util.LinkedList<rice.p2p.scribe.Topic> outstandingSubscriptions
private final int receivedMessageCounter
private final rice.p2p.scribe.ScribeImpl scribe
private final java.util.Hashtable<MessageID,PostinaReliableScribeTransportMessage> sentMessages
private boolean threadIsAlive
| Constructor Detail |
|---|
public ScribeApplication(rice.p2p.commonapi.Node node)
node - The PastryNode| Method Detail |
|---|
public void addClientListener(PostinaClientListener listener)
listener - The listener registering.public void addListener(PostinaMsgListener listener)
listener to this
ScribeApplication
listener - The PostinaMsgListener which has to be added to the
list of listeners to this application.private void addOutstanding(java.util.Collection<rice.p2p.scribe.Topic> topics)
removeOutstanding and adds the
given subscriptions to the list of outstanding subscriptions.
topics - The topics to which the client has issued a subscription.
public boolean anycast(rice.p2p.scribe.Topic topic,
rice.p2p.scribe.ScribeContent content)
anycast in interface rice.p2p.scribe.ScribeClientanycast in interface rice.p2p.scribe.ScribeMultiClient
public void childAdded(rice.p2p.scribe.Topic topic,
rice.p2p.commonapi.NodeHandle child)
childAdded in interface rice.p2p.scribe.ScribeClientchildAdded in interface rice.p2p.scribe.ScribeMultiClient
public void childRemoved(rice.p2p.scribe.Topic topic,
rice.p2p.commonapi.NodeHandle child)
childRemoved in interface rice.p2p.scribe.ScribeClientchildRemoved in interface rice.p2p.scribe.ScribeMultiClient
public void deliver(rice.p2p.commonapi.Id id,
rice.p2p.commonapi.Message message)
deliver in interface rice.p2p.commonapi.Application
public void deliver(rice.p2p.scribe.Topic topic,
rice.p2p.scribe.ScribeContent content)
deliver in interface rice.p2p.scribe.ScribeClientdeliver in interface rice.p2p.scribe.ScribeMultiClientprotected void destroy()
ScribeApplication, i.e. remove it from
the P2P-network.
protected void directReliableSend(rice.p2p.commonapi.NodeHandle destination,
PostinaReliableScribeTransportMessage msg)
destination - The NodeHandle of the client which should receive the
direct message.msg - The PostinaReliableScribeTransportMessage that has to
be sent to the client.
protected void directSend(rice.p2p.commonapi.NodeHandle destination,
rice.p2p.commonapi.Message msg)
destination - The NodeHandle of the client which should receive the
direct message.msg - The Message that has to be sent to the client.public boolean forward(rice.p2p.commonapi.RouteMessage message)
forward in interface rice.p2p.commonapi.Applicationprotected void informListeners(PostinaMessage message)
message - The newly arrived message that is passed to the listeners.
protected void publish(ScribeTopic topic,
PostinaScribeTransportMessage content)
ScribeTransportMessage to the given
topic.
topic - The ScribeTopic to which the content should be
published.content - The PostinaScribeTransportMessage (containing the
message) that should be delivered to all subscribed clients.public void removeClientListener(PostinaClientListener listener)
listener - The listener unregistering.protected void removeListener(PostinaMsgListener listener)
listener from this
ScribeApplication
listener - The PostinaMsgListener which has to be removed from
the list of listeners to this application.private void removeOutstanding(java.util.Collection<rice.p2p.scribe.Topic> topics)
topics - The topics of the subscriptions that have been confirmed.
protected void sendRequest(rice.p2p.commonapi.NodeHandle destination,
ScribeRequestMessage requestMessage)
destination - The NodeHandle of the client that should perform the
requested action.requestMessage - The ScribeRequestMessage defining the action to be
taken by the client specified as destination
protected void subscribe(java.util.Collection<rice.p2p.scribe.Topic> topics,
PostinaScribeTransportMessage content)
ScribeApplication to the
Collection of Topics.
topics - The Collection of Topics to
which this ScribeApplication has to subscribe
to.content - The PostinaScribeTransportMessage is an optional
message that can be routed together with the subscription.
protected void subscribe(ScribeTopic topic,
PostinaScribeTransportMessage content)
ScribeApplication to the given
ScribeTopic.
topic - The ScribeTopic to which the
ScribeApplication has to subscribe to.content - The PostinaScribeTransportMessage is an optional
message that can be routed together with the subscription.public void subscribeFailed(java.util.Collection<rice.p2p.scribe.Topic> topics)
subscribeFailed in interface rice.p2p.scribe.ScribeMultiClientpublic void subscribeFailed(rice.p2p.scribe.Topic topic)
subscribeFailed in interface rice.p2p.scribe.ScribeClientsubscribeFailed in interface rice.p2p.scribe.ScribeMultiClientpublic void subscribeSuccess(java.util.Collection<rice.p2p.scribe.Topic> topics)
subscribeSuccess in interface rice.p2p.scribe.ScribeMultiClientprotected void unsubscribe(java.util.Collection<rice.p2p.scribe.Topic> topics)
ScribeApplication from the
Collection of Topics.
topics - The Collection of Topics from
which this ScribeApplication has to
unsubscribe..protected void unsubscribe(ScribeTopic topic)
ScribeApplication from the given
ScribeTopic.
topic - The ScribeTopic from which this
ScribeApplication has to unsubscribe.
public void update(rice.p2p.commonapi.NodeHandle handle,
boolean joined)
update in interface rice.p2p.commonapi.Application
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||