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.past
Class PastImpl

    java.lang.Object
      rice.p2p.past.PastImpl

All Implemented Interfaces:
  Application, Past, ReplicationManagerClient

Direct Known Subclasses:
  GCPastImpl

    public class PastImpl

extends java.lang.Object
implements Past, Application, ReplicationManagerClient

Version:
  $Id: PastImpl.java 4654 2009-01-08 16:33:07Z jeffh $
Author:
  Alan Mislove, Ansley Post, Peter Druschel

Nested Class Summary
`static interface` | `PastImpl.MessageBuilder` Class which builds a message
`protected class` | `PastImpl.PastDeserializer`

Field Summary
`protected Cache` | `backup`
`protected PastContentDeserializer` | `contentDeserializer`
`protected PastContentHandleDeserializer` | `contentHandleDeserializer`
`protected Endpoint` | `endpoint`
`protected Environment` | `environment`
`protected IdFactory` | `factory`
`int` | `fetchHandles`
`int` | `inserts`
`protected java.lang.String` | `instance`
`protected LockManager` | `lockManager`
`protected Logger` | `logger`
`int` | `lookups`
`int` | `MESSAGE_TIMEOUT`
`int` | `other`
`protected PastPolicy` | `policy`
`protected ReplicationManager` | `replicaManager`
`protected int` | `replicationFactor`
`SocketStrategy` | `socketStrategy`
`protected StorageManager` | `storage`
`double` | `SUCCESSFUL_INSERT_THRESHOLD`
`protected StorageManager` | `trash`

Constructor Summary
`PastImpl(Node node, StorageManager manager, Cache backup, int replicas, java.lang.String instance, PastPolicy policy, StorageManager trash)`
`PastImpl(Node node, StorageManager manager, Cache backup, int replicas, java.lang.String instance, PastPolicy policy, StorageManager trash, boolean useOwnSocket)`
`PastImpl(Node node, StorageManager manager, Cache backup, int replicas, java.lang.String instance, PastPolicy policy, StorageManager trash, SocketStrategy strategy)` Constructor for Past
`PastImpl(Node node, StorageManager manager, int replicas, java.lang.String instance)` Constructor for Past, using the default policy
`PastImpl(Node node, StorageManager manager, int replicas, java.lang.String instance, PastPolicy policy)` Constructor for Past

Method Summary
`protected ReplicationManager` | `buildReplicationManager(Node node, java.lang.String instance)` Internal method which builds the replication manager.
`void` | `cache(PastContent content, Continuation command)` Method which inserts the given object into the cache
`void` | `deliver(Id id, Message message)` This method is called on the application at the destination node for the given id.
`protected void` | `doInsert(Id id, PastImpl.MessageBuilder builder, Continuation command, boolean useSocket)` Internal method which actually performs an insert for a given object.
`boolean` | `exists(Id id)` This upcall should return whether or not the given id is currently stored by the client.
`void` | `existsInOverlay(Id id, Continuation command)` This upcall should return whether or not the given id is currently stored somewhere in the overlay by the client.
`void` | `fetch(Id id, NodeHandle hint, Continuation command)` This upcall is invoked to tell the client to fetch the given id, and to call the given command with the boolean result once the fetch is completed.
`void` | `fetch(PastContentHandle handle, Continuation command)` Retrieves the object associated with a given content handle.
`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.
`Endpoint` | `getEndpoint()` Returns the endpoint associated with the Past - ONLY FOR TESTING - DO NOT USE
`Environment` | `getEnvironment()`
`protected Continuation` | `getFetchResponseContinuation(PastMessage msg)` Do like above, but use a socket
`protected void` | `getHandles(Id id, int max, Continuation command)` Internal method which returns the handles to an object.
`java.lang.String` | `getInstance()`
`NodeHandle` | `getLocalNodeHandle()` get the nodeHandle of the local Past node
`Continuation[]` | `getOutstandingMessages()` Returns of the outstanding messages.
`Replication` | `getReplication()` Returns the replica manager for this Past instance.
`int` | `getReplicationFactor()` Returns the number of replicas used in this Past
`protected Continuation` | `getResponseContinuation(PastMessage msg)` Returns a continuation which will respond to the given message.
`StorageManager` | `getStorageManager()` Returns this Past's storage manager.
`protected int` | `getUID()` Returns a new uid for a message
`void` | `insert(PastContent obj, Continuation command)` Inserts an object with the given ID into this instance of Past.
`void` | `lookup(Id id, boolean cache, Continuation command)` Method which performs the same as lookup(), but allows the callee to specify if the data should be cached.
`void` | `lookup(Id id, Continuation<PastContent,java.lang.Exception> command)` Retrieves the object stored in this instance of Past with the given ID.
`void` | `lookupHandle(Id id, NodeHandle handle, Continuation command)` Retrieves the handle for the given object stored on the requested node.
`void` | `lookupHandles(Id id, int max, Continuation command)` Retrieves the handles of up to max replicas of the object stored in this instance of Past with the given ID.
`void` | `reInsert(Id id, Continuation command)` Asks a client to reinsert an object it already holds into the overlay
`void` | `remove(Id id, Continuation command)` This upcall is to notify the client that the given id can be safely removed from the storage.
`IdSet` | `scan()` This upcall should return the set of keys that the application currently stores.
`IdSet` | `scan(IdRange range)` This upcall should return the set of keys that the application currently stores in this range.
`protected void` | `sendRequest(Id id, PastMessage message, Continuation command)` Sends a request message across the wire, and stores the appropriate continuation.
`protected void` | `sendRequest(Id id, PastMessage message, NodeHandle hint, Continuation command)` Sends a request message across the wire, and stores the appropriate continuation.
`protected void` | `sendRequest(NodeHandle handle, PastMessage message, Continuation command)` Sends a request message across the wire, and stores the appropriate continuation.
`void` | `setContentDeserializer(PastContentDeserializer deserializer)`
`void` | `setContentHandleDeserializer(PastContentHandleDeserializer deserializer)`
`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

### MESSAGE_TIMEOUT

    public final int MESSAGE_TIMEOUT

### SUCCESSFUL_INSERT_THRESHOLD

    public final double SUCCESSFUL_INSERT_THRESHOLD

### endpoint

    protected Endpoint endpoint

### storage

    protected StorageManager storage

### trash

    protected StorageManager trash

### backup

    protected Cache backup

### replicationFactor

    protected int replicationFactor

### replicaManager

    protected ReplicationManager replicaManager

### lockManager

    protected LockManager lockManager

### policy

    protected PastPolicy policy

### factory

    protected IdFactory factory

### instance

    protected java.lang.String instance

### inserts

    public int inserts

### lookups

    public int lookups

### fetchHandles

    public int fetchHandles

### other

    public int other

### environment

    protected Environment environment

### logger

    protected Logger logger

### contentDeserializer

    protected PastContentDeserializer contentDeserializer

### contentHandleDeserializer

    protected PastContentHandleDeserializer contentHandleDeserializer

### socketStrategy

    public SocketStrategy socketStrategy

Constructor Detail

### PastImpl

    public PastImpl(Node node,
                    StorageManager manager,
                    int replicas,
                    java.lang.String instance)

  Constructor for Past, using the default policy

  Parameters:
    `node` - The node below this Past implementation
    `manager` - The storage manager to be used by Past
    `replicas` - The number of object replicas
    `instance` - The unique instance name of this Past

### PastImpl

    public PastImpl(Node node,
                    StorageManager manager,
                    int replicas,
                    java.lang.String instance,
                    PastPolicy policy)

  Constructor for Past

  Parameters:
    `node` - The node below this Past implementation
    `manager` - The storage manager to be used by Past
    `replicas` - The number of object replicas
    `instance` - The unique instance name of this Past

### PastImpl

    public PastImpl(Node node,
                    StorageManager manager,
                    Cache backup,
                    int replicas,
                    java.lang.String instance,
                    PastPolicy policy,
                    StorageManager trash)

### PastImpl

    public PastImpl(Node node,
                    StorageManager manager,
                    Cache backup,
                    int replicas,
                    java.lang.String instance,
                    PastPolicy policy,
                    StorageManager trash,
                    boolean useOwnSocket)

Parameters:
  `node` -
  `manager` -
  `backup` -
  `replicas` -
  `instance` -
  `policy` -
  `trash` -
  `useOwnSocket` - send all inserts/fetches over a socket (default is false)

### PastImpl

    public PastImpl(Node node,
                    StorageManager manager,
                    Cache backup,
                    int replicas,
                    java.lang.String instance,
                    PastPolicy policy,
                    StorageManager trash,
                    SocketStrategy strategy)

  Constructor for Past

  Parameters:
    `node` - The node below this Past implementation
    `manager` - The storage manager to be used by Past
    `replicas` - The number of object replicas
    `instance` - The unique instance name of this Past

Method Detail

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getEnvironment

    public Environment getEnvironment()

  Specified by:
    `getEnvironment` in interface `Past`

### buildReplicationManager

    protected ReplicationManager buildReplicationManager(Node node,
                                                         java.lang.String instance)

  Internal method which builds the replication manager. Can be overridden by subclasses.

  Parameters:
    `node` - The node to base the RM off of
    `instance` - The instance name to use
  Returns:
    The replication manager, ready for use

### getOutstandingMessages

    public Continuation[] getOutstandingMessages()

  Returns of the outstanding messages. This is a DEBUGGING method ONLY!

  Returns:
    The list of all the outstanding messages

### getEndpoint

    public Endpoint getEndpoint()

  Returns the endpoint associated with the Past - ONLY FOR TESTING - DO NOT USE

  Returns:
    The endpoint

### getUID

    protected int getUID()

  Returns a new uid for a message

  Returns:
    A new id

### getResponseContinuation

    protected Continuation getResponseContinuation(PastMessage msg)

  Returns a continuation which will respond to the given message.

  Returns:
    A new id

### getFetchResponseContinuation

    protected Continuation getFetchResponseContinuation(PastMessage msg)

  Do like above, but use a socket

  Parameters:
    `msg` -
  Returns:

### sendRequest

    protected void sendRequest(Id id,
                               PastMessage message,
                               Continuation command)

  Sends a request message across the wire, and stores the appropriate continuation.

  Parameters:
    `id` - The destination id
    `message` - The message to send.
    `command` - The command to run once a result is received

### sendRequest

    protected void sendRequest(NodeHandle handle,
                               PastMessage message,
                               Continuation command)

  Sends a request message across the wire, and stores the appropriate continuation.

  Parameters:
    `handle` - The node handle to send directly too
    `message` - The message to send.
    `command` - The command to run once a result is received

### sendRequest

    protected void sendRequest(Id id,
                               PastMessage message,
                               NodeHandle hint,
                               Continuation command)

  Sends a request message across the wire, and stores the appropriate continuation. Sends the message using the provided handle as a hint.

  Parameters:
    `id` - The destination id
    `message` - The message to send.
    `handle` - The first hop hint
    `command` - The command to run once a result is received

### getHandles

    protected void getHandles(Id id,
                              int max,
                              Continuation command)

  Internal method which returns the handles to an object. It first checks to see if the handles can be determined locally, and if so, returns. Otherwise, it sends a LookupHandles messsage out to find out the nodes.

  Parameters:
    `id` - The id to fetch the handles for
    `max` - The maximum number of handles to return
    `command` - The command to call with the result (NodeHandle[])

### cache

    public void cache(PastContent content,
                      Continuation command)

  Method which inserts the given object into the cache

  Parameters:
    `content` - The content to cache
    `command` - The command to run once done

### doInsert

    protected void doInsert(Id id,
                            PastImpl.MessageBuilder builder,
                            Continuation command,
                            boolean useSocket)

  Internal method which actually performs an insert for a given object. Here so that subclasses can override the types of insert messages which are sent across the wire.

  Parameters:
    `obj` - The object to insert
    `builder` - The object which builds the messages
    `command` - The command to call once done

### insert

    public void insert(PastContent obj,
                       Continuation command)

  Inserts an object with the given ID into this instance of Past. Asynchronously returns a PastException to command, if the operation was unsuccessful. If the operation was successful, a Boolean[] is returned representing the responses from each of the replicas which inserted the object.

  Specified by:
    `insert` in interface `Past`
  Parameters:
    `obj` - the object to be inserted
    `command` - Command to be performed when the result is received

### lookup

    public void lookup(Id id,
                       Continuation<PastContent,java.lang.Exception> command)

  Retrieves the object stored in this instance of Past with the given ID. Asynchronously returns a PastContent object as the result to the provided Continuation, or a PastException. This method is provided for convenience; its effect is identical to a lookupHandles() and a subsequent fetch() to the handle that is nearest in the network. The client must authenticate the object. In case of failure, an alternate replica of the object can be obtained via lookupHandles() and fetch(). This method is not safe if the object is immutable and storage nodes are not trusted. In this case, clients should used the lookUpHandles method to obtains the handles of all primary replicas and determine which replica is fresh in an application-specific manner.

  Specified by:
    `lookup` in interface `Past`
  Parameters:
    `id` - the key to be queried
    `command` - Command to be performed when the result is received

### lookup

    public void lookup(Id id,
                       boolean cache,
                       Continuation command)

  Method which performs the same as lookup(), but allows the callee to specify if the data should be cached.

  Specified by:
    `lookup` in interface `Past`
  Parameters:
    `id` - the key to be queried
    `cache` - Whether or not the data should be cached
    `command` - Command to be performed when the result is received

### lookupHandles

    public void lookupHandles(Id id,
                              int max,
                              Continuation command)

  Retrieves the handles of up to max replicas of the object stored in this instance of Past with the given ID. Asynchronously returns an array of PastContentHandles as the result to the provided Continuation, or a PastException. Each replica handle is obtained from a different primary storage root for the the given key. If max exceeds the replication factor r of this Past instance, only r replicas are returned. This method will return a PastContentHandle[] array containing all of the handles.

  Specified by:
    `lookupHandles` in interface `Past`
  Parameters:
    `id` - the key to be queried
    `max` - the maximal number of replicas requested
    `command` - Command to be performed when the result is received

### lookupHandle

    public void lookupHandle(Id id,
                             NodeHandle handle,
                             Continuation command)

  Retrieves the handle for the given object stored on the requested node. Asynchronously returns a PostContentHandle (or null) to the provided continuation.

  Specified by:
    `lookupHandle` in interface `Past`
  Parameters:
    `id` - the key to be queried
    `handle` - The node on which the handle is requested
    `command` - Command to be performed when the result is received

### fetch

    public void fetch(PastContentHandle handle,
                      Continuation command)

  Retrieves the object associated with a given content handle. Asynchronously returns a PastContent object as the result to the provided Continuation, or a PastException. The client must authenticate the object. In case of failure, an alternate replica can be obtained using a different handle obtained via lookupHandles().

  Specified by:
    `fetch` in interface `Past`
  Parameters:
    `id` - the key to be queried
    `command` - Command to be performed when the result is received

### getLocalNodeHandle

    public NodeHandle getLocalNodeHandle()

  get the nodeHandle of the local Past node

  Specified by:
    `getLocalNodeHandle` in interface `Past`
  Returns:
    the nodehandle

### getReplicationFactor

    public int getReplicationFactor()

  Returns the number of replicas used in this Past

  Specified by:
    `getReplicationFactor` in interface `Past`
  Returns:
    the number of replicas for each object

### 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

### deliver

    public void deliver(Id id,
                        Message message)

  This method is called on the application at the destination node for the given id.

  Specified by:
    `deliver` in interface `Application`
  Parameters:
    `id` - The destination id of the message
    `message` - The message being sent

### 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

### fetch

    public void fetch(Id id,
                      NodeHandle hint,
                      Continuation command)

  This upcall is invoked to tell the client to fetch the given id, and to call the given command with the boolean result once the fetch is completed. The client *MUST* call the command at some point in the future, as the manager waits for the command to return before continuing.

  Specified by:
    `fetch` in interface `ReplicationManagerClient`
  Parameters:
    `id` - The id to fetch
    `hint` - A hint where to find the key from. This is where the local node heard about the key.
    `command` - The command to return the result to

### remove

    public void remove(Id id,
                       Continuation command)

  This upcall is to notify the client that the given id can be safely removed from the storage. The client may choose to perform advanced behavior, such as caching the object, or may simply delete it.

  Specified by:
    `remove` in interface `ReplicationManagerClient`
  Parameters:
    `id` - The id to remove

### scan

    public IdSet scan(IdRange range)

  This upcall should return the set of keys that the application currently stores in this range. Should return a empty IdSet (not null), in the case that no keys belong to this range.

  Specified by:
    `scan` in interface `ReplicationManagerClient`
  Parameters:
    `range` - the requested range

### scan

    public IdSet scan()

  This upcall should return the set of keys that the application currently stores. Should return a empty IdSet (not null), in the case that no keys belong to this range.

  Parameters:
    `range` - the requested range

### exists

    public boolean exists(Id id)

  This upcall should return whether or not the given id is currently stored by the client.

  Specified by:
    `exists` in interface `ReplicationManagerClient`
  Parameters:
    `id` - The id in question
  Returns:
    Whether or not the id exists

### existsInOverlay

    public void existsInOverlay(Id id,
                                Continuation command)

  Description copied from interface: `ReplicationManagerClient`
  This upcall should return whether or not the given id is currently stored somewhere in the overlay by the client.

  Specified by:
    `existsInOverlay` in interface `ReplicationManagerClient`
  Parameters:
    `id` - The id in question

### reInsert

    public void reInsert(Id id,
                         Continuation command)

  Description copied from interface: `ReplicationManagerClient`
  Asks a client to reinsert an object it already holds into the overlay

  Specified by:
    `reInsert` in interface `ReplicationManagerClient`
  Parameters:
    `id` - The id in question

### getReplication

    public Replication getReplication()

  Returns the replica manager for this Past instance. Should *ONLY* be used for testing. Messing with this will cause unknown behavior.

  Returns:
    This Past's replica manager

### getStorageManager

    public StorageManager getStorageManager()

  Returns this Past's storage manager. Should *ONLY* be used for testing. Messing with this will cause unknown behavior.

  Returns:
    This Past's storage manager.

### getInstance

    public java.lang.String getInstance()

  Specified by:
    `getInstance` in interface `Past`
  Returns:

### setContentDeserializer

    public void setContentDeserializer(PastContentDeserializer deserializer)

  Specified by:
    `setContentDeserializer` in interface `Past`

### setContentHandleDeserializer

    public void setContentHandleDeserializer(PastContentHandleDeserializer deserializer)

  Specified by:
    `setContentHandleDeserializer` in interface `Past`

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.