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.aggregation
Class AggregationImpl

    java.lang.Object
      rice.p2p.aggregation.AggregationImpl

All Implemented Interfaces:
  Aggregation, Application, VersioningPast, GCPast, Past, DebugCommandHandler

    public class AggregationImpl

extends java.lang.Object
implements GCPast, VersioningPast, Aggregation, Application, DebugCommandHandler

Field Summary
`protected AggregateFactory` | `aggregateFactory`
`protected AggregateList` | `aggregateList`
`protected Past` | `aggregateStore`
`protected PastContentDeserializer` | `contentDeserializer`
`protected PastContentHandleDeserializer` | `contentHandleDeserializer`
`protected Endpoint` | `endpoint`
`protected IdFactory` | `factory`
`protected Continuation` | `flushWait`
`protected java.lang.String` | `instance`
`protected Logger` | `logger`
`protected java.util.Vector` | `monitorIDs`
`protected Node` | `node`
`protected Past` | `objectStore`
`protected AggregationPolicy` | `policy`
`protected boolean` | `rebuildInProgress`
`protected AggregationStatistics` | `stats`
`protected java.util.Hashtable` | `timers`
`protected StorageManager` | `waitingList`

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

Constructor Summary
`AggregationImpl(Node node, Past aggregateStore, Past objectStore, StorageManager waitingList, java.lang.String configFileName, IdFactory factory, java.lang.String instance)`
`AggregationImpl(Node node, Past aggregateStore, Past objectStore, StorageManager waitingList, java.lang.String configFileName, IdFactory factory, java.lang.String instance, AggregationPolicy policy, AggregateFactory aggregateFactory)`

Method Summary
`void` | `deliver(Id id, Message message)` This method is called on the application at the destination node for the given id.
`void` | `fetch(PastContentHandle handle, Continuation command)` Retrieves the object associated with a given content handle.
`void` | `flush(Continuation command)` Creates aggregates from all objects in the local object cache.
`void` | `flush(Id id, Continuation command)` Creates an aggregate that includes the most current object with the specified key.
`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.
`Past` | `getAggregateStore()`
`Environment` | `getEnvironment()`
`java.io.Serializable` | `getHandle()` Fetches the handle object.
`java.lang.String` | `getInstance()`
`NodeHandle` | `getLocalNodeHandle()` get the nodeHandle of the local Past node
`int` | `getNumObjectsWaiting()`
`Past` | `getObjectStore()`
`int` | `getReplicationFactor()` Returns the number of replicas used in this Past
`AggregationStatistics` | `getStatistics()`
`java.lang.String` | `handleDebugCommand(java.lang.String command)`
`void` | `insert(PastContent obj, Continuation command)` Inserts an object with the given ID into this instance of Past.
`void` | `insert(PastContent obj, long lifetime, Continuation command)` Inserts an object with the given ID into this instance of Past.
`void` | `lookup(Id id, boolean cache, Continuation command)` Retrieves the object stored in this instance of Past with the given ID.
`void` | `lookup(Id id, Continuation command)` Retrieves the object stored in this instance of Past with the given ID.
`void` | `lookup(Id id, long version, Continuation command)` Retrieves the object stored in this instance of Past with the given ID and the specified version.
`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` | `lookupHandles(Id id, long version, 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` | `refresh(Id[] ids, 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[] ids, long[] versions, 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[] ids, long expiration, Continuation command)` Updates the objects stored under the provided keys id to expire no earlier than the provided expiration time.
`void` | `reset(Continuation command)` Deletes all local state, including the aggregate list and all objects waiting in the local buffer.
`void` | `rollback(Id id, Continuation command)` Attempts to retrieve the most recent object that has been inserted by the local node under the specified key.
`void` | `setConsolidationInterval(long consolidationIntervalSec)`
`void` | `setConsolidationMinObjectsPerAggregate(int minObjectsInAggregateArg)`
`void` | `setConsolidationMinUtilization(double minUtilization)`
`void` | `setConsolidationThreshold(long consolidationThresholdSec)`
`void` | `setContentDeserializer(PastContentDeserializer deserializer)`
`void` | `setContentHandleDeserializer(PastContentHandleDeserializer deserializer)`
`void` | `setFlushInterval(int flushIntervalSec)`
`void` | `setHandle(java.io.Serializable handle, Continuation command)` Restores the handle object.
`void` | `setMaxAggregateSize(int maxAggregateSize)`
`void` | `setMaxObjectsInAggregate(int maxObjectsInAggregate)`
`void` | `setRenewThreshold(int expirationRenewThresholdHrs)`
`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

### aggregateStore

    protected final Past aggregateStore

### waitingList

    protected final StorageManager waitingList

### policy

    protected final AggregationPolicy policy

### aggregateList

    protected final AggregateList aggregateList

### endpoint

    protected final Endpoint endpoint

### objectStore

    protected final Past objectStore

### instance

    protected final java.lang.String instance

### factory

    protected final IdFactory factory

### node

    protected final Node node

### timers

    protected java.util.Hashtable timers

### flushWait

    protected Continuation flushWait

### rebuildInProgress

    protected boolean rebuildInProgress

### monitorIDs

    protected java.util.Vector monitorIDs

### stats

    protected AggregationStatistics stats

### logger

    protected Logger logger

### contentDeserializer

    protected PastContentDeserializer contentDeserializer

### contentHandleDeserializer

    protected PastContentHandleDeserializer contentHandleDeserializer

### aggregateFactory

    protected AggregateFactory aggregateFactory

Constructor Detail

### AggregationImpl

    public AggregationImpl(Node node,
                           Past aggregateStore,
                           Past objectStore,
                           StorageManager waitingList,
                           java.lang.String configFileName,
                           IdFactory factory,
                           java.lang.String instance)
                    throws java.io.IOException

Throws:
  `java.io.IOException`

### AggregationImpl

    public AggregationImpl(Node node,
                           Past aggregateStore,
                           Past objectStore,
                           StorageManager waitingList,
                           java.lang.String configFileName,
                           IdFactory factory,
                           java.lang.String instance,
                           AggregationPolicy policy,
                           AggregateFactory aggregateFactory)
                    throws java.io.IOException

Throws:
  `java.io.IOException`

Method Detail

### handleDebugCommand

    public java.lang.String handleDebugCommand(java.lang.String command)

  Specified by:
    `handleDebugCommand` in interface `DebugCommandHandler`

### refresh

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

  Description copied from interface: `GCPast`
  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`
    `expiration` - The time to extend the lifetime to (applies to all keys)
    `command` - Command to be performed when the result is received

### refresh

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

  Description copied from interface: `GCPast`
  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`
    `expirations` - The time to extend the lifetime to
    `command` - Command to be performed when the result is received

### refresh

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

  Description copied from interface: `VersioningPast`
  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 `VersioningPast`
    `command` - Command to be performed when the result is received

### getHandle

    public java.io.Serializable getHandle()

  Description copied from interface: `Aggregation`
  Fetches the handle object. This object is important in the event of a failure that causes Aggregation to lose its local metadata cache. When the handle object is later restored via setHandle(), Aggregation can recover all objects that have been aggregated prior to the getHandle() call, except objects that have already expired. Note that this does not include objects that were still in the local buffer when the failure occurred. To prevent data loss, it is recommended to invoke flush() before fetching the handle object.

  Specified by:
    `getHandle` in interface `Aggregation`
  Returns:
    the current handle object

### setHandle

    public void setHandle(java.io.Serializable handle,
                          Continuation command)

  Description copied from interface: `Aggregation`
  Restores the handle object. This method should always be invoked at startup, using the most current handle object available. When the continuation is invoked, all non-expired objects linked to the handle are accessible from the local node.

  Specified by:
    `setHandle` in interface `Aggregation`
  Parameters:
    `handle` - the handle object
    `command` - Command to be performed when the method completes.

### insert

    public void insert(PastContent obj,
                       Continuation command)

  Description copied from interface: `GCPast`
  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`
  Parameters:
    `obj` - the object to be inserted
    `command` - Command to be performed when the result is received

### insert

    public void insert(PastContent obj,
                       long lifetime,
                       Continuation command)

  Description copied from interface: `GCPast`
  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
    `lifetime` - the time until which the object must be stored
    `command` - Command to be performed when the result is received

### lookup

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

  Description copied from interface: `Past`
  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. This method also allows applications to specify if the result should be cached locally.

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

### lookup

    public void lookup(Id id,
                       long version,
                       Continuation command)

  Description copied from interface: `VersioningPast`
  Retrieves the object stored in this instance of Past with the given ID and the specified version. Asynchronously returns a PastContent object as the result to the provided Continuation, or a PastException.

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

### lookup

    public void lookup(Id id,
                       Continuation command)

  Description copied from interface: `Past`
  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. By default, this method attempts to cache the result locally for future use. Applications which do not desire this behavior should use the lookup(id, boolean, command) method.

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

### lookupHandles

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

  Description copied from interface: `VersioningPast`
  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 `VersioningPast`
  Parameters:
    `id` - the key to be queried
    `version` - the requested version
    `command` - Command to be performed when the result is received

### lookupHandle

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

  Description copied from interface: `Past`
  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

### lookupHandles

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

  Description copied from interface: `Past`
  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

### fetch

    public void fetch(PastContentHandle handle,
                      Continuation command)

  Description copied from interface: `Past`
  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:
    `handle` - the key to be queried
    `command` - Command to be performed when the result is received

### flush

    public void flush(Id id,
                      Continuation command)

  Description copied from interface: `Aggregation`
  Creates an aggregate that includes the most current object with the specified key. When the continuation is invoked, the object is persistent and linked to the current handle object.

  Specified by:
    `flush` in interface `Aggregation`
  Parameters:
    `id` - the key of the object to be made persistent.
    `command` - Command to be performed when the method completes.

### flush

    public void flush(Continuation command)

  Description copied from interface: `Aggregation`
  Creates aggregates from all objects in the local object cache. When the continuation is invoked, all objects that were inserted prior to flush() are persistent and linked to the current handle object.

  Specified by:
    `flush` in interface `Aggregation`
  Parameters:
    `command` - Command to be performed when the method completes.

### rollback

    public void rollback(Id id,
                         Continuation command)

  Description copied from interface: `Aggregation`
  Attempts to retrieve the most recent object that has been inserted by the local node under the specified key. This is useful when the object has been overwritten by an attacker. This method may fail or return an outdated version of the object if a) the object is not linked to the current handle, or b) the object was never aggregated because of the aggregation policy.

  Specified by:
    `rollback` in interface `Aggregation`
  Parameters:
    `id` - the key of the object to be retrieved
    `command` - Command to be performed when the method completes.

### reset

    public void reset(Continuation command)

  Description copied from interface: `Aggregation`
  Deletes all local state, including the aggregate list and all objects waiting in the local buffer. This is useful when the local instance appears to have been corrupted or tampered with. The state can be recovered by invoking setHandle() with an earlier handle object, and by using rollback() on objects that appear to have been overwritten.

  Specified by:
    `reset` in interface `Aggregation`
  Parameters:
    `command` - Command to be performed when the method completes.

### getLocalNodeHandle

    public NodeHandle getLocalNodeHandle()

  Description copied from interface: `Past`
  get the nodeHandle of the local Past node

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

### getReplicationFactor

    public int getReplicationFactor()

  Description copied from interface: `Past`
  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)

  Description copied from interface: `Application`
  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)

  Description copied from interface: `Application`
  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(Id id,
                        Message message)

  Description copied from interface: `Application`
  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

### setFlushInterval

    public void setFlushInterval(int flushIntervalSec)

### setMaxAggregateSize

    public void setMaxAggregateSize(int maxAggregateSize)

### setMaxObjectsInAggregate

    public void setMaxObjectsInAggregate(int maxObjectsInAggregate)

### setRenewThreshold

    public void setRenewThreshold(int expirationRenewThresholdHrs)

### setConsolidationInterval

    public void setConsolidationInterval(long consolidationIntervalSec)

### setConsolidationThreshold

    public void setConsolidationThreshold(long consolidationThresholdSec)

### setConsolidationMinObjectsPerAggregate

    public void setConsolidationMinObjectsPerAggregate(int minObjectsInAggregateArg)

### setConsolidationMinUtilization

    public void setConsolidationMinUtilization(double minUtilization)

### getAggregateStore

    public Past getAggregateStore()

### getObjectStore

    public Past getObjectStore()

### getNumObjectsWaiting

    public int getNumObjectsWaiting()

### getStatistics

    public AggregationStatistics getStatistics()

### getInstance

    public java.lang.String getInstance()

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

### getEnvironment

    public Environment getEnvironment()

  Specified by:
    `getEnvironment` in interface `Past`

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