ePOST API

rice.persistence
Class EmptyCache

java.lang.Object
  extended by rice.persistence.EmptyCache
All Implemented Interfaces:
Cache, Catalog

public class EmptyCache
extends java.lang.Object
implements Cache

This class is a cahcce which doesn't store anything.


Field Summary
protected  IdFactory factory
          The facotry for building id sets
 
Constructor Summary
EmptyCache(IdFactory factory)
          Builds an emtpy cache
 
Method Summary
 void cache(Id id, java.io.Serializable metadata, java.io.Serializable obj, Continuation c)
          Caches an object in this storage.
 boolean exists(Id id)
          Returns whether or not an object is cached in the location id.
 void flush(Continuation c)
          Method which is used to erase all data stored in the Catalog.
 long getMaximumSize()
          Returns the maximum size of the cache, in bytes.
 java.io.Serializable getMetadata(Id id)
          Returns the metadata associated with the provided object, or null if no metadata exists.
 void getObject(Id id, Continuation c)
          Returns the object identified by the given id.
 int getSize()
          Returns the number of Ids currently stored in the catalog
 long getTotalSize()
          Returns the total size of the stored data in bytes.
 void rename(Id oldId, Id newId, Continuation c)
          Renames the given object to the new id.
 IdSet scan()
          Return all objects currently stored by this catalog NOTE: This method blocks so if the behavior of this method changes and no longer stored in memory, this method may be deprecated.
 IdSet scan(IdRange range)
          Return the objects identified by the given range of ids.
 java.util.SortedMap scanMetadata()
          Returns a map which contains keys mapping ids to the associated metadata.
 java.util.SortedMap scanMetadata(IdRange range)
          Returns a map which contains keys mapping ids to the associated metadata.
 java.util.SortedMap scanMetadataValuesHead(java.lang.Object value)
          Returns the submapping of ids which have metadata less than the provided value.
 java.util.SortedMap scanMetadataValuesNull()
          Returns the submapping of ids which have metadata null
 void setMaximumSize(int size, Continuation c)
          Sets the maximum size of the cache, in bytes.
 void setMetadata(Id id, java.io.Serializable metadata, Continuation c)
          Updates the metadata stored under the given key to be the provided value.
 void uncache(Id id, Continuation c)
          Removes the object from the list of cached objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected IdFactory factory
The facotry for building id sets

Constructor Detail

EmptyCache

public EmptyCache(IdFactory factory)
Builds an emtpy cache

Method Detail

rename

public void rename(Id oldId,
                   Id newId,
                   Continuation c)
Renames the given object to the new id. This method is potentially faster than store/cache and unstore/uncache.

Specified by:
rename in interface Catalog
Parameters:
oldId - The id of the object in question.
newId - The new id of the object in question.
c - The command to run once the operation is complete

cache

public void cache(Id id,
                  java.io.Serializable metadata,
                  java.io.Serializable obj,
                  Continuation c)
Caches an object in this storage. This method is non-blocking. If the object has already been stored at the location id, this method has the effect of calling uncachr(id) followed by cache(id, obj). This method finishes by calling receiveResult() on the provided continuation with whether or not the object was cached. Note that the object may not actually be cached due to the cache replacement policy. Returns True if the cache actaully stores the object, else False (through receiveResult on c).

Specified by:
cache in interface Cache
Parameters:
id - The object's id.
obj - The object to cache.
c - The command to run once the operation is complete
metadata - The object's metdatadata

uncache

public void uncache(Id id,
                    Continuation c)
Removes the object from the list of cached objects. This method is non-blocking. If the object was not in the cached list in the first place, nothing happens and False is returned. Returns True if the action succeeds, else False (through receiveResult on c).

Specified by:
uncache in interface Cache
Parameters:
pid - The object's id
c - The command to run once the operation is complete

exists

public boolean exists(Id id)
Returns whether or not an object is cached in the location id.

Specified by:
exists in interface Catalog
Parameters:
id - The id of the object in question.
Returns:
Whether or not an object is present at id.

getObject

public void getObject(Id id,
                      Continuation c)
Returns the object identified by the given id.

Specified by:
getObject in interface Catalog
Parameters:
id - The id of the object in question.
c - The command to run once the operation is complete

getMetadata

public java.io.Serializable getMetadata(Id id)
Returns the metadata associated with the provided object, or null if no metadata exists. The metadata must be stored in memory, so this operation is guaranteed to be fast and non-blocking.

Specified by:
getMetadata in interface Catalog
Parameters:
id - The id for which the metadata is needed
Returns:
The metadata, or null of non exists

setMetadata

public void setMetadata(Id id,
                        java.io.Serializable metadata,
                        Continuation c)
Updates the metadata stored under the given key to be the provided value. As this may require a disk access, the requestor must also provide a continuation to return the result to.

Specified by:
setMetadata in interface Catalog
Parameters:
id - The id for the metadata
metadata - The metadata to store
c - The command to run once the operation is complete

scan

public IdSet scan(IdRange range)
Return the objects identified by the given range of ids. The IdSet returned contains the Ids of the stored objects. The range is partially inclusive, the lower range is inclusive, and the upper exclusive. NOTE: This method blocks so if the behavior of this method changes and uses the disk, this method may be deprecated.

Specified by:
scan in interface Catalog
Parameters:
range - The range to query
Returns:
The idset containg the keys

scan

public IdSet scan()
Return all objects currently stored by this catalog NOTE: This method blocks so if the behavior of this method changes and no longer stored in memory, this method may be deprecated.

Specified by:
scan in interface Catalog
Returns:
The idset containg the keys

scanMetadata

public java.util.SortedMap scanMetadata(IdRange range)
Returns a map which contains keys mapping ids to the associated metadata.

Specified by:
scanMetadata in interface Catalog
Parameters:
range - The range to query
Returns:
The map containg the keys

scanMetadata

public java.util.SortedMap scanMetadata()
Returns a map which contains keys mapping ids to the associated metadata.

Specified by:
scanMetadata in interface Catalog
Returns:
The treemap mapping ids to metadata

scanMetadataValuesHead

public java.util.SortedMap scanMetadataValuesHead(java.lang.Object value)
Returns the submapping of ids which have metadata less than the provided value.

Specified by:
scanMetadataValuesHead in interface Catalog
Parameters:
value - The maximal metadata value
Returns:
The submapping

scanMetadataValuesNull

public java.util.SortedMap scanMetadataValuesNull()
Returns the submapping of ids which have metadata null

Specified by:
scanMetadataValuesNull in interface Catalog
Returns:
The submapping

getMaximumSize

public long getMaximumSize()
Returns the maximum size of the cache, in bytes. The result is returned via the receiveResult method on the provided Continuation with an Integer representing the size.

Specified by:
getMaximumSize in interface Cache
Parameters:
c - The command to run once the operation is complete

getTotalSize

public long getTotalSize()
Returns the total size of the stored data in bytes. The result is returned via the receiveResult method on the provided Continuation with an Integer representing the size.

Specified by:
getTotalSize in interface Catalog
Parameters:
c - The command to run once the operation is complete
Returns:
The total size, in bytes, of data stored.

getSize

public int getSize()
Returns the number of Ids currently stored in the catalog

Specified by:
getSize in interface Catalog
Returns:
The number of ids in the catalog

setMaximumSize

public void setMaximumSize(int size,
                           Continuation c)
Sets the maximum size of the cache, in bytes. Setting this value to a smaller value than the current value may result in object being evicted from the cache.

Specified by:
setMaximumSize in interface Cache
Parameters:
size - The new maximum size, in bytes, of the cache.
c - The command to run once the operation is complete

flush

public void flush(Continuation c)
Method which is used to erase all data stored in the Catalog. Use this method with care!

Specified by:
flush in interface Catalog
Parameters:
c - The command to run once done

ePOST API

Copyright © 2001-2005 - Rice Pastry.