|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.persistence.StorageManagerImpl
public class StorageManagerImpl
This class provides both persistent and caching services to external applications. Building the StorageManager requires a Storage object, to provide the back-end storage, and a Cache to serve as a cache. Note that this implementation has seperate areas for the Cache and Storage, but the next version will allow the cache to use the unused storage space.
Constructor Summary | |
---|---|
StorageManagerImpl(IdFactory factory,
Storage storage,
Cache cache)
Builds a StorageManager given a Storage object to provide storage services and a Cache object to provide caching services. |
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 present in the location id . |
void |
flush(Continuation c)
Method which is used to erase all data stored in the Catalog. |
Cache |
getCache()
Returns the cache object used by this StorageManager |
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, or null if
there is no cooresponding object (through receiveResult on c). |
int |
getSize()
Returns the number of Ids currently stored in the catalog |
Storage |
getStorage()
Returns the permantent storage object used by this StorageManager |
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. |
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 command)
Updates the metadata stored under the given key to be the provided value. |
void |
store(Id id,
java.io.Serializable metadata,
java.io.Serializable obj,
Continuation c)
Stores an object in this storage. |
void |
uncache(Id id,
Continuation c)
Removes the object from the list of cached objects. |
void |
unstore(Id id,
Continuation c)
Removes the object from the list of stored objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StorageManagerImpl(IdFactory factory, Storage storage, Cache cache)
factory
- The factory to use for Id creationstorage
- The Storage object which will serve as the
persistent storage.cache
- The Cache object which will serve as the cache.Method Detail |
---|
public Storage getStorage()
getStorage
in interface StorageManager
public Cache getCache()
getCache
in interface StorageManager
public boolean exists(Id id)
id
.
exists
in interface Catalog
id
- The id of the object in question.
public void rename(Id oldId, Id newId, Continuation c)
rename
in interface Catalog
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 completepublic void getObject(Id id, Continuation c)
null
if
there is no cooresponding object (through receiveResult on c).
getObject
in interface Catalog
id
- The id of the object in question.c
- The command to run once the operation is completepublic java.io.Serializable getMetadata(Id id)
getMetadata
in interface Catalog
id
- The id for which the metadata is needed
public void setMetadata(Id id, java.io.Serializable metadata, Continuation command)
setMetadata
in interface Catalog
id
- The id for the metadatametadata
- The metadata to storec
- The command to run once the operation is completepublic IdSet scan(IdRange range)
scan
in interface Catalog
range
- The range to query
public IdSet scan()
scan
in interface Catalog
public java.util.SortedMap scanMetadata(IdRange range)
scanMetadata
in interface Catalog
range
- The range to query
public java.util.SortedMap scanMetadata()
scanMetadata
in interface Catalog
public java.util.SortedMap scanMetadataValuesHead(java.lang.Object value)
scanMetadataValuesHead
in interface Catalog
value
- The maximal metadata value
public java.util.SortedMap scanMetadataValuesNull()
scanMetadataValuesNull
in interface Catalog
public long getTotalSize()
getTotalSize
in interface Catalog
c
- The command to run once the operation is complete
public int getSize()
getSize
in interface Catalog
public void store(Id id, java.io.Serializable metadata, java.io.Serializable obj, Continuation c)
unstore(id)
followed
by store(id, obj)
. This method finishes by calling
receiveResult() on the provided continuation with the success
or failure of the store.
Returns True
if the action succeeds, else
False
(through receiveResult on c).
store
in interface Storage
id
- The object's id.metadata
- The object's metadataobj
- The object to store.c
- The command to run once the operation is completepublic void unstore(Id id, Continuation c)
False
is returned.
Returns True
if the action succeeds, else
False
(through receiveResult on c).
unstore
in interface Storage
pid
- The object's persistence idc
- The command to run once the operation is completepublic void cache(Id id, java.io.Serializable metadata, java.io.Serializable obj, Continuation c)
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).
cache
in interface Cache
id
- The object's id.metadata
- The object's metadataobj
- The object to cache.c
- The command to run once the operation is completepublic void uncache(Id id, Continuation c)
False
is returned.
Returns True
if the action succeeds, else
False
(through receiveResult on c).
uncache
in interface Cache
pid
- The object's idc
- The command to run once the operation is completepublic long getMaximumSize()
getMaximumSize
in interface Cache
c
- The command to run once the operation is completepublic void setMaximumSize(int size, Continuation c)
setMaximumSize
in interface Cache
size
- The new maximum size, in bytes, of the cache.c
- The command to run once the operation is completepublic void flush(Continuation c)
flush
in interface Catalog
c
- The command to run once done
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |