voldemort.store.bdb
Class BdbStorageEngine

java.lang.Object
  extended by voldemort.store.AbstractStore<K,V,T>
      extended by voldemort.store.AbstractStorageEngine<ByteArray,byte[],byte[]>
          extended by voldemort.store.bdb.BdbStorageEngine
All Implemented Interfaces:
NativeBackupable, StorageEngine<ByteArray,byte[],byte[]>, Store<ByteArray,byte[],byte[]>
Direct Known Subclasses:
PartitionPrefixedBdbStorageEngine

public class BdbStorageEngine
extends AbstractStorageEngine<ByteArray,byte[],byte[]>
implements NativeBackupable

A store that uses BDB for persistence


Field Summary
protected  BdbEnvironmentStats bdbEnvironmentStats
           
protected  boolean checkpointerOffForBatchWrites
           
protected  boolean minimizeScanImpact
           
 
Constructor Summary
BdbStorageEngine(java.lang.String name, com.sleepycat.je.Environment environment, com.sleepycat.je.Database database, BdbRuntimeConfig config)
           
 
Method Summary
 boolean beginBatchModifications()
          A lot of storage engines support efficient methods for performing large number of writes (puts/deletes) against the data source.
 void close()
          Close the store.
 boolean delete(ByteArray key, Version version)
          Delete all entries prior to the given version
 boolean endBatchModifications()
           
 ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries()
          Get an iterator over pairs of entries in the store.
 ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries(int partition)
          Get an iterator over pairs of entries in a store's partition.
 boolean equals(java.lang.Object o)
           
 java.util.List<Versioned<byte[]>> get(ByteArray key, byte[] transforms)
          Get the value associated with the given key
 java.util.Map<ByteArray,java.util.List<Versioned<byte[]>>> getAll(java.lang.Iterable<ByteArray> keys, java.util.Map<ByteArray,byte[]> transforms)
          Get the values associated with the given keys and returns them in a Map of keys to a list of versioned values.
protected  com.sleepycat.je.Database getBdbDatabase()
          truncate() operation mandates that all opened Database be closed before attempting truncation.
 BdbEnvironmentStats getBdbEnvironmentStats()
           
 java.lang.String getBdbStats()
           
 java.lang.String getBdbStats(boolean fast)
           
protected  org.apache.log4j.Logger getLogger()
           
 com.sleepycat.je.DatabaseStats getStats(boolean setFast)
           
 java.util.List<Version> getVersions(ByteArray key)
          Get the versions associated with the given key.
 int hashCode()
           
 ClosableIterator<ByteArray> keys()
          Get an iterator over keys in the store.
 ClosableIterator<ByteArray> keys(int partition)
          Get an iterator over keys in the store's partition Note that the iterator need not be threadsafe, and that it must be manually closed after use.
 java.util.List<Versioned<byte[]>> multiVersionPut(ByteArray key, java.util.List<Versioned<byte[]>> values)
          Atomically update storage with the list of versioned values for the given key, to improve storage efficiency.
 void nativeBackup(java.io.File toDir, boolean verifyFiles, boolean isIncremental, AsyncOperationStatus status)
          Perform a native backup
 void put(ByteArray key, Versioned<byte[]> value, byte[] transforms)
          Associate the value with the key and version in this store
 void truncate()
          Truncate all entries in the store
 
Methods inherited from class voldemort.store.AbstractStorageEngine
isPartitionAware, isPartitionScanSupported, resolveAndConstructVersionsToPersist
 
Methods inherited from class voldemort.store.AbstractStore
delete, get, getAll, getCapability, getName, put
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface voldemort.store.Store
delete, get, getAll, getCapability, getName, put
 

Field Detail

bdbEnvironmentStats

protected final BdbEnvironmentStats bdbEnvironmentStats

minimizeScanImpact

protected final boolean minimizeScanImpact

checkpointerOffForBatchWrites

protected final boolean checkpointerOffForBatchWrites
Constructor Detail

BdbStorageEngine

public BdbStorageEngine(java.lang.String name,
                        com.sleepycat.je.Environment environment,
                        com.sleepycat.je.Database database,
                        BdbRuntimeConfig config)
Method Detail

entries

public ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries()
Description copied from interface: StorageEngine
Get an iterator over pairs of entries in the store. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
entries in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
entries in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Returns:
An iterator over the entries in this StorageEngine.

keys

public ClosableIterator<ByteArray> keys()
Description copied from interface: StorageEngine
Get an iterator over keys in the store. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
keys in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
keys in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Returns:
An iterator over the keys in this StorageEngine.

entries

public ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries(int partition)
Description copied from interface: StorageEngine
Get an iterator over pairs of entries in a store's partition. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
entries in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
entries in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Parameters:
partition - partition whose entries are to be fetched
Returns:
An iterator over the entries in this StorageEngine.

keys

public ClosableIterator<ByteArray> keys(int partition)
Description copied from interface: StorageEngine
Get an iterator over keys in the store's partition Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
keys in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
keys in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Parameters:
partition - partition whose keys are to be fetched
Returns:
An iterator over the keys in this StorageEngine.

truncate

public void truncate()
Description copied from interface: StorageEngine
Truncate all entries in the store

Specified by:
truncate in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
truncate in class AbstractStorageEngine<ByteArray,byte[],byte[]>

getBdbDatabase

protected com.sleepycat.je.Database getBdbDatabase()
truncate() operation mandates that all opened Database be closed before attempting truncation.

This method throws an exception while truncation is happening to any request attempting in parallel with store truncation.

Returns:
database object

getVersions

public java.util.List<Version> getVersions(ByteArray key)
Description copied from interface: Store
Get the versions associated with the given key. This is used in a put call to write a new value for this key

Specified by:
getVersions in interface Store<ByteArray,byte[],byte[]>
Overrides:
getVersions in class AbstractStore<ByteArray,byte[],byte[]>
Parameters:
key - The key to retrieve the versions for
Returns:
List of Versions associated with this key.

get

public java.util.List<Versioned<byte[]>> get(ByteArray key,
                                             byte[] transforms)
                                      throws PersistenceFailureException
Description copied from interface: Store
Get the value associated with the given key

Specified by:
get in interface Store<ByteArray,byte[],byte[]>
Overrides:
get in class AbstractStore<ByteArray,byte[],byte[]>
Parameters:
key - The key to check for
Returns:
The value associated with the key or an empty list if no values are found.
Throws:
PersistenceFailureException

getAll

public java.util.Map<ByteArray,java.util.List<Versioned<byte[]>>> getAll(java.lang.Iterable<ByteArray> keys,
                                                                         java.util.Map<ByteArray,byte[]> transforms)
                                                                  throws VoldemortException
Description copied from interface: Store
Get the values associated with the given keys and returns them in a Map of keys to a list of versioned values. Note that the returned map will only contain entries for the keys which have a value associated with them.

Specified by:
getAll in interface Store<ByteArray,byte[],byte[]>
Overrides:
getAll in class AbstractStore<ByteArray,byte[],byte[]>
Parameters:
keys - The keys to check for.
Returns:
A Map of keys to a list of versioned values.
Throws:
VoldemortException

put

public void put(ByteArray key,
                Versioned<byte[]> value,
                byte[] transforms)
         throws PersistenceFailureException
Description copied from interface: Store
Associate the value with the key and version in this store

Specified by:
put in interface Store<ByteArray,byte[],byte[]>
Overrides:
put in class AbstractStore<ByteArray,byte[],byte[]>
Parameters:
key - The key to use
value - The value to store and its version.
Throws:
PersistenceFailureException

delete

public boolean delete(ByteArray key,
                      Version version)
               throws PersistenceFailureException
Description copied from interface: Store
Delete all entries prior to the given version

Specified by:
delete in interface Store<ByteArray,byte[],byte[]>
Overrides:
delete in class AbstractStore<ByteArray,byte[],byte[]>
Parameters:
key - The key to delete
version - The current value of the key
Returns:
True if anything was deleted
Throws:
PersistenceFailureException

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

close

public void close()
           throws PersistenceFailureException
Description copied from interface: Store
Close the store.

Specified by:
close in interface Store<ByteArray,byte[],byte[]>
Overrides:
close in class AbstractStore<ByteArray,byte[],byte[]>
Throws:
PersistenceFailureException

getStats

public com.sleepycat.je.DatabaseStats getStats(boolean setFast)

getBdbStats

public java.lang.String getBdbStats()

getBdbStats

public java.lang.String getBdbStats(boolean fast)

getBdbEnvironmentStats

public BdbEnvironmentStats getBdbEnvironmentStats()

getLogger

protected org.apache.log4j.Logger getLogger()

nativeBackup

public void nativeBackup(java.io.File toDir,
                         boolean verifyFiles,
                         boolean isIncremental,
                         AsyncOperationStatus status)
Description copied from interface: NativeBackupable
Perform a native backup

Specified by:
nativeBackup in interface NativeBackupable
Parameters:
toDir - The directory to backup to
verifyFiles - whether the integrity of the copied data needs to be verified
isIncremental - is the backup incremental
status - The async operation status to update/check

beginBatchModifications

public boolean beginBatchModifications()
Description copied from interface: StorageEngine
A lot of storage engines support efficient methods for performing large number of writes (puts/deletes) against the data source. This method puts the storage engine in this batch write mode

Specified by:
beginBatchModifications in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
beginBatchModifications in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Returns:
true if the storage engine took successful action to switch to 'batch-write' mode

multiVersionPut

public java.util.List<Versioned<byte[]>> multiVersionPut(ByteArray key,
                                                         java.util.List<Versioned<byte[]>> values)
                                                  throws PersistenceFailureException
Description copied from interface: StorageEngine
Atomically update storage with the list of versioned values for the given key, to improve storage efficiency.

Specified by:
multiVersionPut in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
multiVersionPut in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Parameters:
key - Key to write
values - List of versioned values to be written atomically.
Returns:
list of obsolete versions that were rejected
Throws:
PersistenceFailureException

endBatchModifications

public boolean endBatchModifications()
Specified by:
endBatchModifications in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
endBatchModifications in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Returns:
true if the storage engine successfully returned to normal mode


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu