public final class BDBRepositoryBuilder extends AbstractRepositoryBuilder
BDBRepositoryBuilder builder = new BDBRepositoryBuilder(); builder.setProduct("JE"); builder.setName("test"); builder.setEnvironmentHome("/tmp/testRepo"); builder.setTransactionWriteNoSync(true); Repository repo = builder.build();
The following extra capabilities are supported:
Modifier and Type | Class and Description |
---|---|
static interface |
BDBRepositoryBuilder.DatabaseHook |
Constructor and Description |
---|
BDBRepositoryBuilder() |
Modifier and Type | Method and Description |
---|---|
Repository |
build(java.util.concurrent.atomic.AtomicReference<Repository> rootRef)
Builds a repository instance.
|
void |
errorCheck(java.util.Collection<java.lang.String> messages)
This method is called by assertReady, and subclasses must override to
perform custom checks.
|
BDBProduct |
getBDBProduct()
Returns the BDB product to use, which is JE by default.
|
java.lang.Integer |
getCachePercent()
Returns the percent of JVM heap used by the repository cache, or
null if default should be selected.
|
java.lang.Long |
getCacheSize()
Returns the repository cache size, or null if default should be
selected.
|
int |
getCheckpointInterval() |
int |
getCheckpointThresholdKB() |
int |
getCheckpointThresholdMinutes() |
java.lang.Boolean |
getChecksumEnabled()
Returns true if checksum verification is enabled.
|
java.lang.String |
getCompressor(java.lang.String type)
Return the compressor used for the given storable.
|
BDBRepositoryBuilder.DatabaseHook |
getDatabaseHook()
Returns the custom open database hook, or null if none.
|
java.lang.Boolean |
getDatabasesTransactional()
Returns true if the databases are configured to be transactional,
false if configured to not be transactional, null if this override was never set
|
java.lang.String |
getDataHome()
Returns the directory to store data files.
|
java.io.File |
getDataHomeFile()
Returns the optional directory to store data files.
|
java.lang.String |
getEnvironmentHome()
Returns the repository environment home directory.
|
java.io.File |
getEnvironmentHomeFile()
Returns the repository environment home directory.
|
double |
getIndexRepairThrottle()
Returns the throttle parameter used when indexes are added, dropped or
bulk repaired.
|
boolean |
getIndexSupport()
Returns true if indexes are supported, which is true by default.
|
java.lang.Object |
getInitialDatabaseConfig()
Returns the optional BDB specific database configuration to use
for all databases created.
|
java.lang.Object |
getInitialEnvironmentConfig()
Returns the optional BDB specific environment configuration to use.
|
boolean |
getInitializeLogging() |
boolean |
getKeepOldLogFiles()
Returns false by default.
|
boolean |
getLockConflictDeadlockDetectMode()
Returns true if deadlock detection is run whenever a lock conflict occurs.
|
double |
getLockTimeout()
Returns the lock timeout, in seconds.
|
long |
getLockTimeoutInMicroseconds()
Returns the lock timeout, in microseconds, limited to max long value.
|
java.lang.Integer |
getLogFileMaxSize()
Returns null if default size will be used.
|
boolean |
getLogInMemory()
Returns false by default, indicating that transaction logs are persisted.
|
java.lang.Integer |
getLogRegionSize()
Returns the repository log region size, or null if the default
should be selected.
|
java.lang.Integer |
getMaxLocks() |
java.lang.String |
getName()
Returns the name of the repository.
|
BDBPanicHandler |
getPanicHandler()
Return the panic handler to call if the database panics.
|
java.lang.Runnable |
getPreShutdownHook()
Returns the custom shutdown hook that runs before the repository has
finished running its own shutdown hooks, or null if none.
|
java.lang.String |
getProduct()
Returns the BDB product to use, which is JE by default.
|
boolean |
getReadOnly()
Returns true if repository should be opened read-only.
|
boolean |
getRunCheckpointer()
Returns true if checkpointer is run automatically.
|
boolean |
getRunDeadlockDetector()
Returns true if deadlock detector is configured to run.
|
boolean |
getRunFullRecovery()
Returns true if a full (catastrophic) recovery should be performed when
environment is opened.
|
java.lang.Runnable |
getShutdownHook()
Returns the custom shutdown hook that runs after the repository has
finished running its own shutdown hooks, or null if none.
|
java.lang.String |
getSingleFileName()
Returns the single file that all BDB databases should reside in.
|
StorableCodecFactory |
getStorableCodecFactory()
Returns the storable codec factory used.
|
java.lang.Integer |
getTransactionMaxActive()
Returns the maximum number of concurrent transactions, or null if the
default is used.
|
boolean |
getTransactionNoSync()
Returns true if transactions are not written or flushed to disk.
|
double |
getTransactionTimeout()
Returns the repository transaction timeout, in seconds.
|
long |
getTransactionTimeoutInMicroseconds()
Returns the repository transaction timeout, in microseconds, limited to
max long value.
|
boolean |
getTransactionWriteNoSync()
Returns true if transactions are not flushed to disk.
|
boolean |
isIndexRepairEnabled() |
boolean |
isMaster()
Returns true if repository should assume the role of master, which is
true by default.
|
boolean |
isMultiversion()
Returns false by default because multiversion concurrency control (MVCC)
is not enabled.
|
boolean |
isPrivate()
Returns true if BDB environment is private.
|
boolean |
isReverseSplitOff() |
void |
setBDBProduct(BDBProduct product)
Sets the BDB product to use, which defaults to JE.
|
void |
setCachePercent(int cachePercent)
Set the percent of JVM heap used by the repository cache.
|
void |
setCachePercent(java.lang.Integer cachePercent)
Set the percent of JVM heap used by the repository cache.
|
void |
setCacheSize(long cacheSize)
Set the repository cache size, in bytes.
|
void |
setCacheSize(java.lang.Long cacheSize)
Set the repository cache size, in bytes.
|
void |
setCheckpointInterval(int intervalMillis)
Set the interval to run checkpoints.
|
void |
setCheckpointThresholdKB(int thresholdKB)
Set the size threshold to run checkpoints.
|
void |
setCheckpointThresholdMinutes(int thresholdMinutes)
Set the time threshold to run checkpoints.
|
void |
setChecksumEnabled(java.lang.Boolean checksumEnabled)
When true, enable checksum verification of pages read into the cache
from the backing filestore.
|
void |
setCompressor(java.lang.String type,
java.lang.String compressionType)
Set the compressor for the given class, overriding a custom StorableCodecFactory.
|
void |
setDatabaseHook(BDBRepositoryBuilder.DatabaseHook hook)
Sets a hook to be called whenever a database is opened.
|
void |
setDatabasePageSize(java.lang.Integer bytes,
java.lang.Class<? extends Storable> type)
Sets the desired page size for a given type.
|
void |
setDatabasesTransactional(java.lang.Boolean transactional)
When true, allows databases to be transactional.
|
void |
setDataHome(java.lang.String dir)
By default, data files are stored relative to the environment home.
|
void |
setDataHomeFile(java.io.File dir)
By default, data files are stored relative to the environment home.
|
void |
setEnvironmentHome(java.lang.String envHome)
Sets the repository environment home directory, which is required.
|
void |
setEnvironmentHomeFile(java.io.File envHome)
Sets the repository environment home directory, which is required.
|
void |
setFileName(java.lang.String filename,
java.lang.String typeName)
Specify the file that a BDB database should reside in, except for log
files and caches.
|
void |
setIndexRepairEnabled(boolean enabled)
By default, index repair is enabled.
|
void |
setIndexRepairThrottle(double desiredSpeed)
Sets the throttle parameter used when indexes are added, dropped or bulk
repaired.
|
void |
setIndexSupport(boolean indexSupport)
By default, user specified indexes are supported.
|
void |
setInitialDatabaseConfig(java.lang.Object dbConfig)
Optionally set the BDB specific database configuration to use
for all databases created.
|
void |
setInitialEnvironmentConfig(java.lang.Object envConfig)
Optionally set the BDB specific environment configuration to
use.
|
void |
setInitializeLogging(boolean b)
Ensure the transaction logging sub-system is initialized, which is
usually implied.
|
void |
setKeepOldLogFiles(boolean keep)
By default, transaction log files are deleted when no longer needed.
|
void |
setLockConflictDeadlockDetectMode(boolean b)
Enable deadlock detection whenever a lock conflict occurs.
|
void |
setLockTimeout(double lockTimeout)
Set the lock timeout, in seconds.
|
void |
setLogFileMaxSize(java.lang.Integer sizeInBytes)
Set the maximum transaction log file size for the BDB environment.
|
void |
setLogInMemory(boolean logInMemory)
Set true to store transaction logs in memory only instead of persistent
storage.
|
void |
setLogRegionSize(int logRegionSize)
Set the repository log region size, in bytes.
|
void |
setLogRegionSize(java.lang.Integer logRegionSize)
Set the repository log region size, in bytes.
|
void |
setMaster(boolean b)
Set to false if repository should not assume the role of master.
|
void |
setMaxLocks(java.lang.Integer max) |
void |
setMultiversion(boolean multiversion)
Set true to enable multiversion concurrency control (MVCC) on BDB
environment.
|
void |
setName(java.lang.String name)
Set name for the repository, which is required.
|
void |
setPanicHandler(BDBPanicHandler handler)
Set the handler to call if the database panics.
|
void |
setPreShutdownHook(java.lang.Runnable hook)
Sets a callback to be invoked before the repository has finished running
its own shutdown hooks.
|
void |
setPrivate(boolean b)
When true, BDB environment cannot be shared by other processes, and
region files are not created.
|
void |
setProduct(java.lang.String product)
Sets the BDB product to use, which defaults to JE.
|
void |
setReadOnly(boolean readOnly)
Sets the repository to read-only mode.
|
void |
setReverseSplitOff(boolean off)
Pass true to disable reverse split of B-tree nodes to reduce deadlocks.
|
void |
setRunCheckpointer(boolean runCheckpointer)
Disable automatic checkpointing of database if another process is
responsible for that.
|
void |
setRunDeadlockDetector(boolean runDeadlockDetector)
Disable automatic deadlock detection of database if another thread is
responsible for that.
|
void |
setRunFullRecovery(boolean runRecovery)
Pass true to override the default and run a full (catastrophic) recovery
when environment is opened.
|
void |
setShutdownHook(java.lang.Runnable hook)
Sets a callback to be invoked after repository has finished running its
own shutdown hooks.
|
void |
setSingleFileName(java.lang.String filename)
Specify that all BDB databases should reside in one file, except for log
files and caches.
|
void |
setStorableCodecFactory(StorableCodecFactory factory)
Override the default storable codec factory.
|
void |
setTransactionMaxActive(java.lang.Integer max)
Set the maximum number of concurrent transactions, or pass null to use
the default.
|
void |
setTransactionNoSync(boolean noSync)
When true, commits are not immediately written or flushed to disk.
|
void |
setTransactionTimeout(double txnTimeout)
Set the transaction timeout, in seconds.
|
void |
setTransactionWriteNoSync(boolean noSync)
When true, commits are written, but they are not flushed to disk.
|
boolean |
verify(java.io.PrintStream out)
Opens the BDB environment, checks if it is corrupt, and then closes it.
|
addTriggerFactory, assertReady, build, getTriggerFactories, removeTriggerFactory
public Repository build(java.util.concurrent.atomic.AtomicReference<Repository> rootRef) throws RepositoryException
RepositoryBuilder
If the repository is being wrapped by a parent repository, the child repository will need to know this fact for some operations to work correctly. Since the parent repository is not built yet, a reference is used instead.
rootRef
- reference to root parent repository, to be set by
parent repository upon being builtConfigurationException
- if there is a problem in the builder's configurationRepositoryException
- if there is a general problem opening the repositorypublic boolean verify(java.io.PrintStream out) throws RepositoryException
out
- optional stream to capture any verfication errorsRepositoryException
public java.lang.String getName()
RepositoryBuilder
public void setName(java.lang.String name)
RepositoryBuilder
public boolean isMaster()
RepositoryBuilder
A master repository is responsible for version
and
sequence
properties. For insert operations, a master
repository must set these properties if they are uninitialized. For
updates, the version property is checked to see if an OptimisticLockException
should be thrown.
ReplicatedRepositoryBuilder
public void setMaster(boolean b)
RepositoryBuilder
A master repository is responsible for version
and
sequence
properties. For insert operations, a master
repository must set these properties if they are uninitialized. For
updates, the version property is checked to see if an OptimisticLockException
should be thrown.
ReplicatedRepositoryBuilder
public void setProduct(java.lang.String product)
public java.lang.String getProduct()
public void setBDBProduct(BDBProduct product)
public BDBProduct getBDBProduct()
public void setEnvironmentHomeFile(java.io.File envHome)
public java.io.File getEnvironmentHomeFile()
public void setEnvironmentHome(java.lang.String envHome)
RepositoryException
- if environment home is not validpublic java.lang.String getEnvironmentHome()
public void setDataHomeFile(java.io.File dir)
public java.io.File getDataHomeFile()
public void setDataHome(java.lang.String dir)
public java.lang.String getDataHome()
public void setSingleFileName(java.lang.String filename)
Note: When setting this option, the storable codec factory must also be changed, since the default storable codec factory is unable to distinguish storable types that reside in a single database file. Call setFileName instead to use built-in BDB feature for supporting multiple databases in one file.
public java.lang.String getSingleFileName()
public void setFileName(java.lang.String filename, java.lang.String typeName)
filename
- BDB database filenametypeName
- type to store in file; if null, the file is used by default
for all typespublic void setIndexSupport(boolean indexSupport)
public boolean getIndexSupport()
public boolean isIndexRepairEnabled()
setIndexRepairEnabled(boolean)
public void setIndexRepairEnabled(boolean enabled)
When index repair is disabled, the Storable is immediately available. This does have consequences, however. The set of indexes available for queries is defined by the intersection of the old and new index sets. The set of indexes that are kept up-to-date is defined by the union of the old and new index sets.
While index repair is disabled, another process can safely repair the indexes in the background. When it is complete, index repair can be enabled for this repository too.
public double getIndexRepairThrottle()
public void setIndexRepairThrottle(double desiredSpeed)
desiredSpeed
- 1.0 = perform work at full speed,
0.5 = perform work at half speed, 0.0 = fully suspend workpublic void setReadOnly(boolean readOnly)
public boolean getReadOnly()
public void setCacheSize(long cacheSize)
public void setCacheSize(java.lang.Long cacheSize)
cacheSize
- cache size to use, or null for defaultpublic java.lang.Long getCacheSize()
public void setLogRegionSize(int logRegionSize)
public void setLogRegionSize(java.lang.Integer logRegionSize)
public java.lang.Integer getLogRegionSize()
public void setCachePercent(int cachePercent)
public void setCachePercent(java.lang.Integer cachePercent)
cachePercent
- percent of JVM heap to use, or null for defaultpublic java.lang.Integer getCachePercent()
public void setLockTimeout(double lockTimeout)
public double getLockTimeout()
public long getLockTimeoutInMicroseconds()
public void setMaxLocks(java.lang.Integer max)
public java.lang.Integer getMaxLocks()
public void setTransactionTimeout(double txnTimeout)
public double getTransactionTimeout()
public long getTransactionTimeoutInMicroseconds()
public void setTransactionNoSync(boolean noSync)
public boolean getTransactionNoSync()
public void setTransactionWriteNoSync(boolean noSync)
public boolean getTransactionWriteNoSync()
public void setTransactionMaxActive(java.lang.Integer max)
public java.lang.Integer getTransactionMaxActive()
public void setDatabasesTransactional(java.lang.Boolean transactional)
public java.lang.Boolean getDatabasesTransactional()
public void setReverseSplitOff(boolean off)
public boolean isReverseSplitOff()
public void setDatabasePageSize(java.lang.Integer bytes, java.lang.Class<? extends Storable> type)
public void setPrivate(boolean b)
public boolean isPrivate()
public void setMultiversion(boolean multiversion)
public boolean isMultiversion()
public void setLogInMemory(boolean logInMemory)
public boolean getLogInMemory()
public void setLogFileMaxSize(java.lang.Integer sizeInBytes)
public java.lang.Integer getLogFileMaxSize()
public void setInitializeLogging(boolean b)
public boolean getInitializeLogging()
public void setRunFullRecovery(boolean runRecovery)
public boolean getRunFullRecovery()
public void setRunCheckpointer(boolean runCheckpointer)
public boolean getRunCheckpointer()
public void setCheckpointInterval(int intervalMillis)
intervalMillis
- interval between checkpoints, in millisecondspublic int getCheckpointInterval()
public void setCheckpointThresholdKB(int thresholdKB)
Checkpoint threshold is only used by Carbonado's built-in checkpointer, and is ignored when using BDB-JE.
thresholdKB
- run checkpoint if at least this many kilobytes in logpublic int getCheckpointThresholdKB()
public void setCheckpointThresholdMinutes(int thresholdMinutes)
Checkpoint threshold is only used by Carbonado's built-in checkpointer, and is ignored when using BDB-JE.
thresholdMinutes
- run checkpoint if at least this many minutes
passed since last checkpointpublic int getCheckpointThresholdMinutes()
public void setKeepOldLogFiles(boolean keep)
public boolean getKeepOldLogFiles()
public void setRunDeadlockDetector(boolean runDeadlockDetector)
public boolean getRunDeadlockDetector()
public void setLockConflictDeadlockDetectMode(boolean b)
public boolean getLockConflictDeadlockDetectMode()
public void setChecksumEnabled(java.lang.Boolean checksumEnabled)
public java.lang.Boolean getChecksumEnabled()
public void setInitialEnvironmentConfig(java.lang.Object envConfig)
public java.lang.Object getInitialEnvironmentConfig()
public void setInitialDatabaseConfig(java.lang.Object dbConfig)
public java.lang.Object getInitialDatabaseConfig()
public void setStorableCodecFactory(StorableCodecFactory factory)
public StorableCodecFactory getStorableCodecFactory()
public void setPreShutdownHook(java.lang.Runnable hook)
public java.lang.Runnable getPreShutdownHook()
public void setShutdownHook(java.lang.Runnable hook)
public java.lang.Runnable getShutdownHook()
public void setDatabaseHook(BDBRepositoryBuilder.DatabaseHook hook)
public BDBRepositoryBuilder.DatabaseHook getDatabaseHook()
public void setCompressor(java.lang.String type, java.lang.String compressionType)
type
- Storable to compress.compressionType
- String representation of type of
compression. Available options are "NONE" for no compression or "GZIP"
for gzip compressionpublic java.lang.String getCompressor(java.lang.String type)
type
- Storable to compresspublic void setPanicHandler(BDBPanicHandler handler)
handler
- public BDBPanicHandler getPanicHandler()
public void errorCheck(java.util.Collection<java.lang.String> messages) throws ConfigurationException
AbstractRepositoryBuilder
super.errorCheck
as well.errorCheck
in class AbstractRepositoryBuilder
messages
- add any error messages to this listConfigurationException
- if error checking indirectly caused
another exceptionCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.