Rice Pastry API

rice.persistence
Class DatabaseStorage

java.lang.Object
  extended by rice.persistence.DatabaseStorage
All Implemented Interfaces:
Catalog, Storage

public class DatabaseStorage
extends java.lang.Object
implements Storage


Field Summary
protected  com.sleepycat.je.Database db
           
protected  com.sleepycat.je.Environment dbenv
           
protected  Environment env
           
protected  IdFactory idf
           
protected  ReverseTreeMap meta
           
protected  com.sleepycat.je.Database metadb
           
 
Constructor Summary
DatabaseStorage(IdFactory factory, java.lang.String rootDir, long size, Environment env)
           
DatabaseStorage(IdFactory idf, java.lang.String name, java.lang.String rootDir, Environment env)
           
DatabaseStorage(IdFactory idf, java.lang.String name, java.lang.String rootDir, long size, boolean index, Environment env)
           
DatabaseStorage(IdFactory idf, java.lang.String name, java.lang.String rootDir, long size, Environment env)
           
 
Method Summary
protected  Id db2id(com.sleepycat.je.DatabaseEntry dbe)
           
protected  java.io.Serializable dbDeserialize(com.sleepycat.je.DatabaseEntry dbe)
           
protected  com.sleepycat.je.DatabaseEntry dbSerialize(java.io.Serializable obj)
           
 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.
 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 corresponding object (through receiveResult on c).
 int getSize()
          Returns the number of Ids currently stored in the catalog
 long getTotalSize()
          Returns the total size of the stored data in bytes.
protected  com.sleepycat.je.DatabaseEntry id2db(Id id)
           
 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 setMetadata(Id id, java.io.Serializable metadata, Continuation c)
          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 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
 

Field Detail

env

protected Environment env

dbenv

protected com.sleepycat.je.Environment dbenv

db

protected com.sleepycat.je.Database db

metadb

protected com.sleepycat.je.Database metadb

idf

protected IdFactory idf

meta

protected ReverseTreeMap meta
Constructor Detail

DatabaseStorage

public DatabaseStorage(IdFactory idf,
                       java.lang.String name,
                       java.lang.String rootDir,
                       long size,
                       boolean index,
                       Environment env)
                throws java.io.IOException
Throws:
java.io.IOException

DatabaseStorage

public DatabaseStorage(IdFactory idf,
                       java.lang.String name,
                       java.lang.String rootDir,
                       long size,
                       Environment env)
                throws java.io.IOException
Throws:
java.io.IOException

DatabaseStorage

public DatabaseStorage(IdFactory factory,
                       java.lang.String rootDir,
                       long size,
                       Environment env)
                throws java.io.IOException
Throws:
java.io.IOException

DatabaseStorage

public DatabaseStorage(IdFactory idf,
                       java.lang.String name,
                       java.lang.String rootDir,
                       Environment env)
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

store

public void store(Id id,
                  java.io.Serializable metadata,
                  java.io.Serializable obj,
                  Continuation c)
Description copied from interface: Storage
Stores 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 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).

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

unstore

public void unstore(Id id,
                    Continuation c)
Description copied from interface: Storage
Removes the object from the list of stored objects. This method is non-blocking. If the object was not in the stored 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:
unstore in interface Storage
c - The command to run once the operation is complete

exists

public boolean exists(Id id)
Description copied from interface: Catalog
Returns whether or not an object is present 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)
Description copied from interface: Catalog
Returns the object identified by the given id, or null if there is no corresponding object (through receiveResult on c).

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)
Description copied from interface: Catalog
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. The metadata returned from this method must *NOT* be mutated in any way, as the actual reference to the internal object is returned. Mutating this metadata may make the internal indices incorrect, resulting in undefined behavior. Changing the metadata should be done by creating a new metadata object and calling setMetadata().

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

setMetadata

public void setMetadata(Id id,
                        java.io.Serializable metadata,
                        Continuation c)
Description copied from interface: Catalog
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

rename

public void rename(Id oldId,
                   Id newId,
                   Continuation c)
Description copied from interface: Catalog
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

scan

public IdSet scan(IdRange range)
Description copied from interface: Catalog
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 no longer stored in memory, this method may be deprecated.

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

scan

public IdSet scan()
Description copied from interface: Catalog
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 containing the keys

scanMetadata

public java.util.SortedMap scanMetadata(IdRange range)
Description copied from interface: Catalog
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 containing the keys

scanMetadata

public java.util.SortedMap scanMetadata()
Description copied from interface: Catalog
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)
Description copied from interface: Catalog
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()
Description copied from interface: Catalog
Returns the submapping of ids which have metadata null

Specified by:
scanMetadataValuesNull in interface Catalog
Returns:
The submapping

getSize

public int getSize()
Description copied from interface: Catalog
Returns the number of Ids currently stored in the catalog

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

getTotalSize

public long getTotalSize()
Description copied from interface: Catalog
Returns the total size of the stored data in bytes.

Specified by:
getTotalSize in interface Catalog
Returns:
The total storage size

flush

public void flush(Continuation c)
Description copied from interface: Catalog
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

id2db

protected com.sleepycat.je.DatabaseEntry id2db(Id id)

db2id

protected Id db2id(com.sleepycat.je.DatabaseEntry dbe)

dbSerialize

protected com.sleepycat.je.DatabaseEntry dbSerialize(java.io.Serializable obj)

dbDeserialize

protected java.io.Serializable dbDeserialize(com.sleepycat.je.DatabaseEntry dbe)

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection