Rice Pastry API

rice.p2p.aggregation
Class Moraine

java.lang.Object
  extended by rice.p2p.aggregation.Moraine
All Implemented Interfaces:
VersioningPast, GCPast, Past

public class Moraine
extends java.lang.Object
implements GCPast, VersioningPast

This Past takes 2 pasts, an old Past and a new Past. It treats the old Past as a backing store for the new Past. Pretty much it's only going to work with glacier, and maybe aggregation A Moraine is the hill of rubble (aggregate as it were) left behind at the edges of a glacier or at the end of a retreating glacier

Author:
jstewart

Field Summary
protected  Logger logger
           
protected  GCPast newPast
           
protected  GCPast oldPast
           
protected  VersioningPast vNewPast
           
protected  VersioningPast vOldPast
           
 
Fields inherited from interface rice.p2p.past.gc.GCPast
INFINITY_EXPIRATION
 
Constructor Summary
Moraine(GCPast newPast, GCPast oldPast)
           
 
Method Summary
 void fetch(PastContentHandle handle, Continuation command)
          Retrieves the object associated with a given content handle.
 Environment getEnvironment()
           
 java.lang.String getInstance()
           
 NodeHandle getLocalNodeHandle()
          get the nodeHandle of the local Past node
 int getReplicationFactor()
          Returns the number of replicas used in this Past
 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.
 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 num, 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 setContentDeserializer(PastContentDeserializer deserializer)
           
 void setContentHandleDeserializer(PastContentHandleDeserializer deserializer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

newPast

protected GCPast newPast

oldPast

protected GCPast oldPast

vNewPast

protected VersioningPast vNewPast

vOldPast

protected VersioningPast vOldPast

logger

protected Logger logger
Constructor Detail

Moraine

public Moraine(GCPast newPast,
               GCPast oldPast)
Method Detail

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

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

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

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

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

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

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

getEnvironment

public Environment getEnvironment()
Specified by:
getEnvironment in interface Past

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

insert

public void insert(PastContent obj,
                   long expiration,
                   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
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[] 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 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

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

lookupHandles

public void lookupHandles(Id id,
                          long version,
                          int num,
                          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

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

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection