diff options
Diffstat (limited to 'lang/java/src/com/sleepycat/db/EnvironmentConfig.java')
| -rw-r--r-- | lang/java/src/com/sleepycat/db/EnvironmentConfig.java | 277 |
1 files changed, 275 insertions, 2 deletions
diff --git a/lang/java/src/com/sleepycat/db/EnvironmentConfig.java b/lang/java/src/com/sleepycat/db/EnvironmentConfig.java index d50fba5a..d87e907f 100644 --- a/lang/java/src/com/sleepycat/db/EnvironmentConfig.java +++ b/lang/java/src/com/sleepycat/db/EnvironmentConfig.java @@ -1,8 +1,7 @@ - /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002, 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2015 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ @@ -82,6 +81,9 @@ public class EnvironmentConfig implements Cloneable { private int backup_read_sleep = 0; private int backup_size = 0; private boolean backup_write_direct = false; + private int write_direct = 0; + private java.io.File blobDir = null; + private int blobThreshold = 0; private int cacheCount = 0; private long cacheSize = 0L; private long cacheMax = 0L; @@ -108,6 +110,8 @@ public class EnvironmentConfig implements Cloneable { private int maxWrite = 0; private long maxWriteSleep = 0L; private java.io.File metadataDir = null; + private java.io.File msgfile = null; + private String msgfileStr = null; private int mutexAlignment = 0; private int mutexIncrement = 0; private int mutexTestAndSetSpins = 0; @@ -132,6 +136,7 @@ public class EnvironmentConfig implements Cloneable { private java.io.File temporaryDirectory = null; private ReplicationManagerAckPolicy repmgrAckPolicy = ReplicationManagerAckPolicy.QUORUM; + private long repmgrIncomingQueueMax = 0; private java.util.Vector repmgrSitesConfig = new java.util.Vector(); /* Initial region resource allocation. */ @@ -170,7 +175,9 @@ public class EnvironmentConfig implements Cloneable { private boolean hotbackupInProgress = false; private boolean initializeRegions = false; private boolean logAutoRemove = false; + private boolean logBlobContent = false; private boolean logInMemory = false; + private boolean logNoSync = false; private boolean logZero = false; private boolean multiversion = false; private boolean noLocking = false; @@ -212,6 +219,8 @@ public class EnvironmentConfig implements Cloneable { private EventHandler eventHandler = null; private MessageHandler messageHandler = null; private PanicHandler panicHandler = null; + private boolean repViewIsSet = false; + private ReplicationViewHandler replicationViewHandler = null; private ReplicationTransport replicationTransport = null; /** @@ -247,6 +256,76 @@ True if the database environment is configured to create any } /** + Sets the path of a directory where blobs are stored. + <p> + The blobs of each {@link com.sleepycat.db.Database Database} opened + within this {@link com.sleepycat.db.Environment Environment} are + stored under this directory. + <p> + This path can not be set after opening the environment. + <p> + @param dir + The path of a directory where blobs are stored. + */ + public void setBlobDir(java.io.File dir) { + this.blobDir = dir; + } + + /** + Returns the path of a directory where blobs are stored. + <p> + The blobs of each {@link com.sleepycat.db.Database Database} opened + within this {@link com.sleepycat.db.Environment Environment} are + stored under this directory. + <p> + @return + The path of a directory where blobs are stored. + */ + public java.io.File getBlobDir() { + return blobDir; + } + + /** + Set the default blob threshold for databases opened in this environment. + The blob threshold is the size in bytes which is used to determine when + a data item will be stored as a blob. + <p> + Any data item that is equal to or larger in size than the + threshold value will automatically be stored as a blob. + <p> + It is illegal to enable blob in the environment if any of + {@link com.sleepycat.db.EnvironmentConfig#setTxnSnapshot EnvironmentConfig.setTxnSnapshot}, + {@link com.sleepycat.db.EnvironmentConfig#setInitializeReplication EnvironmentConfig.setInitializeReplication}, + and {@link com.sleepycat.db.EnvironmentConfig#setMultiversion EnvironmentConfig.setMultiversion} + is called with true value. + <p> + This threshold value can be set any time before and after opening the + environment. + <p> + @param value + The size in bytes which is used to determine when a data item will + be stored as a blob. If 0, databases opened in the environment will default + to never using blob. + */ + public void setBlobThreshold(int value) { + this.blobThreshold = value; + } + + /** + Return the environment wide default blob threshold value. The blob + threshold is the size in bytes which is used to determine when a data item + will be stored as a blob. + <p> + @return + The blob threshold value in bytes beyond which data items are + stored as blobs. If 0, databases opened in the environment will default to + never using blobs. + */ + public int getBlobThreshold() { + return blobThreshold; + } + + /** Set the size of the shared memory buffer pool, that is, the size of the cache. <p> @@ -1468,6 +1547,29 @@ True if the system has been configured to to automatically remove log } /** + Enable full logging of blob data. Required for HA and the hotbackup + utility. + <p> + @param logBlobContent + If true, enable full logging of blob data. + */ + public void setLogBlobContent(final boolean logBlobContent) { + this.logBlobContent = logBlobContent; + } + + /** + Return true if full logging of blob data is enabled. + <p> + This method may be called at any time during the life of the application. + <p> + @return + True if full logging of blob data is enabled. + */ + public boolean getLogBlobContent() { + return logBlobContent; + } + + /** If set, maintain transaction logs in memory rather than on disk. This means that transactions exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be @@ -1515,6 +1617,36 @@ True if the database environment is configured to maintain transaction logs } /** + Configure the system to avoid fsync() calls during log file flushes. + <p> + Log nosync is only safe when recovery is not needed after a system crash. + If the system remains alive and the application crashes, the database will + be recoverable in that situation. + <p> + This method may not be called after the environment has been opened. + <p> + @param logNoSync + If true, configure the system to avoid fsync() calls during log file flushes. + */ + public void setLogNoSync(final boolean logNoSync) { + this.logNoSync = logNoSync; + } + + /** + Return true if the system has been configured to avoid fsync() calls during + log files during flushes. + <p> + This method may be called at any time during the life of the application. + <p> + @return + True if the system has been configured to avoid fsync() calls during log + files flushes. + */ + public boolean getLogNoSync() { + return logNoSync; + } + + /** Set a function to process application-specific log records. <p> This method configures only operations performed using a single a @@ -1728,6 +1860,35 @@ The handler for application-specific log records. return repmgrAckPolicy; } + /** + Set the maximum amount of dynamic memory used by the Replication Manager + incoming queue. + <p> + By default, the Replication Manager incoming queue size has a limit of 100MB. + If zero is specified, then the Replication Manager incoming queue size is + limited by available heap memory. + <p> + @param repmgrIncomingQueueMax + The maximum amount of dynamic memory used by the Replication Manager incoming queue. + */ + public void setReplicationManagerIncomingQueueMax( + final long repmgrIncomingQueueMax) + { + this.repmgrIncomingQueueMax = repmgrIncomingQueueMax; + } + + /** + Get the maximum amount of dynamic memory used by the Replication Manager + incoming queue. + <p> + @return + The maximum amount of dynamic memory used by the Replication Manager incoming queue. + */ + public long getReplicationManagerIncomingQueueMax() + { + return this.repmgrIncomingQueueMax; + } + /** Configure a site in a replication group. This could be called more than once, to set local site and remote sites. @@ -2325,6 +2486,22 @@ The an OutputStream for displaying informational messages. return mmapSize; } + /** + Sets the path of a file to store statistical information. + <p> + This method may be called at any time during the life of the application. + <p> + @param file + The path of a file to store statistical information. + */ + public void setMsgfile(java.io.File file) { + this.msgfile = file; + if (file != null) + this.msgfileStr = file.toString(); + else + this.msgfileStr = null; + } + /** Sets the page size used to allocate the hash table and the number of mutexes expected to be needed by the buffer pool. @@ -2623,6 +2800,37 @@ The function to be called if the database environment panics. } /** + Set the function to be used by replication views to determine whether a + database file is replicated to the local site. + <p> + @param repViewHandler + The function name to determine whether a database file is replicated. If + null, the replication view is a full view and all database files are + replicated to the local site. Otherwise it is a partial view and only some + database files are replicated to the local site. + */ + public void setReplicationView( + final ReplicationViewHandler repViewHandler) { + this.repViewIsSet = true; + this.replicationViewHandler = repViewHandler; + } + + /** + Return the function name used by replication views to determine whether + a database file is replicated to the local site. + <p> + @return + The function name used by replication views to determine whether a database + file is replicated to the local site. If null, the replication view is a + full view and all database files are replicated to the local site. + Otherwise it is a partial view and only some database files are replicated + to the local site. + */ + public ReplicationViewHandler getReplicationViewHandler() { + return this.replicationViewHandler; + } + + /** Configure the database environment to only be accessed by a single process (although that process may be multithreaded). <p> @@ -4433,9 +4641,15 @@ True if the system has been configured to yield the processor if (logAutoRemove != oldConfig.logAutoRemove) dbenv.log_set_config(DbConstants.DB_LOG_AUTO_REMOVE, logAutoRemove); + if (logBlobContent != oldConfig.logBlobContent) + dbenv.log_set_config(DbConstants.DB_LOG_BLOB, logBlobContent); + if (logInMemory != oldConfig.logInMemory) dbenv.log_set_config(DbConstants.DB_LOG_IN_MEMORY, logInMemory); + if (logNoSync != oldConfig.logNoSync) + dbenv.log_set_config(DbConstants.DB_LOG_NOSYNC, logNoSync); + if (logZero != oldConfig.logZero) dbenv.log_set_config(DbConstants.DB_LOG_ZERO, logZero); @@ -4499,10 +4713,44 @@ True if the system has been configured to yield the processor dbenv.set_msgcall(messageHandler); if (panicHandler != oldConfig.panicHandler) dbenv.set_paniccall(panicHandler); + /* + * Configure replication views for a new environment or an existing + * environment with the callback provided by the application. + * If the callback is set as null, the replication view is a full view + * and all database files are replicated to the local site. Otherwise + * it is a partial view and only some database files are replicated to + * the local site. + */ + if (repViewIsSet) + dbenv.rep_set_view(replicationViewHandler); if (replicationTransport != oldConfig.replicationTransport) dbenv.rep_set_transport(envid, replicationTransport); /* Other settings */ + + if (backup_read_count != 0) + dbenv.set_backup_config(DbConstants.DB_BACKUP_READ_COUNT, + backup_read_count); + + if (backup_read_sleep != 0) + dbenv.set_backup_config(DbConstants.DB_BACKUP_READ_SLEEP, + backup_read_sleep); + + if (backup_size != 0) { + dbenv.set_backup_config(DbConstants.DB_BACKUP_SIZE, + backup_size); + } + + if (backup_write_direct == true) + dbenv.set_backup_config(DbConstants.DB_BACKUP_WRITE_DIRECT, 1); + else + dbenv.set_backup_config(DbConstants.DB_BACKUP_WRITE_DIRECT, 0); + + if (blobDir != oldConfig.blobDir) + dbenv.set_blob_dir(blobDir.toString()); + if (blobThreshold != oldConfig.blobThreshold) + dbenv.set_blob_threshold(blobThreshold, 0); + if (cacheSize != oldConfig.cacheSize || cacheCount != oldConfig.cacheCount) dbenv.set_cachesize(cacheSize, cacheCount); @@ -4558,6 +4806,8 @@ True if the system has been configured to yield the processor dbenv.set_mp_pagesize(mpPageSize); if (mpTableSize != oldConfig.mpTableSize) dbenv.set_mp_tablesize(mpTableSize); + if (msgfile != oldConfig.msgfile) + dbenv.set_msgfile(msgfile.toString()); if (password != null) dbenv.set_encrypt(password, DbConstants.DB_ENCRYPT_AES); if (replicationClockskewFast != oldConfig.replicationClockskewFast || @@ -4622,6 +4872,8 @@ True if the system has been configured to yield the processor DbConstants.DB_REP_CONF_INMEM, replicationInMemory); if (repmgrAckPolicy != oldConfig.repmgrAckPolicy) dbenv.repmgr_set_ack_policy(repmgrAckPolicy.getId()); + if (repmgrIncomingQueueMax != oldConfig.repmgrIncomingQueueMax) + dbenv.repmgr_set_incoming_queue_max(repmgrIncomingQueueMax); java.util.Iterator elems = repmgrSitesConfig.listIterator(); java.util.Iterator oldElems = oldConfig.repmgrSitesConfig.listIterator(); while (elems.hasNext()){ @@ -4708,7 +4960,9 @@ True if the system has been configured to yield the processor directLogIO = dbenv.log_get_config(DbConstants.DB_LOG_DIRECT); dsyncLog = dbenv.log_get_config(DbConstants.DB_LOG_DSYNC); logAutoRemove = dbenv.log_get_config(DbConstants.DB_LOG_AUTO_REMOVE); + logBlobContent = dbenv.log_get_config(DbConstants.DB_LOG_BLOB); logInMemory = dbenv.log_get_config(DbConstants.DB_LOG_IN_MEMORY); + logNoSync = dbenv.log_get_config(DbConstants.DB_LOG_NOSYNC); logZero = dbenv.log_get_config(DbConstants.DB_LOG_ZERO); } @@ -4742,6 +4996,21 @@ True if the system has been configured to yield the processor // XXX: replicationTransport and envid aren't available? /* Other settings */ + backup_read_count = + dbenv.get_backup_config(DbConstants.DB_BACKUP_READ_COUNT); + backup_read_sleep = + dbenv.get_backup_config(DbConstants.DB_BACKUP_READ_SLEEP); + backup_size = + dbenv.get_backup_config(DbConstants.DB_BACKUP_SIZE); + write_direct = + dbenv.get_backup_config(DbConstants.DB_BACKUP_WRITE_DIRECT); + backup_write_direct = (write_direct == 1) ? true : false; + + String blobDirStr = dbenv.get_blob_dir(); + if (blobDirStr != null) + blobDir = new java.io.File(blobDirStr); + blobThreshold = dbenv.get_blob_threshold(); + if (initializeCache) { cacheSize = dbenv.get_cachesize(); cacheMax = dbenv.get_cache_max(); @@ -4802,6 +5071,8 @@ True if the system has been configured to yield the processor logRegionSize = 0; } messageStream = dbenv.get_message_stream(); + if (msgfileStr != null) + msgfile = new java.io.File(msgfileStr); // XXX: intentional information loss? password = (dbenv.get_encrypt_flags() == 0) ? null : ""; @@ -4846,10 +5117,12 @@ True if the system has been configured to yield the processor replicationRequestMax = dbenv.rep_get_request_max(); repmgrAckPolicy = ReplicationManagerAckPolicy.fromInt( dbenv.repmgr_get_ack_policy()); + repmgrIncomingQueueMax = dbenv.repmgr_get_incoming_queue_max(); } else { replicationLimit = 0L; replicationRequestMin = 0; replicationRequestMax = 0; + repmgrIncomingQueueMax = 0; } segmentId = dbenv.get_shm_key(); |
