Package com.tangosol.io.bdb
Class BerkeleyDBBinaryStore
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.io.AbstractBinaryStore
-
- com.tangosol.io.bdb.BerkeleyDBBinaryStore
-
- All Implemented Interfaces:
BinaryStore
public class BerkeleyDBBinaryStore extends AbstractBinaryStore
An implementation of the BinaryStore interface using Sleepycat Berkeley DB Java Edition.- Author:
- mf 2005.09.29
- See Also:
- Berkeley DB JE JavaDoc
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BerkeleyDBBinaryStore.DatabaseHolder
The DatabaseHolder class is used as a wrapper around a Berkeley DB Database object.-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Nested classes/interfaces inherited from interface com.tangosol.io.BinaryStore
BinaryStore.KeySetAware, BinaryStore.SizeAware
-
-
Field Summary
Fields Modifier and Type Field Description protected BerkeleyDBBinaryStore.DatabaseHolder
m_db
The Database handle.protected DatabaseFactory
m_factory
Factory used to create this Database.
-
Constructor Summary
Constructors Constructor Description BerkeleyDBBinaryStore(String sDbName, DatabaseFactory dbFactory)
Create a new Berkeley DB BinaryStore using the supplied DatabaseFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the BinaryStore.void
erase(Binary binKey)
Remove the specified key from the underlying store if present.void
eraseAll()
Remove all data from the underlying store.BerkeleyDBBinaryStore.DatabaseHolder
getDbHolder()
Get the DatabaseHolder.DatabaseFactory
getFactory()
Get the DatabaseFactory used to create the underlying Database.protected void
init(String sDbName, DatabaseFactory dbFactory)
Initialize the BinaryStore.Iterator
keys()
Iterate all keys in the underlying store.Binary
load(Binary binKey)
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.void
store(Binary binKey, Binary binValue)
Store the specified value under the specific key in the underlying store.String
toString()
Return a human readable description of the BinaryStore.-
Methods inherited from class com.tangosol.io.AbstractBinaryStore
getDefaultDirectory
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Field Detail
-
m_db
protected volatile BerkeleyDBBinaryStore.DatabaseHolder m_db
The Database handle.
-
m_factory
protected DatabaseFactory m_factory
Factory used to create this Database.
-
-
Constructor Detail
-
BerkeleyDBBinaryStore
public BerkeleyDBBinaryStore(String sDbName, DatabaseFactory dbFactory) throws com.sleepycat.je.DatabaseException
Create a new Berkeley DB BinaryStore using the supplied DatabaseFactory.- Parameters:
sDbName
- the name of the table to store the cache's data in, null indicates a temporary table name.dbFactory
- the factory to use to create the Database- Throws:
com.sleepycat.je.DatabaseException
- if the Database creation failed
-
-
Method Detail
-
init
protected void init(String sDbName, DatabaseFactory dbFactory) throws com.sleepycat.je.DatabaseException
Initialize the BinaryStore.- Parameters:
sDbName
- the name of the table to store the cache's data in, null indicates a temporary table name.dbFactory
- the factory to use to create the Database- Throws:
com.sleepycat.je.DatabaseException
- if the Database creation failed
-
toString
public String toString()
Return a human readable description of the BinaryStore.
-
load
public Binary load(Binary binKey)
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.- Specified by:
load
in interfaceBinaryStore
- Specified by:
load
in classAbstractBinaryStore
- Parameters:
binKey
- key whose associated value is to be returned- Returns:
- the value associated with the specified key, or null if no value is available for that key
-
store
public void store(Binary binKey, Binary binValue)
Store the specified value under the specific key in the underlying store.This method is supports both key/value creation and value update for a specific key.
- Specified by:
store
in interfaceBinaryStore
- Overrides:
store
in classAbstractBinaryStore
- Parameters:
binKey
- key to store the value underbinValue
- value to be stored
-
erase
public void erase(Binary binKey)
Remove the specified key from the underlying store if present.- Specified by:
erase
in interfaceBinaryStore
- Overrides:
erase
in classAbstractBinaryStore
- Parameters:
binKey
- key whose mapping is to be removed from the map
-
eraseAll
public void eraseAll()
Remove all data from the underlying store.- Specified by:
eraseAll
in interfaceBinaryStore
- Overrides:
eraseAll
in classAbstractBinaryStore
-
keys
public Iterator keys()
Iterate all keys in the underlying store.- Specified by:
keys
in interfaceBinaryStore
- Overrides:
keys
in classAbstractBinaryStore
- Returns:
- a read-only iterator of the keys in the underlying store
-
close
public void close()
Close the BinaryStore.
-
getDbHolder
public BerkeleyDBBinaryStore.DatabaseHolder getDbHolder()
Get the DatabaseHolder. To prevent the underlying Database from being deleted during usage, hold onto this handle while using the Database object.- Returns:
- the DatabaseHolder
-
getFactory
public DatabaseFactory getFactory()
Get the DatabaseFactory used to create the underlying Database.- Returns:
- the DatabaseFactory
-
-