Class DatabaseConfig
- All Implemented Interfaces:
Cloneable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet the base file name for the database, which must reside in an ordinary file directory.baseFilePath
(String path) Set the base file name for the database, which must reside in an ordinary file directory.cachePriming
(boolean priming) Enable automatic cache priming, which writes a priming set into a special file when the process is cleanly shutdown.cacheSize
(long size) Convenience method which sets the minimum and maximum cache size, overriding the default.checkpointDelayThreshold
(long delay, TimeUnit unit) Set the maximum delay before an automatic checkpoint is performed, regardless of the redo log size threshold.checkpointRate
(long rate, TimeUnit unit) Set the rate at which checkpoints are automatically performed.checkpointSizeThreshold
(long bytes) Set the minimum redo log size required for an automatic checkpoint to actually be performed.checksumPages
(Supplier<? extends Checksum> factory) Enable 32-bit checksums for all of the underlying database pages.cleanShutdown
(boolean shutdown) When the process is cleanly shutdown, attempt to issue a full database shutdown.clone()
compressPages
(int fullPageSize, long cacheSize, Supplier<? extends PageCompressor> factory) Compress the underlying database pages, reducing overall size at the cost of performance.createFilePath
(boolean mkdirs) Set true to create directories for the base and data file, if they don't already exist.customHandlers
(Map<String, ? extends CustomHandler> handlers) Provide handlers for recovering custom transactional operations.Set the data file for the database, which by default resides in the same directory as the base file.Stripe the database data file across several files, expected to be on separate devices.dataPageArray
(Supplier<? extends PageArray> factory) Use a custom storage layer instead of the default data file.dataPageArray
(PageArray array) Use a custom storage layer instead of the default data file.void
debugOpen
(PrintStream out, Map<String, ?> properties) Opens the database in read-only mode for debugging purposes, and then closes it.directPageAccess
(boolean direct) Deprecated.direct page access is always enableddurabilityMode
(DurabilityMode durabilityMode) Set the default transaction durability mode, which isSYNC
if not overridden.enableJMX
(boolean enable) Enable full encryption of the data files, transaction logs, snapshots, and cache priming sets.eventListener
(EventListener listener) Set a listener which receives notifications of actions being performed by the database.eventListeners
(EventListener... listeners) Set multiple listeners which receive notifications of actions being performed by the database.lockTimeout
(long timeout, TimeUnit unit) Set the default lock acquisition timeout, which is 1 second if not overridden.lockUpgradeRule
(LockUpgradeRule lockUpgradeRule) Set the default lock upgrade rule, which isSTRICT
if not overridden.mapDataFiles
(boolean mapped) Enable memory mapping of the data files.maxCacheSize
(long maxBytes) Set the maximum cache size, overriding the default.maxCheckpointThreads
(int num) Specify the maximum number of threads for performing checkpointing, to speed it up.maxReplicaThreads
(int num) If replication is enabled, specify the maximum number of threads to process incoming changes.minCacheSize
(long minBytes) Set the minimum cache size, overriding the default.pageSize
(int size) Set the page size, which is 4096 bytes by default.prepareHandlers
(Map<String, ? extends PrepareHandler> handlers) Provide handlers for recovering prepared transactions.readOnly
(boolean readOnly) Open the database file in read only mode.replicate
(ReplicatorConfig config) Enable replication using the given configuration.replicate
(StreamReplicator repl) Enable replication with an explicitStreamReplicator
instance.syncWrites
(boolean fileSync) Set true to ensure all writes to the main database file are immediately durable, although not checkpointed.
-
Constructor Details
-
DatabaseConfig
public DatabaseConfig()
-
-
Method Details
-
baseFile
Set the base file name for the database, which must reside in an ordinary file directory. If no base file is provided, database is non-durable and cannot exceed the size of the cache. -
baseFilePath
Set the base file name for the database, which must reside in an ordinary file directory. If no base file is provided, database is non-durable and cannot exceed the size of the cache. -
createFilePath
Set true to create directories for the base and data file, if they don't already exist. Default is true. -
dataFile
Set the data file for the database, which by default resides in the same directory as the base file. The data file can be in a separate directory, and it can even be a raw block device. -
dataFiles
Stripe the database data file across several files, expected to be on separate devices. The data files can refer to ordinary files or to raw block devices. -
mapDataFiles
Enable memory mapping of the data files. Not recommended for 32-bit platforms or for databases which don't fit entirely in main memory. Memory mapped files tend to exhibit poor performance when they don't fit in main memory.If the data file is fixed in size, consider calling
dataPageArray
withMappedPageArray
for best memory mapping performance. Combine withStripedPageArray
when using multiple data files. -
dataPageArray
Use a custom storage layer instead of the default data file. -
dataPageArray
Use a custom storage layer instead of the default data file.- Parameters:
factory
- creates a new PageArray
-
minCacheSize
Set the minimum cache size, overriding the default.- Parameters:
minBytes
- cache size, in bytes
-
maxCacheSize
Set the maximum cache size, overriding the default.- Parameters:
maxBytes
- cache size, in bytes
-
cacheSize
Convenience method which sets the minimum and maximum cache size, overriding the default.- Parameters:
size
- cache size, in bytes
-
durabilityMode
Set the default transaction durability mode, which isSYNC
if not overridden. If database itself is non-durable, durability modes are ignored. -
lockUpgradeRule
Set the default lock upgrade rule, which isSTRICT
if not overridden. -
lockTimeout
Set the default lock acquisition timeout, which is 1 second if not overridden. A negative timeout is infinite.- Parameters:
unit
- required unit if timeout is more than zero
-
checkpointRate
Set the rate at which checkpoints are automatically performed. Default rate is 1 second. Pass a negative value to disable automatic checkpoints.- Parameters:
unit
- required unit if rate is more than zero
-
checkpointSizeThreshold
Set the minimum redo log size required for an automatic checkpoint to actually be performed. Default is 100 MiB. If database is used primarily for non-transactional operations, the threshold should be set to zero. -
checkpointDelayThreshold
Set the maximum delay before an automatic checkpoint is performed, regardless of the redo log size threshold. Default is 1 minute, and a negative delay is infinite. If database is used primarily for non-transactional operations, the threshold should be set to zero.- Parameters:
unit
- required unit if delay is more than zero
-
maxCheckpointThreads
Specify the maximum number of threads for performing checkpointing, to speed it up. This option is most useful when combined with thesyncWrites
option, or when usingDIRECT_IO
. The default number of threads is one. If a negative number is provided, the actual number applied is(-num * availableProcessors)
. -
eventListener
Set a listener which receives notifications of actions being performed by the database. Listener implementation must be thread-safe. -
eventListeners
Set multiple listeners which receive notifications of actions being performed by the database. Listener implementations must be thread-safe. -
syncWrites
Set true to ensure all writes to the main database file are immediately durable, although not checkpointed. This option typically reduces overall performance, but checkpoints complete more quickly. As a result, the main database file requires less pre-allocated pages and is smaller. Also consider specifying more checkpoint threads when using this option. -
readOnly
Open the database file in read only mode. Writes to the database are permitted until the cache fills up, but nothing is persisted. -
pageSize
Set the page size, which is 4096 bytes by default. -
directPageAccess
Deprecated.direct page access is always enabled -
cachePriming
Enable automatic cache priming, which writes a priming set into a special file when the process is cleanly shutdown. When opened again, the priming set is applied and the file is deleted. Option has no effect if database is non-durable.- See Also:
-
cleanShutdown
When the process is cleanly shutdown, attempt to issue a full database shutdown. This ensures full durability of all modifications. Setting this option prevents the process from exiting until a final checkpoint completes. -
replicate
Enable replication using the given configuration. When the database is opened, the given config object is cloned and the base file and event listener are assigned to it. -
replicate
Enable replication with an explicitStreamReplicator
instance. -
maxReplicaThreads
If replication is enabled, specify the maximum number of threads to process incoming changes. Default is the number of available processors. If a negative number is provided, the actual number applied is(-num * availableProcessors)
. When the local member is the leader, these threads are used for background processing of transactions which weren't committed withSYNC
durability.If replication isn't enabled, this option controls the number of threads used to recover transactions from the redo log during startup.
-
enableJMX
-
encrypt
Enable full encryption of the data files, transaction logs, snapshots, and cache priming sets. Option has no effect if database is non-durable. If replication is enabled, encryption is not applied to the replication stream. AStreamReplicator
implementation must perform its own encryption.Allocated but never used pages within the data files are unencrypted, although they contain no information. Temporary files used by in-progress snapshots contain encrypted content.
- Parameters:
factory
- creates a new crypto instance
-
checksumPages
Enable 32-bit checksums for all of the underlying database pages. The page size reported by the database will be 4 bytes smaller, to make room for the checksum.- Parameters:
factory
- creates new checksum instances;CRC32C::new
is recommended
-
compressPages
public DatabaseConfig compressPages(int fullPageSize, long cacheSize, Supplier<? extends PageCompressor> factory) Compress the underlying database pages, reducing overall size at the cost of performance. To be effective, the given full page size must be larger than physical page size. A full page size of 65536 bytes paired with the default physical page size of 4096 bytes achieves the best compression. A full page size which is smaller than the physical page size is generally a poor choice.The compression layer itself needs its own cache when accessing pages, although it can be much smaller than the primary cache size. Setting it to be 1% of the primary cache size should be sufficient. For a non-durable database, the compression cache should be much larger to avoid running out of space.
- Parameters:
fullPageSize
- full size of pages when uncompressedcacheSize
- cache size (in bytes) for the compression layerfactory
- creates new page compressor instances
-
customHandlers
Provide handlers for recovering custom transactional operations. The name assigned to each handler must be unique and never change. -
prepareHandlers
Provide handlers for recovering prepared transactions. The name assigned to each handler must be unique and never change. -
debugOpen
Opens the database in read-only mode for debugging purposes, and then closes it. The format of the printed messages and the supported properties are subject to change.- traceUndo=true to print all recovered undo log messages
- traceRedo=true to print all recovered redo log messages
- Parameters:
out
- pass null to print to standard outproperties
- optional- Throws:
IOException
-
clone
-