ePOST API

rice.post
Class PostImpl

java.lang.Object
  extended by rice.post.PostImpl
All Implemented Interfaces:
Application, ScribeClient, Post

public class PostImpl
extends java.lang.Object
implements Post, Application, ScribeClient

This class is the service layer which allows Post applications to use Post functionality.

Version:
$Id: PostImpl.java 2962 2006-01-25 19:20:17Z jstewart $
Author:
Alan Mislove, Ansley Post

Field Summary
protected  PostEntityAddress address
          The address of the local user.
static int BACKUP_INTERVAL
          The interval between log refreshes
protected  Endpoint endpoint
          The endpoint used for routing messages
protected  Environment environment
          The Environment.
protected  java.lang.String instance
          The instance.
protected  Logger logger
           
static int REPLICATION_FACTOR
          The replication factor to use for replicating delivery messages
protected  Scribe scribe
          The local Scribe service to use for notification.
static int SYNCHRONIZE_WAIT
           
 
Constructor Summary
PostImpl(Node node, Past immutablePast, Past mutablePast, DeliveryPast deliveryPast, Past deliveredPast, PostEntityAddress address, java.security.KeyPair keyPair, PostCertificate certificate, java.security.PublicKey caPublicKey, java.lang.String instance, boolean logRewrite, boolean announce, PostEntityAddress previousAddress, long synchronizeInterval, long refreshInterval, long timeoutInterval)
          Builds a PostImpl to run on the given pastry node, using the provided PAST and Scribe services.
 
Method Summary
 void addClient(PostClient client)
          Registers a client with this Post
 void announcePresence()
          This method announce's our presence via our scribe tree
 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 createPostLog(Continuation command)
          Internal method which builds a new PostLog for the log user.
 void deliver(Id id, Message message)
          The method by which Pastry passes a message up to POST
 void deliver(Topic topic, ScribeContent content)
          Method by which Scribe delivers a message to this client.
 boolean forward(RouteMessage message)
          This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop.
 void getAndVerifyPostLog(Continuation command)
          Shortcut which returns the PostLog of the local user.
 java.security.PublicKey getCAPublicKey()
          Returns the certificate authority's public key.
 Endpoint getEndpoint()
           
 PostEntityAddress getEntityAddress()
          Returns the PostEntityAddress of this Post's local user.
 Environment getEnvironment()
          Get the rice.environment.Environment.
 java.lang.String getInstance()
           
 void getPostLog(Continuation command)
          Shortcut which returns the PostLog of the local user.
 void getPostLog(PostEntityAddress entity, Continuation command)
          Returns and verifies the PostLog of the named entity
 StorageService getStorageService()
          This method returns the local storage service.
 void joinGroup(PostGroupAddress address, byte[] key)
          This method causes the local POST service to subscribe to the specified address, and use the specified shared key in order to decrypt messages.
 void removeClient(PostClient client)
          Removes a client from this PostService.
 void sendGroup(NotificationMessage message, Continuation command)
          This method multicasts the provided notification message to the destination group.
 void sendNotification(NotificationMessage message, Continuation command)
          Sends a notification message with destination specified by the members of the NotificationMessage.
 void sendNotificationDirect(NodeHandle handle, NotificationMessage message, Continuation command)
          Sends a notification message with destination specified by the members of the NotificationMessage.
 void subscribeFailed(Topic topic)
          Informs the client that a subscribe on the given topic failed - the client should retry the subscribe or take appropriate action.
 java.lang.String toString()
           
 void update(NodeHandle handle, boolean joined)
          This method is invoked to inform the application that the given node has either joined or left the neighbor set of the local node, as the set would be returned by the neighborSet call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REPLICATION_FACTOR

public static final int REPLICATION_FACTOR
The replication factor to use for replicating delivery messages

See Also:
Constant Field Values

BACKUP_INTERVAL

public static int BACKUP_INTERVAL
The interval between log refreshes


SYNCHRONIZE_WAIT

public static int SYNCHRONIZE_WAIT

endpoint

protected Endpoint endpoint
The endpoint used for routing messages


scribe

protected Scribe scribe
The local Scribe service to use for notification.


address

protected PostEntityAddress address
The address of the local user.


environment

protected Environment environment
The Environment.


logger

protected Logger logger

instance

protected final java.lang.String instance
The instance.

Constructor Detail

PostImpl

public PostImpl(Node node,
                Past immutablePast,
                Past mutablePast,
                DeliveryPast deliveryPast,
                Past deliveredPast,
                PostEntityAddress address,
                java.security.KeyPair keyPair,
                PostCertificate certificate,
                java.security.PublicKey caPublicKey,
                java.lang.String instance,
                boolean logRewrite,
                boolean announce,
                PostEntityAddress previousAddress,
                long synchronizeInterval,
                long refreshInterval,
                long timeoutInterval)
         throws PostException
Builds a PostImpl to run on the given pastry node, using the provided PAST and Scribe services.

Parameters:
node - The Pastry node to run on.
past - The PAST service running on this Pastry node.
address - The address of the user in the system
keyPair - The KeyPair of this user
certificate - The certificate authenticating this user
caPublicKey - The public key of the certificate authority
instance - The unique instance name of this POST
Throws:
PostException - if the PostLog could not be accessed
Method Detail

getEndpoint

public Endpoint getEndpoint()
Returns:
The Endpoint

getEntityAddress

public PostEntityAddress getEntityAddress()
Description copied from interface: Post
Returns the PostEntityAddress of this Post's local user.

Specified by:
getEntityAddress in interface Post
Returns:
The PostEntityAddress of the local user.

getCAPublicKey

public java.security.PublicKey getCAPublicKey()
Description copied from interface: Post
Returns the certificate authority's public key.

Specified by:
getCAPublicKey in interface Post
Returns:
The CA's public key

deliver

public void deliver(Id id,
                    Message message)
The method by which Pastry passes a message up to POST

Specified by:
deliver in interface Application
Parameters:
message - The message which has arrived
id - The destination id of the message

forward

public boolean forward(RouteMessage message)
This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop. Applications can change the contents of the message, specify a different nextHop (through re-routing), or completely terminate the message.

Specified by:
forward in interface Application
Parameters:
message - The message being sent, containing an internal message along with a destination key and nodeHandle next hop.
Returns:
Whether or not to forward the message further

update

public void update(NodeHandle handle,
                   boolean joined)
This method is invoked to inform the application that the given node has either joined or left the neighbor set of the local node, as the set would be returned by the neighborSet call.

Specified by:
update in interface Application
Parameters:
handle - The handle that has joined/left
joined - Whether the node has joined or left

deliver

public void deliver(Topic topic,
                    ScribeContent content)
Method by which Scribe delivers a message to this client.

Specified by:
deliver in interface ScribeClient
Parameters:
msg - The incoming message.

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

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 the client that a subscribe on the given topic failed - the client should retry the subscribe or take appropriate action.

Specified by:
subscribeFailed in interface ScribeClient
Parameters:
topic - The topic which the subscribe failed on

createPostLog

public void createPostLog(Continuation command)
Internal method which builds a new PostLog for the log user. If a previous post log has been specified, it uses that to clone, otherwise, it simply creates a blank log. *DO NOT USE!*

Parameters:
command - The command to call once done

getAndVerifyPostLog

public void getAndVerifyPostLog(Continuation command)
Description copied from interface: Post
Shortcut which returns the PostLog of the local user. This version also verifies all replicas for safety

Specified by:
getAndVerifyPostLog in interface Post

getPostLog

public void getPostLog(Continuation command)
Description copied from interface: Post
Shortcut which returns the PostLog of the local user.

Specified by:
getPostLog in interface Post

getPostLog

public void getPostLog(PostEntityAddress entity,
                       Continuation command)
Description copied from interface: Post
Returns and verifies the PostLog of the named entity

Specified by:
getPostLog in interface Post

getStorageService

public StorageService getStorageService()
This method returns the local storage service.

Specified by:
getStorageService in interface Post
Returns:
The storage service.

addClient

public void addClient(PostClient client)
Registers a client with this Post

Specified by:
addClient in interface Post
Parameters:
client - The client to add

announcePresence

public void announcePresence()
This method announce's our presence via our scribe tree

Specified by:
announcePresence in interface Post

removeClient

public void removeClient(PostClient client)
Removes a client from this PostService.

Specified by:
removeClient in interface Post
Parameters:
client - The client to remove

sendNotification

public void sendNotification(NotificationMessage message,
                             Continuation command)
Sends a notification message with destination specified by the members of the NotificationMessage. Destination parameters include a PostEntityAddress which specifies the group or user to which the notification should go, and a PostClientAddress which specifies the user application to which the notification should go. The NotificationMessage sent is signed by the sender and is then encrypted with the public key of each recipient.

Specified by:
sendNotification in interface Post
Parameters:
message - The notification message to be sent. Destination parameters are encapsulated inside the message object.
command - The command to run once the operation is complete

sendNotificationDirect

public void sendNotificationDirect(NodeHandle handle,
                                   NotificationMessage message,
                                   Continuation command)
Sends a notification message with destination specified by the members of the NotificationMessage. Destination parameters include a PostEntityAddress which specifies the group or user to which the notification should go, and a PostClientAddress which specifies the user application to which the notification should go. The NotificationMessage sent is signed by the sender and is then encrypted with the public key of each recipient. In this method, the notification message is sent directly to the provided node handle, instead of through a group of random nodes via the Scribe tree.

Specified by:
sendNotificationDirect in interface Post
Parameters:
message - The notification message to be sent. Destination parameters are encapsulated inside the message object.
command - The command to run once the operation is complete

joinGroup

public void joinGroup(PostGroupAddress address,
                      byte[] key)
This method causes the local POST service to subscribe to the specified address, and use the specified shared key in order to decrypt messages. If the key is null, then messages are assumed to be unencrypted. Incoming messages, once verified, will be passed up to the appropriate applciation through the notificationReceived() method.

Specified by:
joinGroup in interface Post
Parameters:
address - The address to join
key - The shared key to use (or null, if unencrypted)

sendGroup

public void sendGroup(NotificationMessage message,
                      Continuation command)
This method multicasts the provided notification message to the destination group. However, this local node *MUST* have already joined this group (through the joinGroup method) in order for this to work properly.

Specified by:
sendGroup in interface Post
Parameters:
message - The message to send
command - The command to execute once done

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getEnvironment

public Environment getEnvironment()
Description copied from interface: Post
Get the rice.environment.Environment.

Specified by:
getEnvironment in interface Post
Returns:
the environment

getInstance

public java.lang.String getInstance()
Returns:
the instance of post

ePOST API

Copyright © 2001-2005 - Rice Pastry.