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.gc
Class GCPastImpl

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

All Implemented Interfaces:
  Application, GCPast, Past, ReplicationManagerClient

    public class GCPastImpl

extends PastImpl
implements GCPast

Version:
  $Id: GCPastImpl.java 4654 2009-01-08 16:33:07Z jeffh $
Author:
  Alan Mislove, Andreas Haeberlen

Nested Class Summary
`protected class` | `GCPastImpl.GCPastDeserializer`
`protected class` | `GCPastImpl.ReplicaMap`

Nested classes/interfaces inherited from class rice.p2p.past.PastImpl
`PastImpl.MessageBuilder, PastImpl.PastDeserializer`

Field Summary
`int` | `collected`
`static long` | `DEFAULT_EXPIRATION` The default expiration, or when objects inserted with no timeout will expire
`protected IdFactory` | `realFactory` The real factory, which is not wrapped with a GCIdFactory
`int` | `refreshed`

Fields inherited from class rice.p2p.past.PastImpl
`backup, contentDeserializer, contentHandleDeserializer, endpoint, environment, factory, fetchHandles, inserts, instance, lockManager, logger, lookups, MESSAGE_TIMEOUT, other, policy, replicaManager, replicationFactor, socketStrategy, storage, SUCCESSFUL_INSERT_THRESHOLD, trash`

Fields inherited from interface rice.p2p.past.gc.GCPast
`INFINITY_EXPIRATION`

Constructor Summary
`GCPastImpl(Node node, StorageManager manager, Cache backup, int replicas, java.lang.String instance, PastPolicy policy, long collectionInterval, StorageManager trash)` Constructor for GCPast
`GCPastImpl(Node node, StorageManager manager, int replicas, java.lang.String instance, PastPolicy policy, long collectionInterval)` Constructor for GCPast

Method Summary
`protected void` | `collect(java.util.SortedMap map, Continuation command)` Internal method which collects all of the objects in the given set
`void` | `deliver(Id id, Message message)` This method is called on the application at the destination node for the given id.
`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.
`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` | `insert(PastContent obj, Continuation command)` Inserts an object with the given ID into this instance of Past.
`void` | `insert(PastContent obj, long expiration, Continuation command)` Inserts an object with the given ID into this instance of Past.
`protected void` | `refresh(GCIdSet ids, Continuation command)` Internal method which actually does the refreshing.
`void` | `refresh(Id[] array, long[] expirations, Continuation command)` Updates the objects stored under the provided keys id to expire no earlier than the provided expiration time.
`void` | `refresh(Id[] array, long expiration, Continuation command)` Updates the objects stored under the provided keys id to expire no earlier than the provided expiration time.
`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.
`java.lang.String` | `toString()`

Methods inherited from class rice.p2p.past.PastImpl
`buildReplicationManager, cache, doInsert, fetch, getEndpoint, getEnvironment, getFetchResponseContinuation, getHandles, getInstance, getLocalNodeHandle, getOutstandingMessages, getReplication, getReplicationFactor, getResponseContinuation, getStorageManager, getUID, lookup, lookup, lookupHandle, lookupHandles, sendRequest, sendRequest, sendRequest, setContentDeserializer, setContentHandleDeserializer, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface rice.p2p.past.Past
`fetch, getEnvironment, getInstance, getLocalNodeHandle, getReplicationFactor, lookup, lookup, lookupHandle, lookupHandles, setContentDeserializer, setContentHandleDeserializer`

Field Detail

### DEFAULT_EXPIRATION

    public static final long DEFAULT_EXPIRATION

  The default expiration, or when objects inserted with no timeout will expire

  See Also:
    Constant Field Values

### realFactory

    protected IdFactory realFactory

  The real factory, which is not wrapped with a GCIdFactory

### collected

    public int collected

### refreshed

    public int refreshed

Constructor Detail

### GCPastImpl

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

  Constructor for GCPast

  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` - The policy this past instance should use
    `collectionInterval` - The frequency with which GCPast should collection local expired objects

### GCPastImpl

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

  Constructor for GCPast

  Parameters:
    `node` - The node below this Past implementation
    `manager` - The storage manager to be used by Past
    `backup` - The cache used for previously-responsible objects (can be null)
    `replicas` - The number of object replicas
    `instance` - The unique instance name of this Past
    `trash` - The storage manager to place the deleted objects into (if null, they are removed)
    `policy` - The policy this past instance should use
    `collectionInterval` - The frequency with which GCPast should collection local expired objects

Method Detail

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `PastImpl`

### 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. This method is equivalent to insert(obj, INFINITY_EXPIRATION, command) as it inserts the object with a timeout value of infinity. This is done for simplicity, as well as backwards-compatibility for applications.

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

### insert

    public void insert(PastContent obj,
                       long expiration,
                       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. The contract for this method is that the provided object will be stored until the provided expiration time. Thus, if the application determines that it is still interested in this object, it must refresh the object via the refresh() method.

  Specified by:
    `insert` in interface `GCPast`
  Parameters:
    `obj` - the object to be inserted
    `expiration` - the time until which the object must be stored
    `command` - Command to be performed when the result is received

### refresh

    public void refresh(Id[] array,
                        long expiration,
                        Continuation command)

  Updates the objects stored under the provided keys id to expire no earlier than the provided expiration time. Asyncroniously returns the result to the caller via the provided continuation. The result of this operation is an Object[], which is the same length as the input array of Ids. Each element in the array is either Boolean(true), representing that the refresh succeeded for the cooresponding Id, or an Exception describing why the refresh failed. Specifically, the possible exceptions which can be returned are: ObjectNotFoundException - if no object was found under the given key RefreshFailedException - if the refresh operation failed for any other reason (the getMessage() will describe the failure)

  Specified by:
    `refresh` in interface `GCPast`
  Parameters:
    `id` - The keys which to refresh
    `expiration` - The time to extend the lifetime to
    `command` - Command to be performed when the result is received

### refresh

    public void refresh(Id[] array,
                        long[] expirations,
                        Continuation command)

  Updates the objects stored under the provided keys id to expire no earlier than the provided expiration time. Asyncroniously returns the result to the caller via the provided continuation. The result of this operation is an Object[], which is the same length as the input array of Ids. Each element in the array is either Boolean(true), representing that the refresh succeeded for the cooresponding Id, or an Exception describing why the refresh failed. Specifically, the possible exceptions which can be returned are: ObjectNotFoundException - if no object was found under the given key RefreshFailedException - if the refresh operation failed for any other reason (the getMessage() will describe the failure)

  Specified by:
    `refresh` in interface `GCPast`
  Parameters:
    `id` - The keys which to refresh
    `expiration` - The time to extend the lifetime to
    `command` - Command to be performed when the result is received

### refresh

    protected void refresh(GCIdSet ids,
                           Continuation command)

  Internal method which actually does the refreshing. Should not be called by external applications.

  Parameters:
    `ids` - The ids to refresh
    `expiration` - The time to extend the lifetime until
    `command` - The command to return the result to

### 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`
  Overrides:
    `forward` in class `PastImpl`
  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`
  Overrides:
    `deliver` in class `PastImpl`
  Parameters:
    `id` - The destination id of the message
    `message` - The message being sent

### collect

    protected void collect(java.util.SortedMap map,
                           Continuation command)

  Internal method which collects all of the objects in the given set

  Parameters:
    `set` - THe set to collect
    `command` - The command to call once done

### 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`
  Overrides:
    `fetch` in class `PastImpl`
  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`
  Overrides:
    `remove` in class `PastImpl`
  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`
  Overrides:
    `scan` in class `PastImpl`
  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.

  Overrides:
    `scan` in class `PastImpl`
  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`
  Overrides:
    `exists` in class `PastImpl`
  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`
  Overrides:
    `existsInOverlay` in class `PastImpl`
  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`
  Overrides:
    `reInsert` in class `PastImpl`
  Parameters:
    `id` - The id in question

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.