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,v 1.45 2005/06/03 00:05:42 jeffh Exp $
Author:
  Alan Mislove, Ansley Post, Peter Druschel

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

Field Summary
`protected Cache` | `backup` DESCRIBE THE FIELD
`protected Endpoint` | `endpoint` DESCRIBE THE FIELD
`protected Environment` | `environment` DESCRIBE THE FIELD
`protected IdFactory` | `factory` DESCRIBE THE FIELD
`int` | `fetchHandles` DESCRIBE THE FIELD
`int` | `inserts` DESCRIBE THE FIELD
`protected java.lang.String` | `instance` DESCRIBE THE FIELD
`protected java.util.logging.Logger` | `log` DESCRIBE THE FIELD
`int` | `lookups` DESCRIBE THE FIELD
`static int` | `MESSAGE_TIMEOUT` DESCRIBE THE FIELD
`int` | `other` DESCRIBE THE FIELD
`protected PastPolicy` | `policy` DESCRIBE THE FIELD
`protected ReplicationManager` | `replicaManager` DESCRIBE THE FIELD
`protected int` | `replicationFactor` DESCRIBE THE FIELD
`protected StorageManager` | `storage` DESCRIBE THE FIELD
`static double` | `SUCCESSFUL_INSERT_THRESHOLD` DESCRIBE THE FIELD
`protected StorageManager` | `trash` DESCRIBE THE FIELD
`static boolean` | `verbose` DESCRIBE THE FIELD

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

Method Summary
`protected ReplicationManager` | `buildReplicationManager(Node node, java.lang.String instance, Environment env)` 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)` 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` | `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()` Gets the Environment attribute of the PastImpl object
`protected void` | `getHandles(Id id, int max, Continuation command)` Internal method which returns the handles to an object.
`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 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` | `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` | `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, toString, wait, wait, wait`

Field Detail

### endpoint

    protected Endpoint endpoint

  DESCRIBE THE FIELD

### storage

    protected StorageManager storage

  DESCRIBE THE FIELD

### trash

    protected StorageManager trash

  DESCRIBE THE FIELD

### backup

    protected Cache backup

  DESCRIBE THE FIELD

### replicationFactor

    protected int replicationFactor

  DESCRIBE THE FIELD

### replicaManager

    protected ReplicationManager replicaManager

  DESCRIBE THE FIELD

### policy

    protected PastPolicy policy

  DESCRIBE THE FIELD

### factory

    protected IdFactory factory

  DESCRIBE THE FIELD

### log

    protected java.util.logging.Logger log

  DESCRIBE THE FIELD

### instance

    protected java.lang.String instance

  DESCRIBE THE FIELD

### inserts

    public int inserts

  DESCRIBE THE FIELD

### lookups

    public int lookups

  DESCRIBE THE FIELD

### fetchHandles

    public int fetchHandles

  DESCRIBE THE FIELD

### other

    public int other

  DESCRIBE THE FIELD

### environment

    protected Environment environment

  DESCRIBE THE FIELD

### verbose

    public static final boolean verbose

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### MESSAGE_TIMEOUT

    public static int MESSAGE_TIMEOUT

  DESCRIBE THE FIELD

### SUCCESSFUL_INSERT_THRESHOLD

    public static double SUCCESSFUL_INSERT_THRESHOLD

  DESCRIBE THE FIELD

Constructor Detail

### PastImpl

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

  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
  `env` - DESCRIBE THE PARAMETER

### PastImpl

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

  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
  `policy` - DESCRIBE THE PARAMETER
  `env` - DESCRIBE THE PARAMETER

### PastImpl

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

  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
  `backup` - DESCRIBE THE PARAMETER
  `policy` - DESCRIBE THE PARAMETER
  `trash` - DESCRIBE THE PARAMETER
  `env` - DESCRIBE THE PARAMETER

Method Detail

### getEnvironment

    public Environment getEnvironment()

  Gets the Environment attribute of the PastImpl object

  Specified by:
    `getEnvironment` in interface `Past`
  Returns:
    The Environment value

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

  Parameters:
    `msg` - DESCRIBE THE PARAMETER
  Returns:
    A new id

### 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[])

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

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

### buildReplicationManager

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

  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
    `env` - DESCRIBE THE PARAMETER
  Returns:
    The replication manager, ready for use

### 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.
    `command` - The command to run once a result is received
    `hint` - DESCRIBE THE PARAMETER

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

  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:
    `builder` - The object which builds the messages
    `command` - The command to call once done
    `id` - DESCRIBE THE PARAMETER

### 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 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:
    `command` - Command to be performed when the result is received
    `handle` - DESCRIBE THE PARAMETER

### 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` - DESCRIBE THE PARAMETER
    `command` - DESCRIBE THE PARAMETER

### 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
    `command` - DESCRIBE THE PARAMETER

### 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
  Returns:
    DESCRIBE THE RETURN VALUE

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

  Returns:
    DESCRIBE THE RETURN VALUE

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

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.