Class BerkeleyKVDatabase
- All Implemented Interfaces:
KVDatabase
KVDatabase
implementation.
A database directory is the only required configuration property, but the
Environment
, Database
, and Transaction
s may all be configured.
Instances may be stopped and (re)started multiple times.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default Berkeley DB database name ("Permazen"). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new transaction.createTransaction
(Map<String, ?> options) Create a new transaction with the specified options.com.sleepycat.je.Database
Get the underlyingDatabase
associated with this instance.com.sleepycat.je.DatabaseConfig
Get theDatabaseConfig
to be used by this instance.Get the configuredDatabase
name.Get the filesystem directory containing the database.com.sleepycat.je.Environment
Get the underlyingEnvironment
associated with this instance.com.sleepycat.je.EnvironmentConfig
Get theEnvironmentConfig
to be used by this instance.com.sleepycat.je.TransactionConfig
Get the defaultTransactionConfig
to be used by this instance.void
setDatabaseConfig
(com.sleepycat.je.DatabaseConfig config) Apply selected database configuration parameters from the given instance to theDatabaseConfig
this instance will use when opening theDatabase
at startup.void
setDatabaseName
(String databaseName) Configure theDatabase
name.void
setDirectory
(File directory) Configure the filesystem directory containing the database.void
setEnvironmentConfig
(com.sleepycat.je.EnvironmentConfig config) Set a customEnvironmentConfig
to be used by this instance at startup.void
setNextTransactionConfig
(com.sleepycat.je.TransactionConfig config) Configure a customTransactionConfig
to be used for the next transaction in the current thread.void
setTransactionConfig
(com.sleepycat.je.TransactionConfig config) Configure a custom defaultTransactionConfig
to be used by this instance for transactions.void
start()
Start this instance.void
stop()
Stop this instance.
-
Field Details
-
DEFAULT_DATABASE_NAME
Default Berkeley DB database name ("Permazen").- See Also:
-
-
Constructor Details
-
BerkeleyKVDatabase
public BerkeleyKVDatabase()Constructor.
-
-
Method Details
-
getDirectory
Get the filesystem directory containing the database.- Returns:
- database directory
-
setDirectory
Configure the filesystem directory containing the database. Required property.- Parameters:
directory
- database directory
-
getDatabaseName
Get the configuredDatabase
name.- Returns:
- database name
-
setDatabaseName
Configure theDatabase
name. Defaults toDEFAULT_DATABASE_NAME
.- Parameters:
databaseName
- database name
-
getEnvironmentConfig
public com.sleepycat.je.EnvironmentConfig getEnvironmentConfig()Get theEnvironmentConfig
to be used by this instance.This method returns a copy; use
setEnvironmentConfig()
to change.- Returns:
- environment config
-
setEnvironmentConfig
public void setEnvironmentConfig(com.sleepycat.je.EnvironmentConfig config) Set a customEnvironmentConfig
to be used by this instance at startup.The default
EnvironmentConfig
is configured for serializable transactional operation and with allowCreate set to true.The given
config
must at least be configured for transactional operation.- Parameters:
config
- environment config- Throws:
IllegalArgumentException
- ifconfig
is not configured to be transactionalIllegalArgumentException
- ifconfig
is null
-
getTransactionConfig
public com.sleepycat.je.TransactionConfig getTransactionConfig()Get the defaultTransactionConfig
to be used by this instance.This method returns a copy; use
setTransactionConfig()
to change.- Returns:
- transaction config
-
setTransactionConfig
public void setTransactionConfig(com.sleepycat.je.TransactionConfig config) Configure a custom defaultTransactionConfig
to be used by this instance for transactions.Note: this configures the default; this default config can be overridden for the next transaction in the current thread only via
setNextTransactionConfig()
.The default setting for this property is
TransactionConfig.DEFAULT
.- Parameters:
config
- transaction config- Throws:
IllegalArgumentException
- ifconfig
is null- See Also:
-
setNextTransactionConfig
public void setNextTransactionConfig(com.sleepycat.je.TransactionConfig config) Configure a customTransactionConfig
to be used for the next transaction in the current thread. The next, and only the next, invocation ofcreateTransaction(java.util.Map<java.lang.String, ?>)
in the current thread will use the given configuration. After that, subsequent transactions will revert back to the default (even if the invocation ofcreateTransaction(java.util.Map<java.lang.String, ?>)
failed).- Parameters:
config
- transaction config- Throws:
IllegalArgumentException
- ifconfig
is null- See Also:
-
getDatabaseConfig
public com.sleepycat.je.DatabaseConfig getDatabaseConfig()Get theDatabaseConfig
to be used by this instance.This method returns a copy; use
setDatabaseConfig()
to change.- Returns:
- database config
-
setDatabaseConfig
public void setDatabaseConfig(com.sleepycat.je.DatabaseConfig config) Apply selected database configuration parameters from the given instance to theDatabaseConfig
this instance will use when opening theDatabase
at startup.The default
DatabaseConfig
is configured for transactional operation and with allowCreate set to true. Only certain allowed configuration properties are copied. The copied properties are:- allowCreate
- cacheMode
- deferredWrite
- exclusiveCreate
- nodeMaxEntries
- readOnly
- replicated
- temporary
- Parameters:
config
- database config
-
getEnvironment
public com.sleepycat.je.Environment getEnvironment()Get the underlyingEnvironment
associated with this instance.- Returns:
- the associated
Environment
- Throws:
IllegalStateException
- if this instance is not started
-
getDatabase
public com.sleepycat.je.Database getDatabase()Get the underlyingDatabase
associated with this instance.- Returns:
- the associated
Database
- Throws:
IllegalStateException
- if this instance is not started
-
createTransaction
Description copied from interface:KVDatabase
Create a new transaction with the specified options.- Specified by:
createTransaction
in interfaceKVDatabase
- Parameters:
options
- optional transaction options; may be null- Returns:
- newly created transaction
-
createTransaction
Description copied from interface:KVDatabase
Create a new transaction.- Specified by:
createTransaction
in interfaceKVDatabase
- Returns:
- newly created transaction
-
start
@PostConstruct public void start()Description copied from interface:KVDatabase
Start this instance. This method must be called prior to creating any transactions.This method is idempotent: if this instance is already started, nothing happens.
Whether an instance that has been started and stopped can be restarted is implementation-dependent.
- Specified by:
start
in interfaceKVDatabase
-
stop
@PreDestroy public void stop()Description copied from interface:KVDatabase
Stop this instance.This method is idempotent: if this instance has not been started, or is already stopped, nothing happens.
- Specified by:
stop
in interfaceKVDatabase
-