Class BerkeleyKVDatabase
- All Implemented Interfaces:
KVDatabase
KVDatabase implementation.
A database directory is the only required configuration property, but the
Environment, Database, and Transactions may all be configured.
Instances may be stopped and (re)started multiple times.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault Berkeley DB database name ("Permazen"). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a new transaction.createTransaction(Map<String, ?> options) Create a new transaction with the specified options.com.sleepycat.je.DatabaseGet the underlyingDatabaseassociated with this instance.com.sleepycat.je.DatabaseConfigGet theDatabaseConfigto be used by this instance.Get the configuredDatabasename.Get the filesystem directory containing the database.com.sleepycat.je.EnvironmentGet the underlyingEnvironmentassociated with this instance.com.sleepycat.je.EnvironmentConfigGet theEnvironmentConfigto be used by this instance.com.sleepycat.je.TransactionConfigGet the defaultTransactionConfigto be used by this instance.voidsetDatabaseConfig(com.sleepycat.je.DatabaseConfig config) Apply selected database configuration parameters from the given instance to theDatabaseConfigthis instance will use when opening theDatabaseat startup.voidsetDatabaseName(String databaseName) Configure theDatabasename.voidsetDirectory(File directory) Configure the filesystem directory containing the database.voidsetEnvironmentConfig(com.sleepycat.je.EnvironmentConfig config) Set a customEnvironmentConfigto be used by this instance at startup.voidsetNextTransactionConfig(com.sleepycat.je.TransactionConfig config) Configure a customTransactionConfigto be used for the next transaction in the current thread.voidsetTransactionConfig(com.sleepycat.je.TransactionConfig config) Configure a custom defaultTransactionConfigto be used by this instance for transactions.voidstart()Start this instance.voidstop()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 configuredDatabasename.- Returns:
- database name
-
setDatabaseName
Configure theDatabasename. Defaults toDEFAULT_DATABASE_NAME.- Parameters:
databaseName- database name
-
getEnvironmentConfig
public com.sleepycat.je.EnvironmentConfig getEnvironmentConfig()Get theEnvironmentConfigto 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 customEnvironmentConfigto be used by this instance at startup.The default
EnvironmentConfigis configured for serializable transactional operation and with allowCreate set to true.The given
configmust at least be configured for transactional operation.- Parameters:
config- environment config- Throws:
IllegalArgumentException- ifconfigis not configured to be transactionalIllegalArgumentException- ifconfigis null
-
getTransactionConfig
public com.sleepycat.je.TransactionConfig getTransactionConfig()Get the defaultTransactionConfigto 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 defaultTransactionConfigto 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- ifconfigis null- See Also:
-
setNextTransactionConfig
public void setNextTransactionConfig(com.sleepycat.je.TransactionConfig config) Configure a customTransactionConfigto 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- ifconfigis null- See Also:
-
getDatabaseConfig
public com.sleepycat.je.DatabaseConfig getDatabaseConfig()Get theDatabaseConfigto 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 theDatabaseConfigthis instance will use when opening theDatabaseat startup.The default
DatabaseConfigis 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 underlyingEnvironmentassociated with this instance.- Returns:
- the associated
Environment - Throws:
IllegalStateException- if this instance is not started
-
getDatabase
public com.sleepycat.je.Database getDatabase()Get the underlyingDatabaseassociated with this instance.- Returns:
- the associated
Database - Throws:
IllegalStateException- if this instance is not started
-
createTransaction
Description copied from interface:KVDatabaseCreate a new transaction with the specified options.- Specified by:
createTransactionin interfaceKVDatabase- Parameters:
options- optional transaction options; may be null- Returns:
- newly created transaction
-
createTransaction
Description copied from interface:KVDatabaseCreate a new transaction.- Specified by:
createTransactionin interfaceKVDatabase- Returns:
- newly created transaction
-
start
@PostConstruct public void start()Description copied from interface:KVDatabaseStart 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:
startin interfaceKVDatabase
-
stop
@PreDestroy public void stop()Description copied from interface:KVDatabaseStop this instance.This method is idempotent: if this instance has not been started, or is already stopped, nothing happens.
- Specified by:
stopin interfaceKVDatabase
-