ePOST API

rice.p2p.glacier.v2
Class GlacierImpl

java.lang.Object
  extended by rice.p2p.glacier.v2.GlacierImpl
All Implemented Interfaces:
Application, Glacier, VersioningPast, GCPast, Past, DebugCommandHandler

public class GlacierImpl
extends java.lang.Object
implements Glacier, Past, GCPast, VersioningPast, Application, DebugCommandHandler


Field Summary
protected  long bucketConsumed
           
protected  long bucketLastUpdated
           
protected  long bucketMax
           
protected  long bucketMin
           
protected  java.util.Hashtable continuations
           
protected  long currentFragmentRequestTimeout
           
protected  Endpoint endpoint
           
protected  IdFactory factory
           
protected  StorageManager fragmentStorage
           
protected  java.lang.String instance
           
protected  java.util.Vector listeners
           
protected  Logger logger
           
protected  StorageManager neighborStorage
           
protected  long nextContinuationTimeout
           
protected  int nextUID
           
protected  Node node
           
protected  int numFragments
           
protected  int numSurvivors
           
protected  java.util.Hashtable pendingTraffic
           
protected  GlacierPolicy policy
           
protected  IdRange responsibleRange
           
protected  GlacierStatistics statistics
           
protected  CancellableTask timer
           
protected  long tokenBucket
           
protected  StorageManager trashStorage
           
 
Fields inherited from interface rice.p2p.past.gc.GCPast
INFINITY_EXPIRATION
 
Constructor Summary
GlacierImpl(Node nodeArg, StorageManager fragmentStorageArg, StorageManager neighborStorageArg, int numFragmentsArg, int numSurvivorsArg, IdFactory factoryArg, java.lang.String instanceArg, GlacierPolicy policyArg)
           
 
Method Summary
 void addStatisticsListener(GlacierStatisticsListener gsl)
           
 void deliver(Id id, Message message)
          This method is called on the application at the destination node for the given id.
 void emptyTrash(Continuation c)
           
 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.
 Environment getEnvironment()
           
 java.lang.String getInstance()
           
 NodeHandle getLocalNodeHandle()
          get the nodeHandle of the local Past node
 Id[][] getNeighborRanges()
           
 int getReplicationFactor()
          Returns the number of replicas used in this Past
 long getTrashSize()
           
protected  int getUID()
           
 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 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 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 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 neighborSeen(Id nodeId, long when)
           
 void rateLimitedRetrieveFragment(FragmentKey key, Manifest manifest, char tag, GlacierContinuation c)
           
 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 removeStatisticsListener(GlacierStatisticsListener gsl)
           
 void retrieveFragment(FragmentKey key, Manifest manifest, char tag, GlacierContinuation c)
           
 void retrieveManifest(VersionKey key, char tag, Continuation command)
           
 void retrieveObject(VersionKey key, Manifest manifest, boolean beStrict, char tag, Continuation c)
           
 void sendMessage(Id id, GlacierMessage message, NodeHandle hint)
           
 void setBandwidthLimit(long bytesPerSecond, long maxBurst)
           
 void setNeighborTimeout(long neighborTimeoutMin)
           
 void setRateLimit(int rps)
           
 void setSyncInterval(int syncIntervalSec)
           
 void setSyncMaxFragments(int syncMaxFragments)
           
 void setTrashcan(StorageManager trashStorage)
           
 void startup()
           
 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.
protected  void updateTokenBucket()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fragmentStorage

protected final StorageManager fragmentStorage

neighborStorage

protected final StorageManager neighborStorage

policy

protected final GlacierPolicy policy

node

protected final Node node

numFragments

protected final int numFragments

instance

protected final java.lang.String instance

numSurvivors

protected final int numSurvivors

endpoint

protected final Endpoint endpoint

factory

protected final IdFactory factory

continuations

protected final java.util.Hashtable continuations

pendingTraffic

protected final java.util.Hashtable pendingTraffic

trashStorage

protected StorageManager trashStorage

nextContinuationTimeout

protected long nextContinuationTimeout

responsibleRange

protected IdRange responsibleRange

nextUID

protected int nextUID

timer

protected CancellableTask timer

statistics

protected GlacierStatistics statistics

listeners

protected java.util.Vector listeners

currentFragmentRequestTimeout

protected long currentFragmentRequestTimeout

tokenBucket

protected long tokenBucket

bucketLastUpdated

protected long bucketLastUpdated

bucketMin

protected long bucketMin

bucketMax

protected long bucketMax

bucketConsumed

protected long bucketConsumed

logger

protected Logger logger
Constructor Detail

GlacierImpl

public GlacierImpl(Node nodeArg,
                   StorageManager fragmentStorageArg,
                   StorageManager neighborStorageArg,
                   int numFragmentsArg,
                   int numSurvivorsArg,
                   IdFactory factoryArg,
                   java.lang.String instanceArg,
                   GlacierPolicy policyArg)
Method Detail

startup

public void startup()

updateTokenBucket

protected void updateTokenBucket()

sendMessage

public void sendMessage(Id id,
                        GlacierMessage message,
                        NodeHandle hint)

setTrashcan

public void setTrashcan(StorageManager trashStorage)

getUID

protected int getUID()

handleDebugCommand

public java.lang.String handleDebugCommand(java.lang.String command)
Specified by:
handleDebugCommand in interface DebugCommandHandler

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

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

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

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

neighborSeen

public void neighborSeen(Id nodeId,
                         long when)

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

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 num,
                          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
num - the maximal number of replicas requested
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

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

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

retrieveManifest

public void retrieveManifest(VersionKey key,
                             char tag,
                             Continuation command)

retrieveObject

public void retrieveObject(VersionKey key,
                           Manifest manifest,
                           boolean beStrict,
                           char tag,
                           Continuation c)

retrieveFragment

public void retrieveFragment(FragmentKey key,
                             Manifest manifest,
                             char tag,
                             GlacierContinuation c)

rateLimitedRetrieveFragment

public void rateLimitedRetrieveFragment(FragmentKey key,
                                        Manifest manifest,
                                        char tag,
                                        GlacierContinuation c)

getNeighborRanges

public Id[][] getNeighborRanges()

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

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

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

setSyncInterval

public void setSyncInterval(int syncIntervalSec)

setSyncMaxFragments

public void setSyncMaxFragments(int syncMaxFragments)

setRateLimit

public void setRateLimit(int rps)

setNeighborTimeout

public void setNeighborTimeout(long neighborTimeoutMin)

setBandwidthLimit

public void setBandwidthLimit(long bytesPerSecond,
                              long maxBurst)

getTrashSize

public long getTrashSize()

emptyTrash

public void emptyTrash(Continuation c)

addStatisticsListener

public void addStatisticsListener(GlacierStatisticsListener gsl)

removeStatisticsListener

public void removeStatisticsListener(GlacierStatisticsListener gsl)

getEnvironment

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

getInstance

public java.lang.String getInstance()
Specified by:
getInstance in interface Past
Returns:

ePOST API

Copyright © 2001-2005 - Rice Pastry.