1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: EnvironmentConfig.java,v 12.42 2008/05/14 20:58:42 bschmeck Exp $
7 */
8
9package com.sleepycat.db;
10
11import com.sleepycat.db.internal.DbConstants;
12import com.sleepycat.db.internal.DbEnv;
13import com.sleepycat.db.ReplicationHostAddress;
14
15/**
16Specifies the attributes of an environment.
17<p>
18To change the default settings for a database environment, an application
19creates a configuration object, customizes settings and uses it for
20environment construction. The set methods of this class validate the
21configuration values when the method is invoked.  An
22IllegalArgumentException is thrown if the value is not valid for that
23attribute.
24<p>
25All commonly used environment attributes have convenience setter/getter
26methods defined in this class.  For example, to change the default
27transaction timeout setting for an environment, the application should
28do the following:
29<p>
30<blockquote><pre>
31    // customize an environment configuration
32    EnvironmentConfig envConfig = new EnvironmentConfig();
33    envConfig.setTxnTimeout(10000);  // will throw if timeout value is invalid
34    // Open the environment.
35    Environment myEnvironment = new Environment(home, envConfig);
36</pre></blockquote>
37<p>
38Additional parameters are described in the example.properties file found at
39the top level of the distribution package. These additional parameters
40will not be needed by most applications. This category of
41properties can be specified for the EnvironmentConfig object through a
42Properties object read by EnvironmentConfig(Properties), or
43individually through EnvironmentConfig.setConfigParam().
44<p>
45For example, an application can change the default btree node size with:
46<blockquote><pre>
47    envConfig.setConfigParam("je.nodeMaxEntries", "256");
48</pre></blockquote>
49<p>
50Environment configuration follows this order of precedence:
51<ol>
52<li>Configuration parameters specified in &lt;environment
53home&gt;/je.properties take first precedence.
54<li>Configuration parameters set in the EnvironmentConfig object used
55at Environment construction are next.
56<li>Any configuration parameters not set by the application are set to
57system defaults, described in the example.properties file.
58</ol>
59<p>
60An EnvironmentConfig can be used to specify both mutable and immutable
61environment properties.  Immutable properties may be specified when the
62first Environment handle (instance) is opened for a given physical
63environment.  When more handles are opened for the same environment, the
64following rules apply:
65<p>
66<ol>
67<li>Immutable properties must equal the original values specified when
68constructing an Environment handle for an already open environment.  When a
69mismatch occurs, an exception is thrown.
70<li>Mutable properties are ignored when constructing an Environment
71handle for an already open environment.
72</ol>
73<p>
74After an Environment has been constructed, its mutable properties may
75be changed using
76{@link Environment#setConfig}.
77<p>
78*/
79public class EnvironmentConfig implements Cloneable {
80    /*
81     * For internal use, to allow null as a valid value for
82     * the config parameter.
83     */
84    public static final EnvironmentConfig DEFAULT = new EnvironmentConfig();
85
86    /* package */
87    static EnvironmentConfig checkNull(EnvironmentConfig config) {
88        return (config == null) ? DEFAULT : config;
89    }
90
91    /* Parameters */
92    private int mode = 0644;
93    private int cacheCount = 0;
94    private long cacheSize = 0L;
95    private long cacheMax = 0L;
96    private java.util.Vector dataDirs = new java.util.Vector();
97    private int envid = 0;
98    private String errorPrefix = null;
99    private java.io.OutputStream errorStream = null;
100    private java.io.OutputStream messageStream = null;
101    private byte[][] lockConflicts = null;
102    private LockDetectMode lockDetectMode = LockDetectMode.NONE;
103    private int maxLocks = 0;
104    private int maxLockers = 0;
105    private int maxLockObjects = 0;
106    private int maxLogFileSize = 0;
107    private int logBufferSize = 0;
108    private java.io.File logDirectory = null;
109    private int logFileMode = 0;
110    private int logRegionSize = 0;
111    private int maxMutexes = 0;
112    private int maxOpenFiles = 0;
113    private int maxWrite = 0;
114    private long maxWriteSleep = 0L;
115    private int mutexAlignment = 0;
116    private int mutexIncrement = 0;
117    private int mutexTestAndSetSpins = 0;
118    private long mmapSize = 0L;
119    private String password = null;
120    private int replicationClockskewFast = 0;
121    private int replicationClockskewSlow = 0;
122    private long replicationLimit = 0L;
123    private int replicationNumSites = 0;
124    private int replicationPriority = DbConstants.DB_REP_DEFAULT_PRIORITY;
125    private int replicationRequestMin = 0;
126    private int replicationRequestMax = 0;
127    private String rpcServer = null;
128    private long rpcClientTimeout = 0L;
129    private long rpcServerTimeout = 0L;
130    private long segmentId = 0L;
131    private long lockTimeout = 0L;
132    private int txnMaxActive = 0;
133    private long txnTimeout = 0L;
134    private java.util.Date txnTimestamp = null;
135    private java.io.File temporaryDirectory = null;
136    private ReplicationManagerAckPolicy repmgrAckPolicy =
137        ReplicationManagerAckPolicy.ALL;
138    private ReplicationHostAddress repmgrLocalSiteAddr = null;
139    private java.util.Map repmgrRemoteSites = new java.util.HashMap();
140
141    /* Open flags */
142    private boolean allowCreate = false;
143    private boolean initializeCache = false;
144    private boolean initializeCDB = false;
145    private boolean initializeLocking = false;
146    private boolean initializeLogging = false;
147    private boolean initializeReplication = false;
148    private boolean joinEnvironment = false;
149    private boolean lockDown = false;
150    private boolean isPrivate = false;
151    private boolean register = false;
152    private boolean runRecovery = false;
153    private boolean runFatalRecovery = false;
154    private boolean systemMemory = false;
155    private boolean threaded = true;  // Handles are threaded by default in Java
156    private boolean transactional = false;
157    private boolean useEnvironment = false;
158    private boolean useEnvironmentRoot = false;
159
160    /* Flags */
161    private boolean cdbLockAllDatabases = false;
162    private boolean directDatabaseIO = false;
163    private boolean directLogIO = false;
164    private boolean dsyncDatabases = false;
165    private boolean dsyncLog = false;
166    private boolean initializeRegions = false;
167    private boolean logAutoRemove = false;
168    private boolean logInMemory = false;
169    private boolean logZero = false;
170    private boolean multiversion = false;
171    private boolean noLocking = false;
172    private boolean noMMap = false;
173    private boolean noPanic = false;
174    private boolean overwrite = false;
175    private boolean txnNoSync = false;
176    private boolean txnNoWait = false;
177    private boolean txnNotDurable = false;
178    private boolean txnSnapshot = false;
179    private boolean txnWriteNoSync = false;
180    private boolean yieldCPU = false;
181
182    /* Verbose Flags */
183    private boolean verboseDeadlock = false;
184    private boolean verboseFileops = false;
185    private boolean verboseFileopsAll = false;
186    private boolean verboseRecovery = false;
187    private boolean verboseRegister = false;
188    private boolean verboseReplication = false;
189    private boolean verboseWaitsFor = false;
190
191    /* Callbacks */
192    private ErrorHandler errorHandler = null;
193    private FeedbackHandler feedbackHandler = null;
194    private LogRecordHandler logRecordHandler = null;
195    private EventHandler eventHandler = null;
196    private MessageHandler messageHandler = null;
197    private PanicHandler panicHandler = null;
198    private ReplicationTransport replicationTransport = null;
199
200    /**
201    Create an EnvironmentConfig initialized with the system default settings.
202    */
203    public EnvironmentConfig() {
204    }
205
206    /**
207    Configure the database environment to create any underlying files,
208    as necessary.
209    <p>
210    @param allowCreate
211    If true, configure the database environment to create any underlying
212    files, as necessary.
213    */
214    public void setAllowCreate(final boolean allowCreate) {
215        this.allowCreate = allowCreate;
216    }
217
218    /**
219Return true if the database environment is configured to create any
220    underlying files, as necessary.
221<p>
222This method may be called at any time during the life of the application.
223<p>
224@return
225True if the database environment is configured to create any
226    underlying files, as necessary.
227    */
228    public boolean getAllowCreate() {
229        return allowCreate;
230    }
231
232    /**
233    Set the size of the shared memory buffer pool, that is, the size of the
234cache.
235<p>
236The cache should be the size of the normal working data set of the
237application, with some small amount of additional memory for unusual
238situations.  (Note: the working set is not the same as the number of
239pages accessed simultaneously, and is usually much larger.)
240<p>
241The default cache size is 256KB, and may not be specified as less than
24220KB.  Any cache size less than 500MB is automatically increased by 25%
243to account for buffer pool overhead; cache sizes larger than 500MB are
244used as specified.  The current maximum size of a single cache is 4GB.
245(All sizes are in powers-of-two, that is, 256KB is 2^18 not 256,000.)
246<p>
247The database environment's cache size may also be set using the environment's
248DB_CONFIG file.  The syntax of the entry in that file is a single line
249with the string "set_cachesize", one or more whitespace characters, and the cache size specified in three parts: the gigabytes of cache, the
250additional bytes of cache, and the number of caches, also separated by
251whitespace characters.  For example, "set_cachesize 2 524288000 3" would
252create a 2.5GB logical cache, split between three physical caches.
253Because the DB_CONFIG file is read when the database environment is
254opened, it will silently overrule configuration done before that time.
255<p>
256This method configures a database environment, including all threads
257of control accessing the database environment, not only the operations
258performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
259<p>
260This method may not be called after the
261environment has been opened.
262If joining an existing database environment, any
263information specified to this method will be ignored.
264<p>
265This method may be called at any time during the life of the application.
266<p>
267@param cacheSize
268The size of the shared memory buffer pool, that is, the size of the
269cache.
270<p>
271<p>
272@throws DatabaseException if a failure occurs.
273    */
274    public void setCacheSize(final long cacheSize) {
275        this.cacheSize = cacheSize;
276    }
277
278    /**
279Return the size of the shared memory buffer pool, that is, the cache.
280<p>
281This method may be called at any time during the life of the application.
282<p>
283@return
284The size of the shared memory buffer pool, that is, the cache.
285    */
286    public long getCacheSize() {
287        return cacheSize;
288    }
289
290    /**
291    Set the maximum cache size in bytes. The specified size is rounded to the
292    nearest multiple of the cache region size, which is the initial cache size
293    divded by the number of regions specified to {@link #setCacheCount}. If no
294    value is specified, it defaults to the initial cache size.
295    */
296    public void setCacheMax(final long cacheMax) {
297        this.cacheMax = cacheMax;
298    }
299
300    /**
301Return the maximum size of the cache.
302<p>
303This method may be called at any time during the life of the application.
304<p>
305@return
306The maximum size of the cache.
307    */
308    public long getCacheMax() {
309        return cacheMax;
310    }
311
312    /**
313    Set the number of shared memory buffer pools, that is, the number of
314caches.
315<p>
316It is possible to specify caches larger than 4GB and/or large enough
317they cannot be allocated contiguously on some architectures.  For
318example, some releases of Solaris limit the amount of memory that may
319be allocated contiguously by a process.  This method allows applications
320to break the cache broken up into a number of  equally sized, separate
321pieces of memory.
322<p>
323<p>
324The database environment's cache size may also be set using the environment's
325DB_CONFIG file.  The syntax of the entry in that file is a single line
326with the string "set_cachesize", one or more whitespace characters, and the cache size specified in three parts: the gigabytes of cache, the
327additional bytes of cache, and the number of caches, also separated by
328whitespace characters.  For example, "set_cachesize 2 524288000 3" would
329create a 2.5GB logical cache, split between three physical caches.
330Because the DB_CONFIG file is read when the database environment is
331opened, it will silently overrule configuration done before that time.
332<p>
333This method configures a database environment, including all threads
334of control accessing the database environment, not only the operations
335performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
336<p>
337This method may not be called after the
338environment has been opened.
339If joining an existing database environment, any
340information specified to this method will be ignored.
341<p>
342This method may be called at any time during the life of the application.
343<p>
344@param cacheCount
345The number of shared memory buffer pools, that is, the number of caches.
346<p>
347<p>
348@throws DatabaseException if a failure occurs.
349    */
350    public void setCacheCount(final int cacheCount) {
351        this.cacheCount = cacheCount;
352    }
353
354    /**
355Return the number of shared memory buffer pools, that is, the number
356    of cache regions.
357<p>
358This method may be called at any time during the life of the application.
359<p>
360@return
361The number of shared memory buffer pools, that is, the number
362    of cache regions.
363    */
364    public int getCacheCount() {
365        return cacheCount;
366    }
367
368    /**
369    Configure Concurrent Data Store applications to perform locking on
370    an environment-wide basis rather than on a per-database basis.
371    <p>
372    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
373any other library handles opened within the scope of that handle).
374For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
375handles opened in the database environment must either call this method
376or the configuration should be specified in the database environment's
377DB_CONFIG configuration file.
378    <p>
379    This method may not be called after the
380environment has been opened.
381    <p>
382    @param cdbLockAllDatabases
383    If true, configure Concurrent Data Store applications to perform
384    locking on an environment-wide basis rather than on a per-database
385    basis.
386    */
387    public void setCDBLockAllDatabases(final boolean cdbLockAllDatabases) {
388        this.cdbLockAllDatabases = cdbLockAllDatabases;
389    }
390
391    /**
392Return true if the Concurrent Data Store applications are configured to
393    perform locking on an environment-wide basis rather than on a
394    per-database basis.
395<p>
396This method may be called at any time during the life of the application.
397<p>
398@return
399True if the Concurrent Data Store applications are configured to
400    perform locking on an environment-wide basis rather than on a
401    per-database basis.
402    */
403    public boolean getCDBLockAllDatabases() {
404        return cdbLockAllDatabases;
405    }
406
407    /**
408    Set the path of a directory to be used as the location of the access
409    method database files.
410    <p>
411    Paths specified to {@link com.sleepycat.db.Environment#openDatabase Environment.openDatabase} and
412    {@link com.sleepycat.db.Environment#openSecondaryDatabase Environment.openSecondaryDatabase} will be searched
413    relative to this path.  Paths set using this method are additive, and
414    specifying more than one will result in each specified directory
415    being searched for database files.  If any directories are
416    specified, created database files will always be created in the
417    first path specified.
418    <p>
419    If no database directories are specified, database files must be named
420    either by absolute paths or relative to the environment home directory.
421    <p>
422    The database environment's data directories may also be set using the environment's
423DB_CONFIG file.  The syntax of the entry in that file is a single line
424with the string "set_data_dir", one or more whitespace characters, and the directory name.
425    <p>
426    This method configures only operations performed using a single a
427{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
428    <p>
429    This method may not be called after the
430environment has been opened.
431If joining an existing database environment, the
432information specified to this method must be consistent with the
433existing environment or corruption can occur.
434    <p>
435    @param dataDir
436    A directory to be used as a location for database files.
437    On Windows platforms, this argument will be interpreted as a UTF-8
438string, which is equivalent to ASCII for Latin characters.
439    */
440    public void addDataDir(final java.io.File dataDir) {
441        this.dataDirs.add(dataDir);
442    }
443
444    /** @deprecated replaced by {@link #addDataDir(java.io.File)} */
445    public void addDataDir(final String dataDir) {
446        this.addDataDir(new java.io.File(dataDir));
447    }
448
449    /**
450Return the array of data directories.
451<p>
452This method may be called at any time during the life of the application.
453<p>
454@return
455The array of data directories.
456    */
457    public java.io.File[] getDataDirs() {
458        final java.io.File[] dirs = new java.io.File[dataDirs.size()];
459        dataDirs.copyInto(dirs);
460        return dirs;
461    }
462
463    /**
464    Configure the database environment to not buffer database files.
465    <p>
466    This is intended to avoid to avoid double caching.
467    <p>
468    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
469any other library handles opened within the scope of that handle).
470For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
471handles opened in the database environment must either call this method
472or the configuration should be specified in the database environment's
473DB_CONFIG configuration file.
474    <p>
475    This method may be called at any time during the life of the application.
476    <p>
477    @param directDatabaseIO
478    If true, configure the database environment to not buffer database files.
479    */
480    public void setDirectDatabaseIO(final boolean directDatabaseIO) {
481        this.directDatabaseIO = directDatabaseIO;
482    }
483
484    /**
485Return true if the database environment has been configured to not buffer
486    database files.
487<p>
488This method may be called at any time during the life of the application.
489<p>
490@return
491True if the database environment has been configured to not buffer
492    database files.
493    */
494    public boolean getDirectDatabaseIO() {
495        return directDatabaseIO;
496    }
497
498    /**
499    Configure the database environment to not buffer log files.
500    <p>
501    This is intended to avoid to avoid double caching.
502    <p>
503    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
504any other library handles opened within the scope of that handle).
505For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
506handles opened in the database environment must either call this method
507or the configuration should be specified in the database environment's
508DB_CONFIG configuration file.
509    <p>
510    This method may be called at any time during the life of the application.
511    <p>
512    @param directLogIO
513    If true, configure the database environment to not buffer log files.
514    */
515    public void setDirectLogIO(final boolean directLogIO) {
516        this.directLogIO = directLogIO;
517    }
518
519    /**
520Return true if the database environment has been configured to not buffer
521    log files.
522<p>
523This method may be called at any time during the life of the application.
524<p>
525@return
526True if the database environment has been configured to not buffer
527    log files.
528    */
529    public boolean getDirectLogIO() {
530        return directLogIO;
531    }
532
533    /**
534    Configure the database environment to flush database writes to the backing
535    disk before returning from the write system call, rather than flushing
536    database writes explicitly in a separate system call, as necessary.
537    <p>
538    This is only available on some systems (for example, systems supporting the
539    m4_posix1_name standard O_DSYNC flag, or systems supporting the Win32
540    FILE_FLAG_WRITE_THROUGH flag).  This flag may result in inaccurate file
541    modification times and other file-level information for Berkeley DB database
542    files.  This flag will almost certainly result in a performance decrease on
543    most systems.  This flag is only applicable to certain filesysystem (for
544    example, the Veritas VxFS filesystem), where the filesystem's support for
545    trickling writes back to stable storage behaves badly (or more likely, has
546    been misconfigured).
547    <p>
548    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
549any other library handles opened within the scope of that handle).
550For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
551handles opened in the database environment must either call this method
552or the configuration should be specified in the database environment's
553DB_CONFIG configuration file.
554    <p>
555    This method may be called at any time during the life of the application.
556    <p>
557    @param dsyncDatabases
558    If true, configure the database environment to flush database writes to the
559    backing disk before returning from the write system call, rather than
560    flushing log writes explicitly in a separate system call.
561    */
562    public void setDsyncDatabases(final boolean dsyncDatabases) {
563        this.dsyncDatabases = dsyncDatabases;
564    }
565
566    /**
567Return true if the database environment has been configured to flush database
568    writes to the backing disk before returning from the write system call.
569<p>
570This method may be called at any time during the life of the application.
571<p>
572@return
573True if the database environment has been configured to flush database
574    writes to the backing disk before returning from the write system call.
575    */
576    public boolean getDsyncDatabases() {
577        return dsyncDatabases;
578    }
579
580    /**
581    Configure the database environment to flush log writes to the
582    backing disk before returning from the write system call, rather
583    than flushing log writes explicitly in a separate system call.
584    <p>
585    This configuration is only available on some systems (for example,
586    systems supporting the POSIX standard O_DSYNC flag, or systems
587    supporting the Win32 FILE_FLAG_WRITE_THROUGH flag).  This
588    configuration may result in inaccurate file modification times and
589    other file-level information for Berkeley DB log files.  This
590    configuration may offer a performance increase on some systems and
591    a performance decrease on others.
592    <p>
593    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
594any other library handles opened within the scope of that handle).
595For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
596handles opened in the database environment must either call this method
597or the configuration should be specified in the database environment's
598DB_CONFIG configuration file.
599    <p>
600    This method may be called at any time during the life of the application.
601    <p>
602    @param dsyncLog
603    If true, configure the database environment to flush log writes to
604    the backing disk before returning from the write system call, rather
605    than flushing log writes explicitly in a separate system call.
606    */
607    public void setDsyncLog(final boolean dsyncLog) {
608        this.dsyncLog = dsyncLog;
609    }
610
611    /**
612Return true if the database environment has been configured to flush log
613    writes to the backing disk before returning from the write system
614    call.
615<p>
616This method may be called at any time during the life of the application.
617<p>
618@return
619True if the database environment has been configured to flush log
620    writes to the backing disk before returning from the write system
621    call.
622    */
623    public boolean getDsyncLog() {
624        return dsyncLog;
625    }
626
627    /**
628    Set the password used to perform encryption and decryption.
629    <p>
630    Berkeley DB uses the Rijndael/AES (also known as the Advanced
631    Encryption Standard and Federal Information Processing
632    Standard (FIPS) 197) algorithm for encryption or decryption.
633    */
634    public void setEncrypted(final String password) {
635        this.password = password;
636    }
637
638    /**
639Return the database environment has been configured to perform
640    encryption.
641<p>
642This method may be called at any time during the life of the application.
643<p>
644@return
645The database environment has been configured to perform
646    encryption.
647    */
648    public boolean getEncrypted() {
649        return (password != null);
650    }
651
652    /**
653    Set the function to be called if an error occurs.
654<p>
655When an error occurs in the Berkeley DB library, an exception is thrown.
656In some cases, however, the error information returned to the
657application may be insufficient to completely describe the cause of the
658error, especially during initial application debugging.
659<p>
660The {@link com.sleepycat.db.EnvironmentConfig#setErrorHandler EnvironmentConfig.setErrorHandler} and {@link com.sleepycat.db.DatabaseConfig#setErrorHandler DatabaseConfig.setErrorHandler} methods are used to enhance the mechanism for reporting
661error messages to the application.  In some cases, when an error occurs,
662Berkeley DB will invoke the ErrorHandler's object error method.  It is
663up to this method to display the error message in an appropriate manner.
664<p>
665Alternatively, applications can use {@link com.sleepycat.db.EnvironmentConfig#setErrorStream EnvironmentConfig.setErrorStream} and {@link com.sleepycat.db.DatabaseConfig#setErrorStream DatabaseConfig.setErrorStream} to
666display the additional information via an output stream.  Applications
667should not mix these approaches.
668<p>
669This error-logging enhancement does not slow performance or significantly
670increase application size, and may be run during normal operation as well
671as during application debugging.
672<p>
673This method may be called at any time during the life of the application.
674<p>
675@param errorHandler
676The function to be called if an error occurs.
677    */
678    public void setErrorHandler(final ErrorHandler errorHandler) {
679        this.errorHandler = errorHandler;
680    }
681
682    /**
683Return the function to be called if an error occurs.
684<p>
685This method may be called at any time during the life of the application.
686<p>
687@return
688The function to be called if an error occurs.
689    */
690    public ErrorHandler getErrorHandler() {
691        return errorHandler;
692    }
693
694    /**
695    Set the prefix string that appears before error messages.
696<p>
697This method may be called at any time during the life of the application.
698<p>
699@param errorPrefix
700The prefix string that appears before error messages.
701    */
702    public void setErrorPrefix(final String errorPrefix) {
703        this.errorPrefix = errorPrefix;
704    }
705
706    /**
707Return the prefix string that appears before error messages.
708<p>
709This method may be called at any time during the life of the application.
710<p>
711@return
712The prefix string that appears before error messages.
713    */
714    public String getErrorPrefix() {
715        return errorPrefix;
716    }
717
718    /**
719    Set an OutputStream for displaying error messages.
720<p>
721When an error occurs in the Berkeley DB library, an exception is thrown.
722In some cases, however, the error information returned to the
723application may be insufficient to completely describe the cause of the
724error, especially during initial application debugging.
725<p>
726The {@link com.sleepycat.db.EnvironmentConfig#setErrorStream EnvironmentConfig.setErrorStream} and
727{@link com.sleepycat.db.DatabaseConfig#setErrorStream DatabaseConfig.setErrorStream} methods are used to enhance
728the mechanism for reporting error messages to the application by setting
729a OutputStream to be used for displaying additional Berkeley DB error
730messages.  In some cases, when an error occurs, Berkeley DB will output
731an additional error message to the specified stream.
732<p>
733The error message will consist of the prefix string and a colon
734("<b>:</b>") (if a prefix string was previously specified using
735{@link com.sleepycat.db.EnvironmentConfig#setErrorPrefix EnvironmentConfig.setErrorPrefix} or {@link com.sleepycat.db.DatabaseConfig#setErrorPrefix DatabaseConfig.setErrorPrefix}), an error string, and a trailing newline character.
736<p>
737Setting errorStream to null unconfigures the interface.
738<p>
739Alternatively, applications can use {@link com.sleepycat.db.EnvironmentConfig#setErrorHandler EnvironmentConfig.setErrorHandler} and {@link com.sleepycat.db.DatabaseConfig#setErrorHandler DatabaseConfig.setErrorHandler} to capture
740the additional error information in a way that does not use output
741streams.  Applications should not mix these approaches.
742<p>
743This error-logging enhancement does not slow performance or significantly
744increase application size, and may be run during normal operation as well
745as during application debugging.
746<p>
747This method may be called at any time during the life of the application.
748<p>
749@param errorStream
750The application-specified OutputStream for error messages.
751    */
752    public void setErrorStream(final java.io.OutputStream errorStream) {
753        this.errorStream = errorStream;
754    }
755
756    /**
757Return the an OutputStream for displaying error messages.
758<p>
759This method may be called at any time during the life of the application.
760<p>
761@return
762The an OutputStream for displaying error messages.
763    */
764    public java.io.OutputStream getErrorStream() {
765        return errorStream;
766    }
767
768    /**
769    Set an object whose methods are to be called when a triggered event occurs.
770    <p>
771    @param eventHandler
772    An object whose methods are called when event callbacks are initiated from
773    within Berkeley DB.
774    */
775    public void setEventHandler(final EventHandler eventHandler) {
776        this.eventHandler = eventHandler;
777    }
778
779    /**
780Return the object's methods to be called when a triggered event occurs.
781<p>
782This method may be called at any time during the life of the application.
783<p>
784@return
785The object's methods to be called when a triggered event occurs.
786    */
787    public EventHandler getEventHandler() {
788        return eventHandler;
789    }
790
791    /**
792    Set an object whose methods are called to provide feedback.
793<p>
794Some operations performed by the Berkeley DB library can take
795non-trivial amounts of time.  This method can be used by applications
796to monitor progress within these operations.  When an operation is
797likely to take a long time, Berkeley DB will call the object's methods
798with progress information.
799<p>
800It is up to the object's methods to display this information in an
801appropriate manner.
802<p>
803This method configures only operations performed using a single a
804{@link com.sleepycat.db.Environment Environment} handle
805<p>
806This method may be called at any time during the life of the application.
807<p>
808@param feedbackHandler
809An object whose methods are called to provide feedback.
810    */
811    public void setFeedbackHandler(final FeedbackHandler feedbackHandler) {
812        this.feedbackHandler = feedbackHandler;
813    }
814
815    /**
816Return the object's methods to be called to provide feedback.
817<p>
818This method may be called at any time during the life of the application.
819<p>
820@return
821The object's methods to be called to provide feedback.
822    */
823    public FeedbackHandler getFeedbackHandler() {
824        return feedbackHandler;
825    }
826
827    /**
828    Configure a shared memory buffer pool in the database environment.
829    <p>
830    This subsystem should be used whenever an application is using any
831    Berkeley DB access method.
832    <p>
833    @param initializeCache
834    If true, configure a shared memory buffer pool in the database
835    environment.
836    */
837    public void setInitializeCache(final boolean initializeCache) {
838        this.initializeCache = initializeCache;
839    }
840
841    /**
842Return true if the database environment is configured with a shared
843    memory buffer pool.
844<p>
845This method may be called at any time during the life of the application.
846<p>
847@return
848True if the database environment is configured with a shared
849    memory buffer pool.
850    */
851    public boolean getInitializeCache() {
852        return initializeCache;
853    }
854
855    /**
856    Configure the database environment for the Concurrent Data Store
857    product.
858    <p>
859    In this mode, Berkeley DB provides multiple reader/single writer access.
860    The only other subsystem that should be specified for this handle is a
861    cache.
862    <p>
863    @param initializeCDB
864    If true, configure the database environment for the Concurrent Data
865    Store product.
866    */
867    public void setInitializeCDB(final boolean initializeCDB) {
868        this.initializeCDB = initializeCDB;
869    }
870
871    /**
872Return true if the database environment is configured for the Concurrent
873    Data Store product.
874<p>
875This method may be called at any time during the life of the application.
876<p>
877@return
878True if the database environment is configured for the Concurrent
879    Data Store product.
880    */
881    public boolean getInitializeCDB() {
882        return initializeCDB;
883    }
884
885    /**
886    Configure the database environment for locking.
887    <p>
888    Locking should be used when multiple processes or threads are going
889    to be reading and writing a database, so they do not interfere with
890    each other.  If all threads are accessing the database(s) read-only,
891    locking is unnecessary.  When locking is configured, it is usually
892    necessary to run a deadlock detector, as well.
893    <p>
894    @param initializeLocking
895    If true, configure the database environment for locking.
896    */
897    public void setInitializeLocking(final boolean initializeLocking) {
898        this.initializeLocking = initializeLocking;
899    }
900
901    /**
902Return true if the database environment is configured for locking.
903<p>
904This method may be called at any time during the life of the application.
905<p>
906@return
907True if the database environment is configured for locking.
908    */
909    public boolean getInitializeLocking() {
910        return initializeLocking;
911    }
912
913    /**
914    Configure the database environment for logging.
915    <p>
916    Logging should be used when recovery from application or system
917    failure is necessary.  If the log region is being created and log
918    files are already present, the log files are reviewed; subsequent
919    log writes are appended to the end of the log, rather than overwriting
920    current log entries.
921    <p>
922    @param initializeLogging
923    If true, configure the database environment for logging.
924    */
925    public void setInitializeLogging(final boolean initializeLogging) {
926        this.initializeLogging = initializeLogging;
927    }
928
929    /**
930Return true if the database environment is configured for logging.
931<p>
932This method may be called at any time during the life of the application.
933<p>
934@return
935True if the database environment is configured for logging.
936    */
937    public boolean getInitializeLogging() {
938        return initializeLogging;
939    }
940
941    /**
942    Configure the database environment to page-fault shared regions into
943    memory when initially creating or joining a database environment.
944    <p>
945    In some applications, the expense of page-faulting the underlying
946    shared memory regions can affect performance.  For example, if the
947    page-fault occurs while holding a lock, other lock requests can
948    convoy, and overall throughput may decrease.  This method
949    configures Berkeley DB to page-fault shared regions into memory when
950    initially creating or joining a database environment.  In addition,
951    Berkeley DB will write the shared regions when creating an
952    environment, forcing the underlying virtual memory and filesystems
953    to instantiate both the necessary memory and the necessary disk
954    space.  This can also avoid out-of-disk space failures later on.
955    <p>
956    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
957any other library handles opened within the scope of that handle).
958For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
959handles opened in the database environment must either call this method
960or the configuration should be specified in the database environment's
961DB_CONFIG configuration file.
962    <p>
963    This method may be called at any time during the life of the application.
964    <p>
965    @param initializeRegions
966    If true, configure the database environment to page-fault shared
967    regions into memory when initially creating or joining a database
968    environment.
969    */
970    public void setInitializeRegions(final boolean initializeRegions) {
971        this.initializeRegions = initializeRegions;
972    }
973
974    /**
975Return true if the database environment has been configured to page-fault
976    shared regions into memory when initially creating or joining a
977    database environment.
978<p>
979This method may be called at any time during the life of the application.
980<p>
981@return
982True if the database environment has been configured to page-fault
983    shared regions into memory when initially creating or joining a
984    database environment.
985    */
986    public boolean getInitializeRegions() {
987        return initializeRegions;
988    }
989
990    /**
991    Configure the database environment for replication.
992    <p>
993    Replication requires both locking and transactions.
994    <p>
995    @param initializeReplication
996    If true, configure the database environment for replication.
997    */
998    public void setInitializeReplication(final boolean initializeReplication) {
999        this.initializeReplication = initializeReplication;
1000    }
1001
1002    /**
1003Return true if the database environment is configured for replication.
1004<p>
1005This method may be called at any time during the life of the application.
1006<p>
1007@return
1008True if the database environment is configured for replication.
1009    */
1010    public boolean getInitializeReplication() {
1011        return initializeReplication;
1012    }
1013
1014    /**
1015    Configure the handle to join an existing environment.
1016    <p>
1017    This option allows applications to join an existing environment
1018    without knowing which subsystems the environment supports.
1019    <p>
1020    @param joinEnvironment
1021    If true, configure the handle to join an existing environment.
1022    */
1023    public void setJoinEnvironment(final boolean joinEnvironment) {
1024        this.joinEnvironment = joinEnvironment;
1025    }
1026
1027    /**
1028Return the handle is configured to join an existing environment.
1029<p>
1030This method may be called at any time during the life of the application.
1031<p>
1032@return
1033The handle is configured to join an existing environment.
1034    */
1035    public boolean getJoinEnvironment() {
1036        return joinEnvironment;
1037    }
1038
1039    /**
1040    Configure the locking conflicts matrix.
1041    <p>
1042    If the locking conflicts matrix is never configured, a standard
1043    conflicts array is used.
1044    <p>
1045    This method configures a database environment, including all threads
1046of control accessing the database environment, not only the operations
1047performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1048    <p>
1049    This method may not be called after the
1050environment has been opened.
1051If joining an existing database environment, any
1052information specified to this method will be ignored.
1053    <p>
1054    @param lockConflicts
1055    The locking conflicts matrix.  A non-0 value for an array element
1056    indicates the requested_mode and held_mode conflict:
1057    <blockquote><pre>
1058        lockConflicts[requested_mode][held_mode]
1059    </pre></blockquote>
1060    <p>
1061    The <em>not-granted</em> mode must be represented by 0.
1062    */
1063    public void setLockConflicts(final byte[][] lockConflicts) {
1064        this.lockConflicts = lockConflicts;
1065    }
1066
1067    /**
1068Return the locking conflicts matrix.
1069<p>
1070This method may be called at any time during the life of the application.
1071<p>
1072@return
1073The locking conflicts matrix.
1074    */
1075    public byte[][] getLockConflicts() {
1076        return lockConflicts;
1077    }
1078
1079    /**
1080    Configure if the deadlock detector is to be run whenever a lock
1081    conflict occurs.
1082    <p>
1083    The database environment's deadlock detector configuration may also be set using the environment's
1084DB_CONFIG file.  The syntax of the entry in that file is a single line
1085with the string "set_lk_detect", one or more whitespace characters, and the method <code>detect</code> parameter as a string; for example,
1086    "set_lk_detect DB_LOCK_OLDEST".
1087Because the DB_CONFIG file is read when the database environment is
1088opened, it will silently overrule configuration done before that time.
1089    <p>
1090    This method configures a database environment, including all threads
1091of control accessing the database environment, not only the operations
1092performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1093    <p>
1094    Although the method may be called at any time during the life of the
1095application, it should normally be called before opening the database
1096environment.
1097    <p>
1098    @param lockDetectMode
1099    The lock request(s) to be rejected.  As transactions acquire locks
1100    on behalf of a single locker ID, rejecting a lock request associated
1101    with a transaction normally requires the transaction be aborted.
1102    */
1103    public void setLockDetectMode(final LockDetectMode lockDetectMode) {
1104        this.lockDetectMode = lockDetectMode;
1105    }
1106
1107    /**
1108Return true if the deadlock detector is configured to run whenever a lock
1109    conflict occurs.
1110<p>
1111This method may be called at any time during the life of the application.
1112<p>
1113@return
1114True if the deadlock detector is configured to run whenever a lock
1115    conflict occurs.
1116    */
1117    public LockDetectMode getLockDetectMode() {
1118        return lockDetectMode;
1119    }
1120
1121    /**
1122    Configure the database environment to lock shared environment files
1123    and memory-mapped databases into memory.
1124    <p>
1125    @param lockDown
1126    If true, configure the database environment to lock shared
1127    environment files and memory-mapped databases into memory.
1128    */
1129    public void setLockDown(final boolean lockDown) {
1130        this.lockDown = lockDown;
1131    }
1132
1133    /**
1134Return true if the database environment is configured to lock shared
1135    environment files and memory-mapped databases into memory.
1136<p>
1137This method may be called at any time during the life of the application.
1138<p>
1139@return
1140True if the database environment is configured to lock shared
1141    environment files and memory-mapped databases into memory.
1142    */
1143    public boolean getLockDown() {
1144        return lockDown;
1145    }
1146
1147    /**
1148    Set the timeout value for the database environment
1149locks.
1150<p>
1151Lock timeouts are checked whenever a thread of control blocks on a lock
1152or when deadlock detection is performed.  The lock may have been
1153requested explicitly through the Lock subsystem interfaces, or it may
1154be a lock requested by the database access methods underlying the
1155application.
1156As timeouts are only checked when the lock request first blocks or when
1157deadlock detection is performed, the accuracy of the timeout depends on
1158how often deadlock detection is performed.
1159<p>
1160Timeout values specified for the database environment may be overridden
1161on a
1162per-lock basis by {@link com.sleepycat.db.Environment#lockVector Environment.lockVector}.
1163<p>
1164This method configures a database environment, including all threads
1165of control accessing the database environment, not only the operations
1166performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1167<p>
1168This method may be called at any time during the life of the application.
1169<p>
1170@param lockTimeout
1171The timeout value, specified as an unsigned 32-bit number of
1172microseconds, limiting the maximum timeout to roughly 71 minutes.
1173<p>
1174<p>
1175@throws IllegalArgumentException if an invalid parameter was specified.
1176<p>
1177@throws DatabaseException if a failure occurs.
1178    */
1179    public void setLockTimeout(final long lockTimeout) {
1180        this.lockTimeout = lockTimeout;
1181    }
1182
1183    /**
1184Return the database environment lock timeout value, in microseconds;
1185    a timeout of 0 means no timeout is set.
1186<p>
1187This method may be called at any time during the life of the application.
1188<p>
1189@return
1190The database environment lock timeout value, in microseconds;
1191    a timeout of 0 means no timeout is set.
1192    */
1193    public long getLockTimeout() {
1194        return lockTimeout;
1195    }
1196
1197    /**
1198    Configure the system to automatically remove log files that are no
1199    longer needed.
1200    <p>
1201    Automatic log file removal is likely to make catastrophic recovery
1202    impossible.
1203    <p>
1204    This method configures a database environment, including all threads
1205of control accessing the database environment, not only the operations
1206performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1207    <p>
1208    This method may be called at any time during the life of the application.
1209    <p>
1210    @param logAutoRemove
1211    If true, configure the system to automatically remove log files that
1212    are no longer needed.
1213    */
1214    public void setLogAutoRemove(final boolean logAutoRemove) {
1215        this.logAutoRemove = logAutoRemove;
1216    }
1217
1218    /**
1219Return true if the system has been configured to to automatically remove log
1220    files that are no longer needed.
1221<p>
1222This method may be called at any time during the life of the application.
1223<p>
1224@return
1225True if the system has been configured to to automatically remove log
1226    files that are no longer needed.
1227    */
1228    public boolean getLogAutoRemove() {
1229        return logAutoRemove;
1230    }
1231
1232    /**
1233    If set, maintain transaction logs in memory rather than on disk. This means
1234    that transactions exhibit the ACI (atomicity, consistency, and isolation)
1235    properties, but not D (durability); that is, database integrity will be
1236    maintained, but if the application or system fails, integrity will not
1237    persist. All database files must be verified and/or restored from a
1238    replication group master or archival backup after application or system
1239    failure.
1240    <p>
1241    When in-memory logs are configured and no more log buffer space is
1242    available, Berkeley DB methods will throw a {@link com.sleepycat.db.DatabaseException DatabaseException}.
1243    When choosing log buffer and file sizes for in-memory logs, applications
1244    should ensure the in-memory log buffer size is large enough that no
1245    transaction will ever span the entire buffer, and avoid a state where the
1246    in-memory buffer is full and no space can be freed because a transaction
1247    that started in the first log "file" is still active.
1248    <p>
1249    This method configures a database environment, including all threads
1250of control accessing the database environment, not only the operations
1251performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1252    <p>
1253    This method may not be called after the
1254environment has been opened.
1255If joining an existing database environment, any
1256information specified to this method will be ignored.
1257    <p>
1258    @param logInMemory
1259    If true, maintain transaction logs in memory rather than on disk.
1260    */
1261    public void setLogInMemory(final boolean logInMemory) {
1262        this.logInMemory = logInMemory;
1263    }
1264
1265    /**
1266Return true if the database environment is configured to maintain transaction logs
1267    in memory rather than on disk.
1268<p>
1269This method may be called at any time during the life of the application.
1270<p>
1271@return
1272True if the database environment is configured to maintain transaction logs
1273    in memory rather than on disk.
1274    */
1275    public boolean getLogInMemory() {
1276        return logInMemory;
1277    }
1278
1279    /**
1280    Set a function to process application-specific log records.
1281    <p>
1282    This method configures only operations performed using a single a
1283{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
1284    <p>
1285    This method may not be called after the
1286environment has been opened.
1287If joining an existing database environment, the
1288information specified to this method must be consistent with the
1289existing environment or corruption can occur.
1290    <p>
1291    @param logRecordHandler
1292    The handler for application-specific log records.
1293    */
1294    public void setLogRecordHandler(final LogRecordHandler logRecordHandler) {
1295        this.logRecordHandler = logRecordHandler;
1296    }
1297
1298    /**
1299Return the handler for application-specific log records.
1300<p>
1301This method may be called at any time during the life of the application.
1302<p>
1303@return
1304The handler for application-specific log records.
1305    */
1306    public LogRecordHandler getLogRecordHandler() {
1307        return logRecordHandler;
1308    }
1309
1310    /**
1311    If set, zero all pages of a log file when that log file is created.  This
1312    has been shown to provide greater transaction throughput in some
1313    environments.  The log file will be zeroed by the thread which needs to
1314    re-create the new log file.  Other threads may not write to the log file
1315    while this is happening.
1316    <p>
1317    This method configures the database environment, including all threads of
1318    control accessing the database environment.
1319    <p>
1320    This method may not be called after the environment has been opened.
1321    <p>
1322    @param logZero
1323    If true, zero all pages of new log files upon their creation.
1324    */
1325    public void setLogZero(final boolean logZero) {
1326        this.logZero = logZero;
1327    }
1328
1329    /**
1330    Return true if the database environment is configured to zero all pages of
1331    new log files upon their creation.
1332    <p>
1333    This method may be called at any time during the life of the application.
1334    <p>
1335    @return
1336    True if the database environment is configured to pre-zero log pages.
1337    */
1338    public boolean getLogZero() {
1339        return logZero;
1340    }
1341
1342    /**
1343    Set the network Ack policy used by the replication manager.
1344    <p>
1345    @param repmgrAckPolicy
1346    The network Ack policy used by the replication manager.
1347    */
1348    public void setReplicationManagerAckPolicy(
1349        final ReplicationManagerAckPolicy repmgrAckPolicy)
1350    {
1351        this.repmgrAckPolicy = repmgrAckPolicy;
1352    }
1353
1354    /**
1355    Get the network Ack policy used by the replication manager.
1356    <p>
1357    @return
1358    The network Ack policy used by the replication manager.
1359    */
1360    public ReplicationManagerAckPolicy getReplicationManagerAckPolicy()
1361    {
1362        return repmgrAckPolicy;
1363    }
1364
1365    /**
1366    Set the address of the local (this) site in a replication group.
1367    <p>
1368    @param repmgrLocalSiteAddr
1369    The address of the local site.
1370    */
1371    public void setReplicationManagerLocalSite(
1372        final ReplicationHostAddress repmgrLocalSiteAddr)
1373    {
1374        this.repmgrLocalSiteAddr = repmgrLocalSiteAddr;
1375    }
1376
1377    /**
1378    Get the address of the local (this) site in a replication group.
1379    <p>
1380    @return
1381    The address of the local site.
1382    */
1383    public ReplicationHostAddress getReplicationManagerLocalSite()
1384    {
1385        return repmgrLocalSiteAddr;
1386    }
1387
1388    /**
1389    Add a remote site to a replication group.
1390    <p>
1391    @param repmgrRemoteAddr
1392    The address of the remote site
1393    @param isPeer
1394    Whether the remote site is the local site's peer.
1395    */
1396    public void replicationManagerAddRemoteSite(
1397        final ReplicationHostAddress repmgrRemoteAddr, boolean isPeer)
1398	throws DatabaseException
1399    {
1400        this.repmgrRemoteSites.put(repmgrRemoteAddr, new Boolean(isPeer));
1401    }
1402
1403    /**
1404    Set the maximum number of locks supported by the database
1405    environment.
1406    <p>
1407    This value is used during environment creation to estimate how much
1408    space to allocate for various lock-table data structures.  The
1409    default value is 1000 locks.
1410    <p>
1411    The database environment's maximum number of locks may also be set using the environment's
1412DB_CONFIG file.  The syntax of the entry in that file is a single line
1413with the string "set_lk_max_locks", one or more whitespace characters, and the number of locks.
1414Because the DB_CONFIG file is read when the database environment is
1415opened, it will silently overrule configuration done before that time.
1416    <p>
1417    This method configures a database environment, including all threads
1418of control accessing the database environment, not only the operations
1419performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1420    <p>
1421    This method may not be called after the
1422environment has been opened.
1423If joining an existing database environment, any
1424information specified to this method will be ignored.
1425    <p>
1426    @param maxLocks
1427    The maximum number of locks supported by the database environment.
1428    */
1429    public void setMaxLocks(final int maxLocks) {
1430        this.maxLocks = maxLocks;
1431    }
1432
1433    /**
1434Return the maximum number of locks.
1435<p>
1436This method may be called at any time during the life of the application.
1437<p>
1438@return
1439The maximum number of locks.
1440    */
1441    public int getMaxLocks() {
1442        return maxLocks;
1443    }
1444
1445    /**
1446    Set the maximum number of locking entities supported by the database
1447    environment.
1448    <p>
1449    This value is used during environment creation to estimate how much
1450    space to allocate for various lock-table data structures.  The default
1451    value is 1000 lockers.
1452    <p>
1453    The database environment's maximum number of lockers may also be set using the environment's
1454DB_CONFIG file.  The syntax of the entry in that file is a single line
1455with the string "set_lk_max_lockers", one or more whitespace characters, and the number of lockers.
1456Because the DB_CONFIG file is read when the database environment is
1457opened, it will silently overrule configuration done before that time.
1458    <p>
1459    This method configures a database environment, including all threads
1460of control accessing the database environment, not only the operations
1461performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1462    <p>
1463    This method may not be called after the
1464environment has been opened.
1465If joining an existing database environment, any
1466information specified to this method will be ignored.
1467    <p>
1468    @param maxLockers
1469    The maximum number simultaneous locking entities supported by the
1470    database environment.
1471    */
1472    public void setMaxLockers(final int maxLockers) {
1473        this.maxLockers = maxLockers;
1474    }
1475
1476    /**
1477Return the maximum number of lockers.
1478<p>
1479This method may be called at any time during the life of the application.
1480<p>
1481@return
1482The maximum number of lockers.
1483    */
1484    public int getMaxLockers() {
1485        return maxLockers;
1486    }
1487
1488    /**
1489    Set the maximum number of locked objects supported by the database
1490    environment.
1491    <p>
1492    This value is used during environment creation to estimate how much
1493    space to allocate for various lock-table data structures.  The default
1494    value is 1000 objects.
1495    <p>
1496    The database environment's maximum number of objects may also be set using the environment's
1497DB_CONFIG file.  The syntax of the entry in that file is a single line
1498with the string "set_lk_max_objects", one or more whitespace characters, and the number of objects.
1499Because the DB_CONFIG file is read when the database environment is
1500opened, it will silently overrule configuration done before that time.
1501    <p>
1502    This method configures a database environment, including all threads
1503of control accessing the database environment, not only the operations
1504performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1505    <p>
1506    This method may not be called after the
1507environment has been opened.
1508If joining an existing database environment, any
1509information specified to this method will be ignored.
1510    <p>
1511    @param maxLockObjects
1512    The maximum number of locked objects supported by the database
1513    environment.
1514    */
1515    public void setMaxLockObjects(final int maxLockObjects) {
1516        this.maxLockObjects = maxLockObjects;
1517    }
1518
1519    /**
1520Return the maximum number of locked objects.
1521<p>
1522This method may be called at any time during the life of the application.
1523<p>
1524@return
1525The maximum number of locked objects.
1526    */
1527    public int getMaxLockObjects() {
1528        return maxLockObjects;
1529    }
1530
1531    /**
1532    Set the maximum size of a single file in the log, in bytes.
1533    <p>
1534    By default, or if the maxLogFileSize parameter is set to 0, a size
1535    of 10MB is used.  If no size is specified by the application, the
1536    size last specified for the database region will be used, or if no
1537    database region previously existed, the default will be used.
1538    Because {@link com.sleepycat.db.LogSequenceNumber LogSequenceNumber} file offsets are unsigned four-byte
1539    values, the set value may not be larger than the maximum unsigned
1540    four-byte value.
1541    <p>
1542    The database environment's log file size may also be set using the environment's
1543DB_CONFIG file.  The syntax of the entry in that file is a single line
1544with the string "set_lg_max", one or more whitespace characters, and the size in bytes.
1545Because the DB_CONFIG file is read when the database environment is
1546opened, it will silently overrule configuration done before that time.
1547    <p>
1548    This method configures a database environment, including all threads
1549of control accessing the database environment, not only the operations
1550performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1551    <p>
1552    This method may be called at any time during the life of the application.
1553    <p>
1554    @param maxLogFileSize
1555    The maximum size of a single file in the log, in bytes.
1556    */
1557    public void setMaxLogFileSize(final int maxLogFileSize) {
1558        this.maxLogFileSize = maxLogFileSize;
1559    }
1560
1561    /**
1562Return the maximum size of a single file in the log, in bytes.
1563<p>
1564This method may be called at any time during the life of the application.
1565<p>
1566@return
1567The maximum size of a single file in the log, in bytes.
1568    */
1569    public int getMaxLogFileSize() {
1570        return maxLogFileSize;
1571    }
1572
1573    /**
1574    Set the size of the in-memory log buffer, in bytes.
1575    <p>
1576    Log information is stored in-memory until the storage space fills up
1577    or transaction commit forces the information to be flushed to stable
1578    storage.  In the presence of long-running transactions or transactions
1579    producing large amounts of data, larger buffer sizes can increase
1580    throughput.
1581    <p>
1582    By default, or if the value is set to 0, a size of 32K is used.
1583    <p>
1584    The database environment's log buffer size may also be set using the environment's
1585DB_CONFIG file.  The syntax of the entry in that file is a single line
1586with the string "set_lg_bsize", one or more whitespace characters, and the size in bytes.
1587Because the DB_CONFIG file is read when the database environment is
1588opened, it will silently overrule configuration done before that time.
1589    <p>
1590    This method configures a database environment, including all threads
1591of control accessing the database environment, not only the operations
1592performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1593    <p>
1594    This method may not be called after the
1595environment has been opened.
1596If joining an existing database environment, any
1597information specified to this method will be ignored.
1598    <p>
1599    @param logBufferSize
1600    The size of the in-memory log buffer, in bytes.
1601    */
1602    public void setLogBufferSize(final int logBufferSize) {
1603        this.logBufferSize = logBufferSize;
1604    }
1605
1606    /**
1607Return the size of the in-memory log buffer, in bytes.
1608<p>
1609This method may be called at any time during the life of the application.
1610<p>
1611@return
1612The size of the in-memory log buffer, in bytes.
1613    */
1614    public int getLogBufferSize() {
1615        return logBufferSize;
1616    }
1617
1618    /**
1619    Set the path of a directory to be used as the location of logging files.
1620    <p>
1621    Log files created by the Log Manager subsystem will be created in this
1622    directory.  If no logging directory is specified, log files are
1623    created in the environment home directory.
1624    <p>
1625    For the greatest degree of recoverability from system or application
1626    failure, database files and log files should be located on separate
1627    physical devices.
1628    <p>
1629    The database environment's logging directory may also be set using the environment's
1630DB_CONFIG file.  The syntax of the entry in that file is a single line
1631with the string "set_lg_dir", one or more whitespace characters, and the directory name.
1632Because the DB_CONFIG file is read when the database environment is
1633opened, it will silently overrule configuration done before that time.
1634    <p>
1635    This method configures only operations performed using a single a
1636{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
1637    <p>
1638    This method may not be called after the
1639environment has been opened.
1640If joining an existing database environment, the
1641information specified to this method must be consistent with the
1642existing environment or corruption can occur.
1643    <p>
1644    @param logDirectory
1645    The directory used to store the logging files.
1646    On Windows platforms, this argument will be interpreted as a UTF-8
1647string, which is equivalent to ASCII for Latin characters.
1648    */
1649    public void setLogDirectory(final java.io.File logDirectory) {
1650        this.logDirectory = logDirectory;
1651    }
1652
1653    /**
1654Return the path of a directory to be used as the location of logging files.
1655<p>
1656This method may be called at any time during the life of the application.
1657<p>
1658@return
1659The path of a directory to be used as the location of logging files.
1660    */
1661    public java.io.File getLogDirectory() {
1662        return logDirectory;
1663    }
1664
1665    /**
1666    Set the absolute file mode for created log files.  This method is
1667    <b>only</b> useful for the rare Berkeley DB application that does not
1668    control its umask value.
1669    <p>
1670    Normally, if Berkeley DB applications set their umask appropriately, all
1671    processes in the application suite will have read permission on the log
1672    files created by any process in the application suite.  However, if the
1673    Berkeley DB application is a library, a process using the library might set
1674    its umask to a value preventing other processes in the application suite
1675    from reading the log files it creates.  In this rare case, this method
1676    can be used to set the mode of created log files to an absolute value.
1677    <p>
1678    @param logFileMode
1679    The absolute mode of the created log file.
1680    */
1681    public void setLogFileMode(final int logFileMode) {
1682        this.logFileMode = logFileMode;
1683    }
1684
1685    /**
1686    Return the absolute file mode for created log files.
1687    <p>
1688    This method may be called at any time during the life of the application.
1689    <p>
1690    @return
1691    The absolute file mode for created log files.
1692    */
1693    public int getLogFileMode() {
1694        return logFileMode;
1695    }
1696
1697    /**
1698    Set the size of the underlying logging area of the database
1699    environment, in bytes.
1700    <p>
1701    By default, or if the value is set to 0, the default size is 60KB.
1702    The log region is used to store filenames, and so may need to be
1703    increased in size if a large number of files will be opened and
1704    registered with the specified database environment's log manager.
1705    <p>
1706    The database environment's log region size may also be set using the environment's
1707DB_CONFIG file.  The syntax of the entry in that file is a single line
1708with the string "set_lg_regionmax", one or more whitespace characters, and the size in bytes.
1709Because the DB_CONFIG file is read when the database environment is
1710opened, it will silently overrule configuration done before that time.
1711    <p>
1712    This method configures a database environment, including all threads
1713of control accessing the database environment, not only the operations
1714performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
1715    <p>
1716    This method may not be called after the
1717environment has been opened.
1718If joining an existing database environment, any
1719information specified to this method will be ignored.
1720    <p>
1721    @param logRegionSize
1722    The size of the logging area in the database environment, in bytes.
1723    */
1724    public void setLogRegionSize(final int logRegionSize) {
1725        this.logRegionSize = logRegionSize;
1726    }
1727
1728    /**
1729Return the size of the underlying logging subsystem region.
1730<p>
1731This method may be called at any time during the life of the application.
1732<p>
1733@return
1734The size of the underlying logging subsystem region.
1735    */
1736    public int getLogRegionSize() {
1737        return logRegionSize;
1738    }
1739
1740    /**
1741    Limit the number of file descriptors the library will open concurrently
1742    when flushing dirty pages from the cache.
1743    <p>
1744    @param maxOpenFiles
1745    The maximum number of file descriptors that may be concurrently opened
1746    by the library when flushing dirty pages from the cache.
1747    **/
1748    public void setMaxOpenFiles(final int maxOpenFiles) {
1749        this.maxOpenFiles = maxOpenFiles;
1750    }
1751
1752    /**
1753Return the maximum number of file descriptors that will be opened concurrently..
1754<p>
1755This method may be called at any time during the life of the application.
1756<p>
1757@return
1758The maximum number of file descriptors that will be opened concurrently..
1759    */
1760    public int getMaxOpenFiles() {
1761        return maxOpenFiles;
1762    }
1763
1764    /**
1765    Limit the number of sequential write operations scheduled by the
1766    library when flushing dirty pages from the cache.
1767    <p>
1768    @param maxWrite
1769    The maximum number of sequential write operations scheduled by the
1770    library when flushing dirty pages from the cache.
1771    @param maxWriteSleep
1772    The number of microseconds the thread of control should pause before
1773    scheduling further write operations.
1774    **/
1775    public void setMaxWrite(final int maxWrite, final long maxWriteSleep) {
1776        this.maxWrite = maxWrite;
1777        this.maxWriteSleep = maxWriteSleep;
1778    }
1779
1780    /**
1781Return the maximum number of sequential write operations.
1782<p>
1783This method may be called at any time during the life of the application.
1784<p>
1785@return
1786The maximum number of sequential write operations.
1787    */
1788    public int getMaxWrite() {
1789        return maxWrite;
1790    }
1791
1792    /**
1793Return the microseconds to pause before scheduling further write operations.
1794<p>
1795This method may be called at any time during the life of the application.
1796<p>
1797@return
1798The microseconds to pause before scheduling further write operations.
1799    */
1800    public long getMaxWriteSleep() {
1801        return maxWriteSleep;
1802    }
1803
1804    /**
1805    Set a function to be called with an informational message.
1806<p>
1807There are interfaces in the Berkeley DB library which either directly
1808output informational messages or statistical information, or configure
1809the library to output such messages when performing other operations,
1810{@link com.sleepycat.db.EnvironmentConfig#setVerboseDeadlock EnvironmentConfig.setVerboseDeadlock} for example.
1811<p>
1812The {@link com.sleepycat.db.EnvironmentConfig#setMessageHandler EnvironmentConfig.setMessageHandler} and
1813{@link com.sleepycat.db.DatabaseConfig#setMessageHandler DatabaseConfig.setMessageHandler} methods are used to display
1814these messages for the application.
1815<p>
1816Setting messageHandler to null unconfigures the interface.
1817<p>
1818Alternatively, you can use {@link com.sleepycat.db.EnvironmentConfig#setMessageStream EnvironmentConfig.setMessageStream}
1819and {@link com.sleepycat.db.DatabaseConfig#setMessageStream DatabaseConfig.setMessageStream} to send the additional
1820information directly to an output streams.  You should not mix these
1821approaches.
1822<p>
1823This method may be called at any time during the life of the application.
1824<p>
1825@param messageHandler
1826The application-specified function for informational messages.
1827    */
1828    public void setMessageHandler(final MessageHandler messageHandler) {
1829        this.messageHandler = messageHandler;
1830    }
1831
1832    /**
1833Return the function to be called with an informational message.
1834<p>
1835This method may be called at any time during the life of the application.
1836<p>
1837@return
1838The function to be called with an informational message.
1839    */
1840    public MessageHandler getMessageHandler() {
1841        return messageHandler;
1842    }
1843
1844    /**
1845    Set an OutputStream for displaying informational messages.
1846<p>
1847There are interfaces in the Berkeley DB library which either directly
1848output informational messages or statistical information, or configure
1849the library to output such messages when performing other operations,
1850{@link com.sleepycat.db.EnvironmentConfig#setVerboseDeadlock EnvironmentConfig.setVerboseDeadlock} for example.
1851<p>
1852The {@link com.sleepycat.db.EnvironmentConfig#setMessageStream EnvironmentConfig.setMessageStream} and
1853{@link com.sleepycat.db.DatabaseConfig#setMessageStream DatabaseConfig.setMessageStream} methods are used to display
1854these messages for the application.  In this case, the message will
1855include a trailing newline character.
1856<p>
1857Setting messageStream to null unconfigures the interface.
1858<p>
1859Alternatively, you can use {@link com.sleepycat.db.EnvironmentConfig#setMessageHandler EnvironmentConfig.setMessageHandler}
1860and {@link com.sleepycat.db.DatabaseConfig#setMessageHandler DatabaseConfig.setMessageHandler} to capture the additional
1861information in a way that does not use output streams.  You should not
1862mix these approaches.
1863<p>
1864This method may be called at any time during the life of the application.
1865<p>
1866@param messageStream
1867The application-specified OutputStream for informational messages.
1868    */
1869    public void setMessageStream(final java.io.OutputStream messageStream) {
1870        this.messageStream = messageStream;
1871    }
1872
1873    /**
1874Return the an OutputStream for displaying informational messages.
1875<p>
1876This method may be called at any time during the life of the application.
1877<p>
1878@return
1879The an OutputStream for displaying informational messages.
1880    */
1881    public java.io.OutputStream getMessageStream() {
1882        return messageStream;
1883    }
1884
1885    /**
1886    Set the maximum file size, in bytes, for a file to be mapped into
1887    the process address space.
1888    <p>
1889    If no value is specified, it defaults to 10MB.
1890    <p>
1891    Files that are opened read-only in the pool (and that satisfy a few
1892    other criteria) are, by default, mapped into the process address space
1893    instead of being copied into the local cache.  This can result in
1894    better-than-usual performance because available virtual memory is
1895    normally much larger than the local cache, and page faults are faster
1896    than page copying on many systems.  However, it can cause resource
1897    starvation in the presence of limited virtual memory, and it can result
1898    in immense process sizes in the presence of large databases.
1899    <p>
1900    @param mmapSize
1901    The maximum file size, in bytes, for a file to be mapped into the
1902    process address space.
1903    <p>
1904    This method configures only operations performed using a single a
1905{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
1906    <p>
1907    This method may be called at any time during the life of the application.
1908    */
1909    public void setMMapSize(final long mmapSize) {
1910        this.mmapSize = mmapSize;
1911    }
1912
1913    /**
1914    Return the maximum file size, in bytes, for a file to be mapped into
1915    the process address space.
1916    <p>
1917    @return
1918    The maximum file size, in bytes, for a file to be mapped into the
1919    process address space.
1920    */
1921    public long getMMapSize() {
1922        return mmapSize;
1923    }
1924
1925    /**
1926    Configure the database environment to use a specific mode when
1927    creating underlying files and shared memory segments.
1928    <p>
1929    On UNIX systems or in POSIX environments, files created in the
1930    database environment are created with the specified mode (as
1931    modified by the process' umask value at the time of creation).
1932    <p>
1933    On UNIX systems or in POSIX environments, system shared memory
1934    segments created by the library are created with the specified
1935    mode, unmodified by the process' umask value.
1936    <p>
1937    If is 0, the library will use a default mode of readable and
1938    writable by both owner and group.
1939    <p>
1940    Created files are owned by the process owner; the group ownership
1941    of created files is based on the system and directory defaults,
1942    and is not further specified by the library.
1943    <p>
1944    @param mode
1945    The mode to use when creating underlying files and shared memory
1946    segments.
1947    */
1948    public void setMode(final int mode) {
1949        this.mode = mode;
1950    }
1951
1952    /**
1953Return the mode to use when creating underlying files and shared
1954    memory segments.
1955<p>
1956This method may be called at any time during the life of the application.
1957<p>
1958@return
1959The mode to use when creating underlying files and shared
1960    memory segments.
1961    */
1962    public long getMode() {
1963        return mode;
1964    }
1965
1966    /**
1967    Configure the database environment to open all databases that are not
1968    using the queue access method for multiversion concurrency control.
1969    See {@link DatabaseConfig#setMultiversion} for more information.
1970    <p>
1971    This method may be called at any time during the life of the application.
1972    <p>
1973    @param multiversion
1974    If true, all databases that are not using the queue access method will be
1975    opened for multiversion concurrency control.
1976    */
1977    public void setMultiversion(final boolean multiversion) {
1978        this.multiversion = multiversion;
1979    }
1980
1981    /**
1982Return true if the handle is configured to open all databases for multiversion
1983    concurrency control.
1984<p>
1985This method may be called at any time during the life of the application.
1986<p>
1987@return
1988True if the handle is configured to open all databases for multiversion
1989    concurrency control.
1990    */
1991    public boolean getMultiversion() {
1992        return multiversion;
1993    }
1994
1995    /**
1996    Configure the system to grant all requested mutual exclusion mutexes
1997    and database locks without regard for their actual availability.
1998    <p>
1999    This functionality should never be used for purposes other than
2000    debugging.
2001    <p>
2002    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
2003any other library handles opened within the scope of that handle).
2004    <p>
2005    This method may be called at any time during the life of the application.
2006    <p>
2007    @param noLocking
2008    If true, configure the system to grant all requested mutual exclusion
2009    mutexes and database locks without regard for their actual availability.
2010    */
2011    public void setNoLocking(final boolean noLocking) {
2012        this.noLocking = noLocking;
2013    }
2014
2015    /**
2016Return true if the system has been configured to grant all requested mutual
2017    exclusion mutexes and database locks without regard for their actual
2018    availability.
2019<p>
2020This method may be called at any time during the life of the application.
2021<p>
2022@return
2023True if the system has been configured to grant all requested mutual
2024    exclusion mutexes and database locks without regard for their actual
2025    availability.
2026    */
2027    public boolean getNoLocking() {
2028        return noLocking;
2029    }
2030
2031    /**
2032    Configure the system to copy read-only database files into the local
2033    cache instead of potentially mapping them into process memory.
2034    <p>
2035    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
2036any other library handles opened within the scope of that handle).
2037For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
2038handles opened in the database environment must either call this method
2039or the configuration should be specified in the database environment's
2040DB_CONFIG configuration file.
2041    <p>
2042    This method may be called at any time during the life of the application.
2043    <p>
2044    @param noMMap
2045    If true, configure the system to copy read-only database files into
2046    the local cache instead of potentially mapping them into process memory.
2047    */
2048    public void setNoMMap(final boolean noMMap) {
2049        this.noMMap = noMMap;
2050    }
2051
2052    /**
2053Return true if the system has been configured to copy read-only database files
2054    into the local cache instead of potentially mapping them into process
2055    memory.
2056<p>
2057This method may be called at any time during the life of the application.
2058<p>
2059@return
2060True if the system has been configured to copy read-only database files
2061    into the local cache instead of potentially mapping them into process
2062    memory.
2063    */
2064    public boolean getNoMMap() {
2065        return noMMap;
2066    }
2067
2068    /**
2069    Configure the system to ignore any panic state in the database
2070    environment.
2071    <p>
2072    Database environments in a panic state normally refuse all attempts to
2073    call Berkeley DB functions, throwing {@link com.sleepycat.db.RunRecoveryException RunRecoveryException}.
2074    This functionality should never be used for purposes other than
2075    debugging.
2076    <p>
2077    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
2078any other library handles opened within the scope of that handle).
2079    <p>
2080    This method may be called at any time during the life of the application.
2081    <p>
2082    @param noPanic
2083    If true, configure the system to ignore any panic state in the
2084    database environment.
2085    */
2086    public void setNoPanic(final boolean noPanic) {
2087        this.noPanic = noPanic;
2088    }
2089
2090    /**
2091Return true if the system has been configured to ignore any panic state in
2092    the database environment.
2093<p>
2094This method may be called at any time during the life of the application.
2095<p>
2096@return
2097True if the system has been configured to ignore any panic state in
2098    the database environment.
2099    */
2100    public boolean getNoPanic() {
2101        return noPanic;
2102    }
2103
2104    /**
2105    Configure the system to overwrite files stored in encrypted formats
2106    before deleting them.
2107    <p>
2108    Berkeley DB overwrites files using alternating 0xff, 0x00 and 0xff
2109    byte patterns.  For file overwriting to be effective, the underlying
2110    file must be stored on a fixed-block filesystem.  Systems with
2111    journaling or logging filesystems will require operating system
2112    support and probably modification of the Berkeley DB sources.
2113    <p>
2114    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
2115any other library handles opened within the scope of that handle).
2116    <p>
2117    This method may be called at any time during the life of the application.
2118    <p>
2119    @param overwrite
2120    If true, configure the system to overwrite files stored in encrypted
2121    formats before deleting them.
2122    */
2123    public void setOverwrite(final boolean overwrite) {
2124        this.overwrite = overwrite;
2125    }
2126
2127    /**
2128Return true if the system has been configured to overwrite files stored in
2129    encrypted formats before deleting them.
2130<p>
2131This method may be called at any time during the life of the application.
2132<p>
2133@return
2134True if the system has been configured to overwrite files stored in
2135    encrypted formats before deleting them.
2136    */
2137    public boolean getOverwrite() {
2138        return overwrite;
2139    }
2140
2141    /**
2142    Set the function to be called if the database environment panics.
2143<p>
2144Errors can occur in the Berkeley DB library where the only solution is
2145to shut down the application and run recovery (for example, if Berkeley
2146DB is unable to allocate heap memory).  In such cases, the Berkeley DB
2147methods will throw a {@link com.sleepycat.db.RunRecoveryException RunRecoveryException}.  It is often easier
2148to simply exit the application when such errors occur rather than
2149gracefully return up the stack.  This method specifies a function to be
2150called when {@link com.sleepycat.db.RunRecoveryException RunRecoveryException} is about to be thrown from a
2151Berkeley DB method.
2152<p>
2153This method may be called at any time during the life of the application.
2154<p>
2155@param panicHandler
2156The function to be called if the database environment panics.
2157    */
2158    public void setPanicHandler(final PanicHandler panicHandler) {
2159        this.panicHandler = panicHandler;
2160    }
2161
2162    /**
2163Return the function to be called if the database environment panics.
2164<p>
2165This method may be called at any time during the life of the application.
2166<p>
2167@return
2168The function to be called if the database environment panics.
2169    */
2170    public PanicHandler getPanicHandler() {
2171        return panicHandler;
2172    }
2173
2174    /**
2175    Configure the database environment to only be accessed by a single
2176    process (although that process may be multithreaded).
2177    <p>
2178    This has two effects on the database environment.  First, all
2179    underlying data structures are allocated from per-process memory
2180    instead of from shared memory that is potentially accessible to more
2181    than a single process.  Second, mutexes are only configured to work
2182    between threads.
2183    <p>
2184    This flag should not be specified if more than a single process is
2185    accessing the environment because it is likely to cause database
2186    corruption and unpredictable behavior.  For example, if both a
2187    server application and the a Berkeley DB utility are expected to
2188    access the environment, the database environment should not be
2189    configured as private.
2190    <p>
2191    @param isPrivate
2192    If true, configure the database environment to only be accessed by
2193    a single process.
2194    */
2195    public void setPrivate(final boolean isPrivate) {
2196        this.isPrivate = isPrivate;
2197    }
2198
2199    /**
2200Return true if the database environment is configured to only be accessed
2201    by a single process.
2202<p>
2203This method may be called at any time during the life of the application.
2204<p>
2205@return
2206True if the database environment is configured to only be accessed
2207    by a single process.
2208    */
2209    public boolean getPrivate() {
2210        return isPrivate;
2211    }
2212
2213    /**
2214    Sets the clock skew ratio among replication group members based on the
2215    fastest and slowest measurements among the group for use with master leases.
2216    Calling this method is optional, the default values for clock skew assume no
2217    skew.  The user must also configure leases via the
2218    {@link Environment#setReplicationConfig} method.  Additionally, the user must
2219    also set the master lease timeout via the
2220    {@link Environment#setReplicationTimeout} method and the number of sites in
2221    the replication group via the (@link #setReplicationNumSites} method.  These
2222    methods may be called in any order.  For a description of the clock skew
2223    values, see <a href="{@docRoot}/../ref/rep/clock_skew.html">Clock skew</a>.
2224    For a description of master leases, see
2225    <a href="{@docRoot}/../ref/rep/lease.html">Master leases</a>.
2226    <p>
2227    These arguments can be used to express either raw measurements of a clock
2228    timing experiment or a percentage across machines.  For instance a group of
2229    sites have a 2% variance, then <code>replicationClockskewFast</code> should be given as
2230    102, and <code>replicationClockskewSlow</code> should be set at 100.  Or, for a 0.03%
2231    difference, you can use 10003 and 10000 respectively.
2232    <p>
2233    The database environment's replication subsystem may also be configured using
2234    the environment's
2235    <a href="{@docRoot}/../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file.
2236    The syntax of the entry in that file is a single line with the string
2237    "rep_set_clockskew", one or more whitespace characters, and the clockskew
2238    specified in two parts: the replicationClockskewFast and the replicationClockskewSlow.  For example,
2239    "rep_set_clockskew 102 100".  Because the
2240    <a href="{@docRoot}/../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file is
2241    read when the database environment is opened, it will silently overrule
2242    configuration done before that time.
2243    <p>
2244    This method configures a database environment, not only operations performed
2245    using the specified {@link Environment} handle.
2246    <p>
2247    This method may not be called after the {@link Environment#replicationManagerStart} or {@link Environment#startReplication} methods are called.
2248    <p>
2249    @param replicationClockskewFast
2250    The value, relative to the <code>replicationClockskewSlow</code>, of the fastest clock in the group of sites.
2251    @param replicationClockskewSlow
2252    The value of the slowest clock in the group of sites.
2253
2254    */
2255    public void setReplicationClockskew(final int replicationClockskewFast,
2256        final int replicationClockskewSlow) {
2257
2258        this.replicationClockskewFast = replicationClockskewFast;
2259        this.replicationClockskewSlow = replicationClockskewSlow;
2260    }
2261
2262    /**
2263    Return the current clock skew value for the fastest clock in the group of sites.
2264    <p>
2265    This method may be called at any time during the life of the application.
2266    @return
2267    The current clock skew value for the fastest clock in the group of sites.
2268    */
2269    public int getReplicationClockskewFast() {
2270        return replicationClockskewFast;
2271    }
2272
2273    /**
2274    Return the current clock skew value for the slowest clock in the group of sites.
2275    <p>
2276    This method may be called at any time during the life of the application.
2277    @return
2278    The current clock skew value for the slowest clock in the group of sites.
2279    */
2280    public int getReplicationClockskewSlow() {
2281        return replicationClockskewSlow;
2282    }
2283
2284    /**
2285    Impose a byte-count limit on the amount of data that will be
2286    transmitted from a site in a single call to {@link com.sleepycat.db.Environment#processReplicationMessage Environment.processReplicationMessage}.
2287    <p>
2288    This method configures a database environment, including all threads
2289of control accessing the database environment, not only the operations
2290performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
2291    <p>
2292    This method may not be called before the database environment is opened.
2293    <p>
2294    @param replicationLimit
2295    The maximum number of bytes that will be sent in a single call to
2296    {@link com.sleepycat.db.Environment#processReplicationMessage Environment.processReplicationMessage}.
2297    */
2298    public void setReplicationLimit(final long replicationLimit) {
2299        this.replicationLimit = replicationLimit;
2300    }
2301
2302    /**
2303    Return the transmit limit in bytes for a single call to
2304    {@link com.sleepycat.db.Environment#processReplicationMessage Environment.processReplicationMessage}.
2305    <p>
2306    This method may be called at any time during the life of the application.
2307    <p>
2308    @return
2309    The transmit limit in bytes for a single call to {@link com.sleepycat.db.Environment#processReplicationMessage Environment.processReplicationMessage}.
2310    */
2311    public long getReplicationLimit() {
2312        return replicationLimit;
2313    }
2314
2315    /**
2316    Set a threshold for the minimum time that a client waits before requesting
2317    retransmission of a missing message.  Specifically, if the client detects a
2318    gap in the sequence of incoming log records or database pages, Berkeley DB
2319    will wait for at least <code>replicationRequestMin</code> microseconds before requesting
2320    retransmission of the missing record.  Berkeley DB will double that amount
2321    before requesting the same missing record again, and so on, up to a maximum
2322    threshold, set by {@link #setReplicationRequestMax}.
2323    <p>
2324    These values are thresholds only.  Since Berkeley DB has no thread available
2325    in the library as a timer, the threshold is only checked when a thread enters
2326    the Berkeley DB library to process an incoming replication message.  Any
2327    amount of time may have passed since the last message arrived and Berkeley DB
2328    only checks whether the amount of time since a request was made is beyond the
2329    threshold value or not.
2330    <p>
2331    By default the minimum is 40000 and the maximum is 1280000 (1.28 seconds).
2332    These defaults are fairly arbitrary and the application likely needs to
2333    adjust these.  The values should be based on expected load and performance
2334    characteristics of the master and client host platforms and transport
2335    infrastructure as well as round-trip message time.
2336    <p>
2337    @param replicationRequestMin
2338    The minimum amount of time the client waits before requesting retransmission
2339    of a missing message.
2340    */
2341    public void setReplicationRequestMin(final int replicationRequestMin) {
2342        this.replicationRequestMin = replicationRequestMin;
2343    }
2344
2345    /**
2346    Get the threshold for the minimum amount of time that a client waits before
2347    requesting retransmission of a missed message.
2348    <p>
2349    @return
2350    The threshold for the minimum amount of time that a client waits before
2351    requesting retransmission of a missed message.
2352    */
2353    public int getReplicationRequestMin() {
2354        return replicationRequestMin;
2355    }
2356
2357    /**
2358    Set a threshold for the maximum time that a client waits before requesting
2359    retransmission of a missing message.  Specifically, if the client detects a
2360    gap in the sequence of incoming log records or database pages, Berkeley DB
2361    will wait for at least the minimum threshold, set by
2362    {@link #setReplicationRequestMin}, before requesting retransmission of the
2363    missing record.  Berkeley DB will double that amount before requesting the
2364    same missing record again, and so on, up to <code>replicationRequestMax</code>.
2365    <p>
2366    These values are thresholds only.  Since Berkeley DB has no thread available
2367    in the library as a timer, the threshold is only checked when a thread enters
2368    the Berkeley DB library to process an incoming replication message.  Any
2369    amount of time may have passed since the last message arrived and Berkeley DB
2370    only checks whether the amount of time since a request was made is beyond the
2371    threshold value or not.
2372    <p>
2373    By default the minimum is 40000 and the maximum is 1280000 (1.28 seconds).
2374    These defaults are fairly arbitrary and the application likely needs to
2375    adjust these.  The values should be based on expected load and performance
2376    characteristics of the master and client host platforms and transport
2377    infrastructure as well as round-trip message time.
2378    <p>
2379    @param replicationRequestMax
2380    The maximum amount of time the client waits before requesting retransmission
2381    of a missing message.
2382    */
2383    public void setReplicationRequestMax(final int replicationRequestMax) {
2384        this.replicationRequestMax = replicationRequestMax;
2385    }
2386
2387    /**
2388    Get the threshold for the maximum amount of time that a client waits before
2389    requesting retransmission of a missed message.
2390    <p>
2391    @return
2392    The threshold for the maximum amount of time that a client waits before
2393    requesting retransmission of a missed message.
2394    */
2395    public int getReplicationRequestMax() {
2396        return replicationRequestMax;
2397    }
2398
2399    /**
2400    Initialize the communication infrastructure for a database environment
2401    participating in a replicated application.
2402    <p>
2403    This method configures only operations performed using a single a
2404{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
2405    <p>
2406    This method may be called at any time during the life of the application.
2407    <p>
2408    @param envid
2409    The local environment's ID.  It must be a positive integer and
2410    uniquely identify this Berkeley DB database environment.
2411    <p>
2412    @param replicationTransport
2413    The callback function is used to transmit data using the replication
2414    application's communication infrastructure.
2415    */
2416    public void setReplicationTransport(final int envid,
2417        final ReplicationTransport replicationTransport) {
2418
2419        this.envid = envid;
2420        this.replicationTransport = replicationTransport;
2421    }
2422
2423    /**
2424    Return the replication callback function used to transmit data using
2425    the replication application's communication infrastructure.
2426    <p>
2427    @return
2428    The replication callback function used to transmit data using the
2429    replication application's communication infrastructure.
2430    */
2431    public ReplicationTransport getReplicationTransport() {
2432        return replicationTransport;
2433    }
2434
2435    /**
2436    Check if a process has failed while using the database environment, that
2437    is, if a process has exited with an open {@link Environment} handle.  (For
2438    this check to be accurate, all processes using the environment must
2439    specify this flag when opening the environment.)  If recovery
2440    needs to be run for any reason and either {@link #setRunRecovery} or
2441    {@link #setRunFatalRecovery} are also specified, recovery will be performed
2442    and the open will proceed normally.  If recovery needs to be run and no
2443    recovery flag is specified, a {@link RunRecoveryException} will be thrown.
2444    If recovery does not need to be run, the recovery flags will be ignored.
2445    See
2446    <a href="{@docRoot}/../ref/transapp/app.html" target="_top">Architecting
2447    Transactional Data Store applications</a>) for more information.
2448    <p>
2449    @param register
2450    If true, check for process failure when the environment is opened.
2451    **/
2452    public void setRegister(final boolean register) {
2453        this.register = register;
2454    }
2455
2456    /**
2457Return true if the check for process failure when the environment is opened.
2458<p>
2459This method may be called at any time during the life of the application.
2460<p>
2461@return
2462True if the check for process failure when the environment is opened.
2463    */
2464    public boolean getRegister() {
2465        return register;
2466    }
2467
2468    /**
2469    Configure to run catastrophic recovery on this environment before opening it for
2470normal use.
2471<p>
2472A standard part of the recovery process is to remove the existing
2473database environment and create a new one.  Applications running
2474recovery must be prepared to re-create the environment because
2475underlying shared regions will be removed and re-created.
2476<p>
2477If the thread of control performing recovery does not specify the
2478correct database environment initialization information (for example,
2479the correct memory pool cache size), the result can be an application
2480running in an environment with incorrect cache and other subsystem
2481sizes.  For this reason, the thread of control performing recovery
2482should specify correct configuration information before recovering the
2483environment; or it should remove the environment after recovery is
2484completed, leaving creation of a correctly sized environment to a
2485subsequent call.
2486<p>
2487All recovery processing must be single-threaded; that is, only a single
2488thread of control may perform recovery or access a database environment
2489while recovery is being performed.  Because it is not an error to run
2490recovery for an environment for which no recovery is required, it is
2491reasonable programming practice for the thread of control responsible
2492for performing recovery and creating the environment to always specify
2493recovery during startup.
2494<p>
2495This method returns successfully if recovery is run no log files exist,
2496so it is necessary to ensure that all necessary log files are present
2497before running recovery.
2498<p>
2499@param runFatalRecovery
2500If true, configure to run catastrophic recovery on this environment
2501before opening it for normal use.
2502    */
2503    public void setRunFatalRecovery(final boolean runFatalRecovery) {
2504        this.runFatalRecovery = runFatalRecovery;
2505    }
2506
2507    /**
2508Return the handle is configured to run catastrophic recovery on
2509    the database environment before opening it for use.
2510<p>
2511This method may be called at any time during the life of the application.
2512<p>
2513@return
2514The handle is configured to run catastrophic recovery on
2515    the database environment before opening it for use.
2516    */
2517    public boolean getRunFatalRecovery() {
2518        return runFatalRecovery;
2519    }
2520
2521    /**
2522    Configure to run normal recovery on this environment before opening it for
2523normal use.
2524<p>
2525A standard part of the recovery process is to remove the existing
2526database environment and create a new one.  Applications running
2527recovery must be prepared to re-create the environment because
2528underlying shared regions will be removed and re-created.
2529<p>
2530If the thread of control performing recovery does not specify the
2531correct database environment initialization information (for example,
2532the correct memory pool cache size), the result can be an application
2533running in an environment with incorrect cache and other subsystem
2534sizes.  For this reason, the thread of control performing recovery
2535should specify correct configuration information before recovering the
2536environment; or it should remove the environment after recovery is
2537completed, leaving creation of a correctly sized environment to a
2538subsequent call.
2539<p>
2540All recovery processing must be single-threaded; that is, only a single
2541thread of control may perform recovery or access a database environment
2542while recovery is being performed.  Because it is not an error to run
2543recovery for an environment for which no recovery is required, it is
2544reasonable programming practice for the thread of control responsible
2545for performing recovery and creating the environment to always specify
2546recovery during startup.
2547<p>
2548This method returns successfully if recovery is run no log files exist,
2549so it is necessary to ensure that all necessary log files are present
2550before running recovery.
2551<p>
2552@param runRecovery
2553If true, configure to run normal recovery on this environment
2554before opening it for normal use.
2555    */
2556    public void setRunRecovery(final boolean runRecovery) {
2557        this.runRecovery = runRecovery;
2558    }
2559
2560    /**
2561Return the handle is configured to run normal recovery on the
2562    database environment before opening it for use.
2563<p>
2564This method may be called at any time during the life of the application.
2565<p>
2566@return
2567The handle is configured to run normal recovery on the
2568    database environment before opening it for use.
2569    */
2570    public boolean getRunRecovery() {
2571        return runRecovery;
2572    }
2573
2574    /**
2575    Configure the database environment to allocate memory from system
2576    shared memory instead of from memory backed by the filesystem.
2577    <p>
2578    @param systemMemory
2579    If true, configure the database environment to allocate memory from
2580    system shared memory instead of from memory backed by the filesystem.
2581    */
2582    public void setSystemMemory(final boolean systemMemory) {
2583        this.systemMemory = systemMemory;
2584    }
2585
2586    /**
2587Return true if the database environment is configured to allocate memory
2588    from system shared memory instead of from memory backed by the
2589    filesystem.
2590<p>
2591This method may be called at any time during the life of the application.
2592<p>
2593@return
2594True if the database environment is configured to allocate memory
2595    from system shared memory instead of from memory backed by the
2596    filesystem.
2597    */
2598    public boolean getSystemMemory() {
2599        return systemMemory;
2600    }
2601
2602    /**
2603    Establish a connection to a RPC server for this database environment.
2604    <p>
2605    After this method is called, subsequent calls to Berkeley DB library
2606    interfaces may throw exceptions encapsulating DB_NOSERVER,
2607    DB_NOSERVER_ID or DB_NOSERVER_HOME.
2608    <p>
2609    This method configures only operations performed using a single a
2610{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
2611    <p>
2612    This method may not be called after the
2613environment has been opened.
2614    <p>
2615    @param rpcServer
2616    The host to which the client will connect and create a channel for
2617    communication.
2618    <p>
2619    @param rpcClientTimeout
2620    The number of seconds the client should wait for results to come
2621    back from the server.  Once the timeout has expired on any
2622    communication with the server, {@link com.sleepycat.db.DatabaseException DatabaseException}
2623    encapsulating DB_NOSERVER will be thrown.  If this value is zero, a
2624    default timeout is used.
2625    <p>
2626    @param rpcServerTimeout
2627    The number of seconds the server should allow a client connection
2628    to remain idle before assuming that the client is gone.  Once that
2629    timeout has been reached, the server releases all resources
2630    associated with that client connection.  Subsequent attempts by that
2631    client to communicate with the server result in an error return,
2632    indicating that an invalid identifier has been given to the server.
2633    This value can be considered a hint to the server.  The server may
2634    alter this value based on its own policies or allowed values.  If
2635    this value is zero, a default timeout is used.
2636    */
2637    public void setRPCServer(final String rpcServer,
2638                             final long rpcClientTimeout,
2639                             final long rpcServerTimeout) {
2640        this.rpcServer = rpcServer;
2641        this.rpcClientTimeout = rpcClientTimeout;
2642        this.rpcServerTimeout = rpcServerTimeout;
2643
2644        // Turn off threading for RPC client handles.
2645        this.threaded = false;
2646    }
2647
2648    /**
2649    Specify a base segment ID for database environment shared memory
2650    regions created in system memory on VxWorks or systems supporting
2651    X/Open-style shared memory interfaces; for example, UNIX systems
2652    supporting <code>shmget</code> and related System V IPC interfaces.
2653    <p>
2654    This base segment ID will be used when database environment shared
2655    memory regions are first created.  It will be incremented a small
2656    integer value each time a new shared memory region is created; that
2657    is, if the base ID is 35, the first shared memory region created
2658    will have a segment ID of 35, and the next one will have a segment
2659    ID between 36 and 40 or so.  A database environment always creates
2660    a master shared memory region; an additional shared memory region
2661    for each of the subsystems supported by the environment (Locking,
2662    Logging, Memory Pool and Transaction); plus an additional shared
2663    memory region for each additional memory pool cache that is
2664    supported.  Already existing regions with the same segment IDs will
2665    be removed.
2666    <p>
2667    The intent behind this method is two-fold: without it, applications
2668    have no way to ensure that two Berkeley DB applications don't
2669    attempt to use the same segment IDs when creating different database
2670    environments.  In addition, by using the same segment IDs each time
2671    the environment is created, previously created segments will be
2672    removed, and the set of segments on the system will not grow without
2673    bound.
2674    The database environment's base segment ID may also be set using the environment's
2675DB_CONFIG file.  The syntax of the entry in that file is a single line
2676with the string "set_shm_key", one or more whitespace characters, and the ID.
2677Because the DB_CONFIG file is read when the database environment is
2678opened, it will silently overrule configuration done before that time.
2679    <p>
2680    This method configures only operations performed using a single a
2681{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
2682    <p>
2683    This method may not be called after the
2684environment has been opened.
2685If joining an existing database environment, the
2686information specified to this method must be consistent with the
2687existing environment or corruption can occur.
2688    <p>
2689    @param segmentId
2690    The base segment ID for the database environment.
2691    */
2692    public void setSegmentId(final long segmentId) {
2693        this.segmentId = segmentId;
2694    }
2695
2696    /**
2697Return the base segment ID.
2698<p>
2699This method may be called at any time during the life of the application.
2700<p>
2701@return
2702The base segment ID.
2703    */
2704    public long getSegmentId() {
2705        return segmentId;
2706    }
2707
2708    /**
2709    Set the path of a directory to be used as the location of temporary
2710    files.
2711    <p>
2712    The files created to back in-memory access method databases will be
2713    created relative to this path.  These temporary files can be quite
2714    large, depending on the size of the database.
2715    <p>
2716    If no directory is specified, the following alternatives are checked
2717    in the specified order.  The first existing directory path is used
2718    for all temporary files.
2719    <blockquote><ol>
2720    <li>The value of the environment variable TMPDIR.
2721    <li>The value of the environment variable TEMP.
2722    <li>The value of the environment variable TMP.
2723    <li>The value of the environment variable TempFolder.
2724    <li>The value returned by the GetTempPath interface.
2725    <li>The directory /var/tmp.
2726    <li>The directory /usr/tmp.
2727    <li>The directory /temp.
2728    <li>The directory /tmp.
2729    <li>The directory C:/temp.
2730    <li>The directory C:/tmp.
2731    </ol</blockquote>
2732    <p>
2733    Note: the environment variables are only checked if the database
2734    environment has been configured with one of
2735    {@link com.sleepycat.db.EnvironmentConfig#setUseEnvironment EnvironmentConfig.setUseEnvironment} or
2736    {@link com.sleepycat.db.EnvironmentConfig#setUseEnvironmentRoot EnvironmentConfig.setUseEnvironmentRoot}.
2737    <p>
2738    Note: the GetTempPath interface is only checked on Win/32 platforms.
2739    <p>
2740    The database environment's temporary file directory may also be set using the environment's
2741DB_CONFIG file.  The syntax of the entry in that file is a single line
2742with the string "set_tmp_dir", one or more whitespace characters, and the directory name.
2743Because the DB_CONFIG file is read when the database environment is
2744opened, it will silently overrule configuration done before that time.
2745    <p>
2746    This method configures only operations performed using a single a
2747{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
2748    <p>
2749    This method may not be called after the
2750environment has been opened.
2751If joining an existing database environment, the
2752information specified to this method must be consistent with the
2753existing environment or corruption can occur.
2754    <p>
2755    @param temporaryDirectory
2756    The directory to be used to store temporary files.
2757    On Windows platforms, this argument will be interpreted as a UTF-8
2758string, which is equivalent to ASCII for Latin characters.
2759    */
2760    public void setTemporaryDirectory(final java.io.File temporaryDirectory) {
2761        this.temporaryDirectory = temporaryDirectory;
2762    }
2763
2764    /** @deprecated replaced by {@link #setTemporaryDirectory(java.io.File)} */
2765    public void setTemporaryDirectory(final String temporaryDirectory) {
2766        this.setTemporaryDirectory(new java.io.File(temporaryDirectory));
2767    }
2768
2769    /**
2770Return the path of a directory to be used as the location of
2771    temporary files.
2772<p>
2773This method may be called at any time during the life of the application.
2774<p>
2775@return
2776The path of a directory to be used as the location of
2777    temporary files.
2778    */
2779    public java.io.File getTemporaryDirectory() {
2780        return temporaryDirectory;
2781    }
2782
2783    /**
2784    Set the mutex alignment, in bytes.
2785    <p>
2786    It is sometimes advantageous to align mutexes on specific byte
2787    boundaries in order to minimize cache line collisions.   This method
2788    specifies an alignment for mutexes allocated by Berkeley DB.
2789    <p>
2790    The database environment's mutex alignment may also be set using the environment's
2791DB_CONFIG file.  The syntax of the entry in that file is a single line
2792with the string "mutex_set_align", one or more whitespace characters, and the mutex alignment in bytes.
2793Because the DB_CONFIG file is read when the database environment is
2794opened, it will silently overrule configuration done before that time.
2795    <p>
2796    This method configures a database environment, including all threads
2797of control accessing the database environment, not only the operations
2798performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
2799    <p>
2800    This method may not be called after the
2801environment has been opened.
2802If joining an existing database environment, any
2803information specified to this method will be ignored.
2804    @param mutexAlignment
2805    mutex alignment, in bytes.  The mutex alignment must be a power-of-two.
2806    **/
2807    public void setMutexAlignment(final int mutexAlignment) {
2808        this.mutexAlignment = mutexAlignment;
2809    }
2810
2811    /**
2812Return the mutex alignment, in bytes.
2813<p>
2814This method may be called at any time during the life of the application.
2815<p>
2816@return
2817The mutex alignment, in bytes.
2818    **/
2819    public int getMutexAlignment() {
2820        return mutexAlignment;
2821    }
2822
2823    /**
2824    Increase the number of mutexes to allocate.
2825    <p>
2826    Berkeley DB allocates a default number of mutexes based on the initial
2827    configuration of the database environment.  That default calculation may
2828    be too small if the application has an unusual need for mutexes (for
2829    example, if the application opens an unexpectedly large number of
2830    databases) or too large (if the application is trying to minimize its
2831    memory footprint).  This method configure the number of additional
2832    mutexes to allocate.
2833    <p>
2834    Calling this method discards any value previously
2835    set using the {@link #setMaxMutexes} method.
2836    <p>
2837    This method configures a database environment, including all threads
2838of control accessing the database environment, not only the operations
2839performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
2840    <p>
2841    This method may not be called after the
2842environment has been opened.
2843If joining an existing database environment, any
2844information specified to this method will be ignored.
2845    <p>
2846    @param mutexIncrement
2847    The number of additional mutexes to allocate.
2848    **/
2849    public void setMutexIncrement(final int mutexIncrement) {
2850        this.mutexIncrement = mutexIncrement;
2851    }
2852
2853    /**
2854Return the number of additional mutexes to allocate.
2855<p>
2856This method may be called at any time during the life of the application.
2857<p>
2858@return
2859The number of additional mutexes to allocate.
2860    **/
2861    public int getMutexIncrement() {
2862        return mutexIncrement;
2863    }
2864
2865    /**
2866    Set the total number of mutexes to allocate.
2867    <p>
2868    Berkeley DB allocates a default number of mutexes based on the initial
2869    configuration of the database environment.  That default calculation may
2870    be too small if the application has an unusual need for mutexes (for
2871    example, if the application opens an unexpectedly large number of
2872    databases) or too large (if the application is trying to minimize its
2873    memory footprint).  This method is used to specify an
2874    absolute number of mutexes to allocate.
2875    <p>
2876    Calling this method discards any value previously
2877    set using the {@link #setMutexIncrement} method.
2878    <p>
2879    The database environment's total number of mutexes may also be set using
2880    the environment's <b>DB_CONFIG</b> file.  The syntax of the entry in that
2881    file is a single line with the string "mutex_set_max", one or more
2882    whitespace characters, and the total number of mutexes. Because the
2883    <b>DB_CONFIG</b> file is read when the database environment is opened, it
2884    will silently overrule configuration done before that time.
2885    <p>
2886    This method configures a database environment, including all threads
2887of control accessing the database environment, not only the operations
2888performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
2889    <p>
2890    This method may not be called after the
2891environment has been opened.
2892If joining an existing database environment, any
2893information specified to this method will be ignored.
2894    <p>
2895    @param maxMutexes
2896    The absolute number of mutexes to allocate.
2897    **/
2898    public void setMaxMutexes(final int maxMutexes) {
2899        this.maxMutexes = maxMutexes;
2900    }
2901
2902    /**
2903Return the total number of mutexes allocated.
2904<p>
2905This method may be called at any time during the life of the application.
2906<p>
2907@return
2908The total number of mutexes allocated.
2909    **/
2910    public int getMaxMutexes() {
2911        return maxMutexes;
2912    }
2913
2914    /**
2915    Specify the number of times that test-and-set mutexes should spin
2916    without blocking.  The value defaults to 1 on uniprocessor systems and
2917    to 50 times the number of processors on multiprocessor systems.
2918    <p>
2919    The database environment's test-and-set spin count may also be set using the environment's
2920DB_CONFIG file.  The syntax of the entry in that file is a single line
2921with the string "set_tas_spins", one or more whitespace characters, and the number of spins.
2922Because the DB_CONFIG file is read when the database environment is
2923opened, it will silently overrule configuration done before that time.
2924    <p>
2925    This method configures only operations performed using a single a
2926{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
2927    <p>
2928    This method may be called at any time during the life of the application.
2929    <p>
2930    @param mutexTestAndSetSpins
2931    The number of spins test-and-set mutexes should execute before blocking.
2932     **/
2933    public void setMutexTestAndSetSpins(final int mutexTestAndSetSpins) {
2934        this.mutexTestAndSetSpins = mutexTestAndSetSpins;
2935    }
2936
2937    /**
2938Return the test-and-set spin count.
2939<p>
2940This method may be called at any time during the life of the application.
2941<p>
2942@return
2943The test-and-set spin count.
2944    **/
2945    public int getMutexTestAndSetSpins() {
2946        return mutexTestAndSetSpins;
2947    }
2948
2949    /**
2950    Set the total number of sites in the replication group.
2951    <p>
2952    @param replicationNumSites
2953    The total number of sites in the replication group.
2954    */
2955    public void setReplicationNumSites(final int replicationNumSites) {
2956        this.replicationNumSites = replicationNumSites;
2957    }
2958
2959    /**
2960    Get the total number of sites in the replication group.
2961    <p>
2962    @return
2963    The total number of sites in the replication group.
2964    */
2965    public int getReplicationNumSites() {
2966        return replicationNumSites;
2967    }
2968
2969    /**
2970    Set the current environment's priority. Priority is used to determine
2971    which replicated site will be selected as master when an election occurs.
2972    <p>
2973    @param replicationPriority
2974    The database environment priority.
2975    */
2976    public void setReplicationPriority(final int replicationPriority) {
2977        this.replicationPriority = replicationPriority;
2978    }
2979
2980    /**
2981    Get the current environment's priority. Priority is used to determine
2982    which replicated site will be selected as master when an election occurs.
2983    <p>
2984    @return
2985    The database environment priority.
2986    */
2987    public int getReplicationPriority() {
2988        return replicationPriority;
2989    }
2990
2991    /**
2992    Set the number of times test-and-set mutexes should spin before
2993    blocking.
2994    <p>
2995    The value defaults to 1 on uniprocessor systems and to 50 times the
2996    number of processors on multiprocessor systems.
2997    <p>
2998    This method configures only operations performed using a single a
2999{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
3000    <p>
3001    This method may be called at any time during the life of the application.
3002    <p>
3003    @param mutexTestAndSetSpins
3004    The number of times test-and-set mutexes should spin before blocking.
3005    <p>
3006    @deprecated replaced by {@link #setMutexTestAndSetSpins}
3007    */
3008    public void setTestAndSetSpins(final int mutexTestAndSetSpins) {
3009        setMutexTestAndSetSpins(mutexTestAndSetSpins);
3010    }
3011
3012    /**
3013Return the number of times test-and-set mutexes should spin before
3014    blocking.
3015<p>
3016This method may be called at any time during the life of the application.
3017<p>
3018@return
3019The number of times test-and-set mutexes should spin before
3020    blocking.
3021    <p>
3022    @deprecated replaced by {@link #getMutexTestAndSetSpins}
3023    */
3024    public int getTestAndSetSpins() {
3025        return getMutexTestAndSetSpins();
3026    }
3027
3028    /**
3029    Configure the handle to be <em>free-threaded</em>; that is, usable
3030    by multiple threads within a single address space.
3031    <p>
3032    This is the default; threading is always assumed in Java, so no special
3033    configuration is required.
3034    <p>
3035    @param threaded
3036    If true, configure the handle to be <em>free-threaded</em>.
3037    */
3038    public void setThreaded(final boolean threaded) {
3039        this.threaded = threaded;
3040    }
3041
3042    /**
3043Return true if the handle is configured to be <em>free-threaded</em>.
3044<p>
3045This method may be called at any time during the life of the application.
3046<p>
3047@return
3048True if the handle is configured to be <em>free-threaded</em>.
3049    */
3050    public boolean getThreaded() {
3051        return threaded;
3052    }
3053
3054    /**
3055    Configure the database environment for transactions.
3056    <p>
3057    This configuration option should be used when transactional guarantees
3058    such as atomicity of multiple operations and durability are important.
3059    <p>
3060    @param transactional
3061    If true, configure the database environment for transactions.
3062    */
3063    public void setTransactional(final boolean transactional) {
3064        this.transactional = transactional;
3065    }
3066
3067    /**
3068Return true if the database environment is configured for transactions.
3069<p>
3070This method may be called at any time during the life of the application.
3071<p>
3072@return
3073True if the database environment is configured for transactions.
3074    */
3075    public boolean getTransactional() {
3076        return transactional;
3077    }
3078
3079    /**
3080    Configure the system to not write or synchronously flush the log
3081    on transaction commit.
3082    <p>
3083    This means that transactions exhibit the ACI (atomicity, consistency,
3084    and isolation) properties, but not D (durability); that is, database
3085    integrity will be maintained, but if the application or system fails,
3086    it is possible some number of the most recently committed transactions
3087    may be undone during recovery.  The number of transactions at risk is
3088    governed by how many log updates can fit into the log buffer, how often
3089    the operating system flushes dirty buffers to disk, and how often the
3090    log is checkpointed.
3091    <p>
3092    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
3093any other library handles opened within the scope of that handle).
3094For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
3095handles opened in the database environment must either call this method
3096or the configuration should be specified in the database environment's
3097DB_CONFIG configuration file.
3098    <p>
3099    This method may be called at any time during the life of the application.
3100    <p>
3101    @param txnNoSync
3102    If true, configure the system to not write or synchronously flush
3103    the log on transaction commit.
3104    */
3105    public void setTxnNoSync(final boolean txnNoSync) {
3106        this.txnNoSync = txnNoSync;
3107    }
3108
3109    /**
3110Return true if the system has been configured to not write or synchronously
3111    flush the log on transaction commit.
3112<p>
3113This method may be called at any time during the life of the application.
3114<p>
3115@return
3116True if the system has been configured to not write or synchronously
3117    flush the log on transaction commit.
3118    */
3119    public boolean getTxnNoSync() {
3120        return txnNoSync;
3121    }
3122
3123    /**
3124    If a lock is unavailable for any Berkeley DB operation performed in the
3125    context of a transaction, cause the operation to throw {@link
3126    LockNotGrantedException} without waiting for the lock.
3127    <p>
3128    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
3129any other library handles opened within the scope of that handle).
3130For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
3131handles opened in the database environment must either call this method
3132or the configuration should be specified in the database environment's
3133DB_CONFIG configuration file.
3134    <p>
3135    This method may be called at any time during the life of the application.
3136    <p>
3137    @param txnNoWait
3138    If true, configure transactions to not wait for locks by default.
3139    */
3140    public void setTxnNoWait(final boolean txnNoWait) {
3141        this.txnNoWait = txnNoWait;
3142    }
3143
3144    /**
3145Return true if the transactions have been configured to not wait for locks by default.
3146<p>
3147This method may be called at any time during the life of the application.
3148<p>
3149@return
3150True if the transactions have been configured to not wait for locks by default.
3151    */
3152    public boolean getTxnNoWait() {
3153        return txnNoWait;
3154    }
3155
3156    /**
3157    Configure the system to not write log records.
3158    <p>
3159    This means that transactions exhibit the ACI (atomicity, consistency,
3160    and isolation) properties, but not D (durability); that is, database
3161    integrity will be maintained, but if the application or system
3162    fails, integrity will not persist.  All database files must be
3163    verified and/or restored from backup after a failure.  In order to
3164    ensure integrity after application shut down, all database handles
3165    must be closed without specifying noSync, or all database changes
3166    must be flushed from the database environment cache using the
3167    {@link com.sleepycat.db.Environment#checkpoint Environment.checkpoint}.
3168    <p>
3169    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
3170any other library handles opened within the scope of that handle).
3171For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
3172handles opened in the database environment must either call this method
3173or the configuration should be specified in the database environment's
3174DB_CONFIG configuration file.
3175    <p>
3176    This method may be called at any time during the life of the application.
3177    <p>
3178    @param txnNotDurable
3179    If true, configure the system to not write log records.
3180    */
3181    public void setTxnNotDurable(final boolean txnNotDurable) {
3182        this.txnNotDurable = txnNotDurable;
3183    }
3184
3185    /**
3186Return true if the system has been configured to not write log records.
3187<p>
3188This method may be called at any time during the life of the application.
3189<p>
3190@return
3191True if the system has been configured to not write log records.
3192    */
3193    public boolean getTxnNotDurable() {
3194        return txnNotDurable;
3195    }
3196
3197    /**
3198    Configure the database environment to run transactions at snapshot
3199    isolation by default.  See {@link TransactionConfig#setSnapshot} for more
3200    information.
3201    <p>
3202    This method may be called at any time during the life of the application.
3203    <p>
3204    @param txnSnapshot
3205    If true, configure the system to default to snapshot isolation.
3206    */
3207    public void setTxnSnapshot(final boolean txnSnapshot) {
3208        this.txnSnapshot = txnSnapshot;
3209    }
3210
3211    /**
3212Return true if the handle is configured to run all transactions at snapshot
3213    isolation.
3214<p>
3215This method may be called at any time during the life of the application.
3216<p>
3217@return
3218True if the handle is configured to run all transactions at snapshot
3219    isolation.
3220    */
3221    public boolean getTxnSnapshot() {
3222        return txnSnapshot;
3223    }
3224
3225    /**
3226    Configure the database environment to support at least txnMaxActive
3227    active transactions.
3228    <p>
3229    This value bounds the size of the memory allocated for transactions.
3230    Child transactions are counted as active until they either commit
3231    or abort.
3232    <p>
3233    When all of the memory available in the database environment for
3234    transactions is in use, calls to {@link com.sleepycat.db.Environment#beginTransaction Environment.beginTransaction}
3235    will fail (until some active transactions complete).  If this
3236    interface is never called, the database environment is configured
3237    to support at least 20 active transactions.
3238    <p>
3239    The database environment's number of active transactions may also be set using the environment's
3240DB_CONFIG file.  The syntax of the entry in that file is a single line
3241with the string "set_tx_max", one or more whitespace characters, and the number of transactions.
3242Because the DB_CONFIG file is read when the database environment is
3243opened, it will silently overrule configuration done before that time.
3244    <p>
3245    This method configures a database environment, including all threads
3246of control accessing the database environment, not only the operations
3247performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
3248    <p>
3249    This method may not be called after the
3250environment has been opened.
3251If joining an existing database environment, any
3252information specified to this method will be ignored.
3253    <p>
3254    @param txnMaxActive
3255    The minimum number of simultaneously active transactions supported
3256    by the database environment.
3257    */
3258    public void setTxnMaxActive(final int txnMaxActive) {
3259        this.txnMaxActive = txnMaxActive;
3260    }
3261
3262    /**
3263Return the minimum number of simultaneously active transactions supported
3264    by the database environment.
3265<p>
3266This method may be called at any time during the life of the application.
3267<p>
3268@return
3269The minimum number of simultaneously active transactions supported
3270    by the database environment.
3271    */
3272    public int getTxnMaxActive() {
3273        return txnMaxActive;
3274    }
3275
3276    /**
3277    Set the timeout value for the database environment
3278transactions.
3279<p>
3280Transaction timeouts are checked whenever a thread of control blocks on
3281a lock or when deadlock detection is performed.  The lock is one
3282requested on behalf of a transaction, normally by the database access
3283methods underlying the application.
3284As timeouts are only checked when the lock request first blocks or when
3285deadlock detection is performed, the accuracy of the timeout depends on
3286how often deadlock detection is performed.
3287<p>
3288Timeout values specified for the database environment may be overridden
3289on a
3290per-transaction basis by {@link com.sleepycat.db.Transaction#setTxnTimeout Transaction.setTxnTimeout}.
3291<p>
3292This method configures a database environment, including all threads
3293of control accessing the database environment, not only the operations
3294performed using a specified {@link com.sleepycat.db.Environment Environment} handle.
3295<p>
3296This method may be called at any time during the life of the application.
3297<p>
3298@param txnTimeout
3299The timeout value, specified as an unsigned 32-bit number of
3300microseconds, limiting the maximum timeout to roughly 71 minutes.
3301<p>
3302<p>
3303@throws IllegalArgumentException if an invalid parameter was specified.
3304<p>
3305@throws DatabaseException if a failure occurs.
3306    */
3307    public void setTxnTimeout(final long txnTimeout) {
3308        this.txnTimeout = txnTimeout;
3309    }
3310
3311    /**
3312Return the database environment transaction timeout value, in
3313    microseconds; a timeout of 0 means no timeout is set.
3314<p>
3315This method may be called at any time during the life of the application.
3316<p>
3317@return
3318The database environment transaction timeout value, in
3319    microseconds; a timeout of 0 means no timeout is set.
3320    */
3321    public long getTxnTimeout() {
3322        return txnTimeout;
3323    }
3324
3325    /**
3326    Recover to the specified time rather than to the most current
3327    possible date.
3328    <p>
3329    Once a database environment has been upgraded to a new version of
3330    Berkeley DB involving a log format change, it is no longer possible
3331    to recover to a specific time before that upgrade.
3332    <p>
3333    This method configures only operations performed using a single a
3334{@link com.sleepycat.db.Environment Environment} handle, not an entire database environment.
3335    <p>
3336    This method may not be called after the
3337environment has been opened.
3338    <p>
3339    @param txnTimestamp
3340    The recovery timestamp.
3341    Only the seconds (not the milliseconds) of the timestamp are used.
3342    */
3343    public void setTxnTimestamp(final java.util.Date txnTimestamp) {
3344        this.txnTimestamp = txnTimestamp;
3345    }
3346
3347    /**
3348    Return the time to which recovery will be done, or 0 if recovery will
3349    be done to the most current possible date.
3350    <p>
3351    @return
3352    The time to which recovery will be done, or 0 if recovery will be
3353    done to the most current possible date.
3354    */
3355    public java.util.Date getTxnTimestamp() {
3356        return txnTimestamp;
3357    }
3358
3359    /**
3360    Configure the system to write, but not synchronously flush, the log on
3361    transaction commit.
3362    <p>
3363    This means that transactions exhibit the ACI (atomicity, consistency,
3364    and isolation) properties, but not D (durability); that is, database
3365    integrity will be maintained, but if the system fails, it is possible
3366    some number of the most recently committed transactions may be undone
3367    during recovery.  The number of transactions at risk is governed by how
3368    often the system flushes dirty buffers to disk and how often the log is
3369    checkpointed.
3370    <p>
3371    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
3372any other library handles opened within the scope of that handle).
3373For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
3374handles opened in the database environment must either call this method
3375or the configuration should be specified in the database environment's
3376DB_CONFIG configuration file.
3377    <p>
3378    This method may be called at any time during the life of the application.
3379    <p>
3380    @param txnWriteNoSync
3381    If true, configure the system to write, but not synchronously flush,
3382    the log on transaction commit.
3383    */
3384    public void setTxnWriteNoSync(final boolean txnWriteNoSync) {
3385        this.txnWriteNoSync = txnWriteNoSync;
3386    }
3387
3388    /**
3389Return true if the system has been configured to write, but not synchronously
3390    flush, the log on transaction commit.
3391<p>
3392This method may be called at any time during the life of the application.
3393<p>
3394@return
3395True if the system has been configured to write, but not synchronously
3396    flush, the log on transaction commit.
3397    */
3398    public boolean getTxnWriteNoSync() {
3399        return txnWriteNoSync;
3400    }
3401
3402    /**
3403    Configure the database environment to accept information from the
3404    process environment when naming files, regardless of the status of
3405    the process.
3406    <p>
3407    Because permitting users to specify which files are used can create
3408    security problems, environment information will be used in file
3409    naming for all users only if configured to do so.
3410    <p>
3411    @param useEnvironment
3412    If true, configure the database environment to accept information
3413    from the process environment when naming files.
3414    */
3415    public void setUseEnvironment(final boolean useEnvironment) {
3416        this.useEnvironment = useEnvironment;
3417    }
3418
3419    /**
3420Return true if the database environment is configured to accept information
3421    from the process environment when naming files.
3422<p>
3423This method may be called at any time during the life of the application.
3424<p>
3425@return
3426True if the database environment is configured to accept information
3427    from the process environment when naming files.
3428    */
3429    public boolean getUseEnvironment() {
3430        return useEnvironment;
3431    }
3432
3433    /**
3434    Configure the database environment to accept information from the
3435    process environment when naming files, if the process has
3436    appropriate permissions (for example, users with a user-ID of 0 on
3437    UNIX systems).
3438    <p>
3439    Because permitting users to specify which files are used can create
3440    security problems, environment information will be used in file
3441    naming for all users only if configured to do so.
3442    <p>
3443    @param useEnvironmentRoot
3444    If true, configure the database environment to accept information
3445    from the process environment when naming files if the process has
3446    appropriate permissions.
3447    */
3448    public void setUseEnvironmentRoot(final boolean useEnvironmentRoot) {
3449        this.useEnvironmentRoot = useEnvironmentRoot;
3450    }
3451
3452    /**
3453Return true if the database environment is configured to accept information
3454    from the process environment when naming files if the process has
3455    appropriate permissions.
3456<p>
3457This method may be called at any time during the life of the application.
3458<p>
3459@return
3460True if the database environment is configured to accept information
3461    from the process environment when naming files if the process has
3462    appropriate permissions.
3463    */
3464    public boolean getUseEnvironmentRoot() {
3465        return useEnvironmentRoot;
3466    }
3467
3468    /**
3469    Display verbose information.
3470    <p>
3471    This method may be called at any time during the life of the application.
3472    <p>
3473    @param flag
3474    The type of verbose information being configured.
3475    <p>
3476    @param enable
3477    If true, display additional information.
3478    */
3479    public void setVerbose(final VerboseConfig flag, boolean enable) {
3480        int iflag = flag.getInternalFlag();
3481        switch (iflag) {
3482        case DbConstants.DB_VERB_DEADLOCK:
3483            verboseDeadlock = enable;
3484            break;
3485        case DbConstants.DB_VERB_FILEOPS:
3486            verboseFileops = enable;
3487            break;
3488        case DbConstants.DB_VERB_FILEOPS_ALL:
3489            verboseFileopsAll = enable;
3490            break;
3491        case DbConstants.DB_VERB_RECOVERY:
3492            verboseRecovery = enable;
3493            break;
3494        case DbConstants.DB_VERB_REGISTER:
3495            verboseRegister = enable;
3496            break;
3497        case DbConstants.DB_VERB_REPLICATION:
3498            verboseReplication = enable;
3499            break;
3500        case DbConstants.DB_VERB_WAITSFOR:
3501            verboseWaitsFor = enable;
3502            break;
3503        default:
3504            throw new IllegalArgumentException(
3505                "Unknown verbose flag: " + DbEnv.strerror(iflag));
3506        }
3507    }
3508
3509    /**
3510    Return if the database environment is configured to display
3511    a given type of verbose information.
3512    <p>
3513    This method may be called at any time during the life of the application.
3514    <p>
3515    @param flag
3516    The type of verbose information being queried.
3517    <p>
3518    @return
3519    If the database environment is configured to display additional
3520    information of the specified type.
3521    */
3522    public boolean getVerbose(final VerboseConfig flag) {
3523        int iflag = flag.getInternalFlag();
3524        switch (iflag) {
3525        case DbConstants.DB_VERB_DEADLOCK:
3526            return verboseDeadlock;
3527        case DbConstants.DB_VERB_FILEOPS:
3528            return verboseFileops;
3529        case DbConstants.DB_VERB_FILEOPS_ALL:
3530            return verboseFileopsAll;
3531        case DbConstants.DB_VERB_RECOVERY:
3532            return verboseRecovery;
3533        case DbConstants.DB_VERB_REGISTER:
3534            return verboseRegister;
3535        case DbConstants.DB_VERB_REPLICATION:
3536            return verboseReplication;
3537        case DbConstants.DB_VERB_WAITSFOR:
3538            return verboseWaitsFor;
3539        default:
3540            throw new IllegalArgumentException(
3541                "Unknown verbose flag: " + DbEnv.strerror(iflag));
3542       }
3543    }
3544
3545    /**
3546    Display additional information when doing deadlock detection.
3547    <p>
3548    This method may be called at any time during the life of the application.
3549    <p>
3550    @param verboseDeadlock
3551    If true, display additional information when doing deadlock
3552    detection.
3553    <p>
3554    @deprecated replaced by {@link #setVerbose}
3555    */
3556    public void setVerboseDeadlock(final boolean verboseDeadlock) {
3557        this.verboseDeadlock = verboseDeadlock;
3558    }
3559
3560    /**
3561    Return if the database environment is configured to display
3562    additional information when doing deadlock detection.
3563    <p>
3564    This method may be called at any time during the life of the application.
3565    <p>
3566    @return
3567    If the database environment is configured to display additional
3568    information when doing deadlock detection.
3569    <p>
3570    @deprecated replaced by {@link #getVerbose}
3571    */
3572    public boolean getVerboseDeadlock() {
3573        return verboseDeadlock;
3574    }
3575
3576    /**
3577    Display additional information when performing recovery.
3578    <p>
3579    This method may be called at any time during the life of the application.
3580    <p>
3581    @param verboseRecovery
3582    If true, display additional information when performing recovery.
3583    <p>
3584    @deprecated replaced by {@link #setVerbose}
3585    */
3586    public void setVerboseRecovery(final boolean verboseRecovery) {
3587        this.verboseRecovery = verboseRecovery;
3588    }
3589
3590    /**
3591    Return if the database environment is configured to display
3592    additional information when performing recovery.
3593    <p>
3594    This method may be called at any time during the life of the application.
3595    <p>
3596    @return
3597    If the database environment is configured to display additional
3598    information when performing recovery.
3599    <p>
3600    @deprecated replaced by {@link #getVerbose}
3601    */
3602    public boolean getVerboseRecovery() {
3603        return verboseRecovery;
3604    }
3605
3606    /**
3607    Display additional information concerning support for the
3608     {@link #setRegister} method.
3609    <p>
3610    This method may be called at any time during the life of the application.
3611    <p>
3612    @param verboseRegister
3613    If true, display additional information concerning support for the
3614     {@link #setRegister} method
3615    <p>
3616    @deprecated replaced by {@link #setVerbose}
3617    */
3618    public void setVerboseRegister(final boolean verboseRegister) {
3619        this.verboseRegister = verboseRegister;
3620    }
3621
3622    /**
3623    Return if the database environment is configured to display
3624    additional information concerning support for the
3625     {@link #setRegister} method.
3626    <p>
3627    This method may be called at any time during the life of the application.
3628    <p>
3629    @return
3630    If the database environment is configured to display additional
3631    information concerning support for the
3632     {@link #setRegister} method.
3633    <p>
3634    @deprecated replaced by {@link #getVerbose}
3635    */
3636    public boolean getVerboseRegister() {
3637        return verboseRegister;
3638    }
3639
3640    /**
3641    Display additional information when processing replication messages.
3642    <p>
3643    Note, to get complete replication logging when debugging replication
3644    applications, you must also configure and build the Berkeley DB
3645    library with the --enable-diagnostic configuration option as well
3646    as call this method.
3647    <p>
3648    This method may be called at any time during the life of the application.
3649    <p>
3650    @param verboseReplication
3651    If true, display additional information when processing replication
3652    messages.
3653    <p>
3654    @deprecated replaced by {@link #setVerbose}
3655    */
3656    public void setVerboseReplication(final boolean verboseReplication) {
3657        this.verboseReplication = verboseReplication;
3658    }
3659
3660    /**
3661    Return if the database environment is configured to display
3662    additional information when processing replication messages.
3663    <p>
3664    This method may be called at any time during the life of the application.
3665    <p>
3666    @return
3667    If the database environment is configured to display additional
3668    information when processing replication messages.
3669    <p>
3670    @deprecated replaced by {@link #getVerbose}
3671    */
3672    public boolean getVerboseReplication() {
3673        return verboseReplication;
3674    }
3675
3676    /**
3677    Display the waits-for table when doing deadlock detection.
3678    <p>
3679    This method may be called at any time during the life of the application.
3680    <p>
3681    @param verboseWaitsFor
3682    If true, display the waits-for table when doing deadlock detection.
3683    <p>
3684    @deprecated replaced by {@link #setVerbose}
3685    */
3686    public void setVerboseWaitsFor(final boolean verboseWaitsFor) {
3687        this.verboseWaitsFor = verboseWaitsFor;
3688    }
3689
3690    /**
3691    Return if the database environment is configured to display the
3692    waits-for table when doing deadlock detection.
3693    <p>
3694    This method may be called at any time during the life of the application.
3695    <p>
3696    @return
3697    If the database environment is configured to display the waits-for
3698    table when doing deadlock detection.
3699    <p>
3700    @deprecated replaced by {@link #getVerbose}
3701    */
3702    public boolean getVerboseWaitsFor() {
3703        return verboseWaitsFor;
3704    }
3705
3706    /**
3707    Configure the system to yield the processor immediately after each
3708    page or mutex acquisition.
3709    <p>
3710    This functionality should never be used for purposes other than
3711    stress testing.
3712    <p>
3713    This method only affects the specified {@link com.sleepycat.db.Environment Environment} handle (and
3714any other library handles opened within the scope of that handle).
3715For consistent behavior across the environment, all {@link com.sleepycat.db.Environment Environment}
3716handles opened in the database environment must either call this method
3717or the configuration should be specified in the database environment's
3718DB_CONFIG configuration file.
3719    <p>
3720    This method may be called at any time during the life of the application.
3721    <p>
3722    @param yieldCPU
3723    If true, configure the system to yield the processor immediately
3724    after each page or mutex acquisition.
3725    */
3726    public void setYieldCPU(final boolean yieldCPU) {
3727        this.yieldCPU = yieldCPU;
3728    }
3729
3730    /**
3731Return true if the system has been configured to yield the processor
3732    immediately after each page or mutex acquisition.
3733<p>
3734This method may be called at any time during the life of the application.
3735<p>
3736@return
3737True if the system has been configured to yield the processor
3738    immediately after each page or mutex acquisition.
3739    */
3740    public boolean getYieldCPU() {
3741        return yieldCPU;
3742    }
3743
3744    private boolean lockConflictsEqual(byte[][] lc1, byte[][]lc2) {
3745        if (lc1 == lc2)
3746            return true;
3747        if (lc1 == null || lc2 == null || lc1.length != lc2.length)
3748            return false;
3749        for (int i = 0; i < lc1.length; i++) {
3750            if (lc1[i].length != lc2[i].length)
3751                return false;
3752            for (int j = 0; j < lc1[i].length; j++)
3753                if (lc1[i][j] != lc2[i][j])
3754                    return false;
3755        }
3756        return true;
3757    }
3758
3759    /* package */
3760    DbEnv openEnvironment(final java.io.File home)
3761        throws DatabaseException, java.io.FileNotFoundException {
3762
3763        final DbEnv dbenv = createEnvironment();
3764        int openFlags = 0;
3765
3766        openFlags |= allowCreate ? DbConstants.DB_CREATE : 0;
3767        openFlags |= initializeCache ? DbConstants.DB_INIT_MPOOL : 0;
3768        openFlags |= initializeCDB ? DbConstants.DB_INIT_CDB : 0;
3769        openFlags |= initializeLocking ? DbConstants.DB_INIT_LOCK : 0;
3770        openFlags |= initializeLogging ? DbConstants.DB_INIT_LOG : 0;
3771        openFlags |= initializeReplication ? DbConstants.DB_INIT_REP : 0;
3772        openFlags |= joinEnvironment ? DbConstants.DB_JOINENV : 0;
3773        openFlags |= lockDown ? DbConstants.DB_LOCKDOWN : 0;
3774        openFlags |= isPrivate ? DbConstants.DB_PRIVATE : 0;
3775        openFlags |= register ? DbConstants.DB_REGISTER : 0;
3776        openFlags |= runRecovery ? DbConstants.DB_RECOVER : 0;
3777        openFlags |= runFatalRecovery ? DbConstants.DB_RECOVER_FATAL : 0;
3778        openFlags |= systemMemory ? DbConstants.DB_SYSTEM_MEM : 0;
3779        openFlags |= threaded ? DbConstants.DB_THREAD : 0;
3780        openFlags |= transactional ? DbConstants.DB_INIT_TXN : 0;
3781        openFlags |= useEnvironment ? DbConstants.DB_USE_ENVIRON : 0;
3782        openFlags |= useEnvironmentRoot ? DbConstants.DB_USE_ENVIRON_ROOT : 0;
3783
3784        boolean succeeded = false;
3785        try {
3786            dbenv.open((home == null) ? null : home.toString(),
3787                openFlags, mode);
3788            succeeded = true;
3789            return dbenv;
3790        } finally {
3791            if (!succeeded)
3792                try {
3793                    dbenv.close(0);
3794                } catch (Throwable t) {
3795                    // Ignore it -- an exception is already in flight.
3796                }
3797        }
3798    }
3799
3800
3801    /* package */
3802    DbEnv createEnvironment()
3803        throws DatabaseException {
3804
3805        int createFlags = 0;
3806
3807        if (rpcServer != null)
3808                createFlags |= DbConstants.DB_RPCCLIENT;
3809
3810        final DbEnv dbenv = new DbEnv(createFlags);
3811        configureEnvironment(dbenv, DEFAULT);
3812        return dbenv;
3813    }
3814
3815    /* package */
3816    void configureEnvironment(final DbEnv dbenv,
3817                              final EnvironmentConfig oldConfig)
3818        throws DatabaseException {
3819
3820        if (errorHandler != oldConfig.errorHandler)
3821            dbenv.set_errcall(errorHandler);
3822        if (errorPrefix != oldConfig.errorPrefix &&
3823            errorPrefix != null && !errorPrefix.equals(oldConfig.errorPrefix))
3824            dbenv.set_errpfx(errorPrefix);
3825        if (errorStream != oldConfig.errorStream)
3826            dbenv.set_error_stream(errorStream);
3827
3828        if (rpcServer != oldConfig.rpcServer ||
3829            rpcClientTimeout != oldConfig.rpcClientTimeout ||
3830            rpcServerTimeout != oldConfig.rpcServerTimeout)
3831            dbenv.set_rpc_server(rpcServer,
3832                rpcClientTimeout, rpcServerTimeout, 0);
3833
3834        // We always set DB_TIME_NOTGRANTED in the Java API, because
3835        // LockNotGrantedException extends DeadlockException, so there's no
3836        // reason why an application would prefer one to the other.
3837        int onFlags = DbConstants.DB_TIME_NOTGRANTED;
3838        int offFlags = 0;
3839
3840        if (cdbLockAllDatabases && !oldConfig.cdbLockAllDatabases)
3841            onFlags |= DbConstants.DB_CDB_ALLDB;
3842        if (!cdbLockAllDatabases && oldConfig.cdbLockAllDatabases)
3843            offFlags |= DbConstants.DB_CDB_ALLDB;
3844
3845        if (directDatabaseIO && !oldConfig.directDatabaseIO)
3846            onFlags |= DbConstants.DB_DIRECT_DB;
3847        if (!directDatabaseIO && oldConfig.directDatabaseIO)
3848            offFlags |= DbConstants.DB_DIRECT_DB;
3849
3850        if (dsyncDatabases && !oldConfig.dsyncDatabases)
3851            onFlags |= DbConstants.DB_DSYNC_DB;
3852        if (!dsyncDatabases && oldConfig.dsyncDatabases)
3853            offFlags |= DbConstants.DB_DSYNC_DB;
3854
3855        if (initializeRegions && !oldConfig.initializeRegions)
3856            onFlags |= DbConstants.DB_REGION_INIT;
3857        if (!initializeRegions && oldConfig.initializeRegions)
3858            offFlags |= DbConstants.DB_REGION_INIT;
3859
3860        if (multiversion && !oldConfig.multiversion)
3861            onFlags |= DbConstants.DB_MULTIVERSION;
3862        if (!multiversion && oldConfig.multiversion)
3863            offFlags |= DbConstants.DB_MULTIVERSION;
3864
3865        if (noLocking && !oldConfig.noLocking)
3866            onFlags |= DbConstants.DB_NOLOCKING;
3867        if (!noLocking && oldConfig.noLocking)
3868            offFlags |= DbConstants.DB_NOLOCKING;
3869
3870        if (noMMap && !oldConfig.noMMap)
3871            onFlags |= DbConstants.DB_NOMMAP;
3872        if (!noMMap && oldConfig.noMMap)
3873            offFlags |= DbConstants.DB_NOMMAP;
3874
3875        if (noPanic && !oldConfig.noPanic)
3876            onFlags |= DbConstants.DB_NOPANIC;
3877        if (!noPanic && oldConfig.noPanic)
3878            offFlags |= DbConstants.DB_NOPANIC;
3879
3880        if (overwrite && !oldConfig.overwrite)
3881            onFlags |= DbConstants.DB_OVERWRITE;
3882        if (!overwrite && oldConfig.overwrite)
3883            offFlags |= DbConstants.DB_OVERWRITE;
3884
3885        if (txnNoSync && !oldConfig.txnNoSync)
3886            onFlags |= DbConstants.DB_TXN_NOSYNC;
3887        if (!txnNoSync && oldConfig.txnNoSync)
3888            offFlags |= DbConstants.DB_TXN_NOSYNC;
3889
3890        if (txnNoWait && !oldConfig.txnNoWait)
3891            onFlags |= DbConstants.DB_TXN_NOWAIT;
3892        if (!txnNoWait && oldConfig.txnNoWait)
3893            offFlags |= DbConstants.DB_TXN_NOWAIT;
3894
3895        if (txnNotDurable && !oldConfig.txnNotDurable)
3896            onFlags |= DbConstants.DB_TXN_NOT_DURABLE;
3897        if (!txnNotDurable && oldConfig.txnNotDurable)
3898            offFlags |= DbConstants.DB_TXN_NOT_DURABLE;
3899
3900        if (txnSnapshot && !oldConfig.txnSnapshot)
3901            onFlags |= DbConstants.DB_TXN_SNAPSHOT;
3902        if (!txnSnapshot && oldConfig.txnSnapshot)
3903            offFlags |= DbConstants.DB_TXN_SNAPSHOT;
3904
3905        if (txnWriteNoSync && !oldConfig.txnWriteNoSync)
3906            onFlags |= DbConstants.DB_TXN_WRITE_NOSYNC;
3907        if (!txnWriteNoSync && oldConfig.txnWriteNoSync)
3908            offFlags |= DbConstants.DB_TXN_WRITE_NOSYNC;
3909
3910        if (yieldCPU && !oldConfig.yieldCPU)
3911            onFlags |= DbConstants.DB_YIELDCPU;
3912        if (!yieldCPU && oldConfig.yieldCPU)
3913            offFlags |= DbConstants.DB_YIELDCPU;
3914
3915        if (onFlags != 0)
3916            dbenv.set_flags(onFlags, true);
3917        if (offFlags != 0)
3918            dbenv.set_flags(offFlags, false);
3919
3920	/* Log flags */
3921        if (directLogIO != oldConfig.directLogIO)
3922            dbenv.log_set_config(DbConstants.DB_LOG_DIRECT, directLogIO);
3923
3924        if (dsyncLog != oldConfig.dsyncLog)
3925            dbenv.log_set_config(DbConstants.DB_LOG_DSYNC, dsyncLog);
3926
3927        if (logAutoRemove != oldConfig.logAutoRemove)
3928            dbenv.log_set_config(DbConstants.DB_LOG_AUTO_REMOVE, logAutoRemove);
3929
3930        if (logInMemory != oldConfig.logInMemory)
3931            dbenv.log_set_config(DbConstants.DB_LOG_IN_MEMORY, logInMemory);
3932
3933        if (logZero != oldConfig.logZero)
3934            dbenv.log_set_config(DbConstants.DB_LOG_ZERO, logZero);
3935
3936        /* Verbose flags */
3937        if (verboseDeadlock && !oldConfig.verboseDeadlock)
3938            dbenv.set_verbose(DbConstants.DB_VERB_DEADLOCK, true);
3939        if (!verboseDeadlock && oldConfig.verboseDeadlock)
3940            dbenv.set_verbose(DbConstants.DB_VERB_DEADLOCK, false);
3941
3942        if (verboseFileops && !oldConfig.verboseFileops)
3943            dbenv.set_verbose(DbConstants.DB_VERB_FILEOPS, true);
3944        if (!verboseFileops && oldConfig.verboseFileops)
3945            dbenv.set_verbose(DbConstants.DB_VERB_FILEOPS, false);
3946
3947        if (verboseFileopsAll && !oldConfig.verboseFileopsAll)
3948            dbenv.set_verbose(DbConstants.DB_VERB_FILEOPS_ALL, true);
3949        if (!verboseFileopsAll && oldConfig.verboseFileopsAll)
3950            dbenv.set_verbose(DbConstants.DB_VERB_FILEOPS_ALL, false);
3951
3952        if (verboseRecovery && !oldConfig.verboseRecovery)
3953            dbenv.set_verbose(DbConstants.DB_VERB_RECOVERY, true);
3954        if (!verboseRecovery && oldConfig.verboseRecovery)
3955            dbenv.set_verbose(DbConstants.DB_VERB_RECOVERY, false);
3956
3957        if (verboseRegister && !oldConfig.verboseRegister)
3958            dbenv.set_verbose(DbConstants.DB_VERB_REGISTER, true);
3959        if (!verboseRegister && oldConfig.verboseRegister)
3960            dbenv.set_verbose(DbConstants.DB_VERB_REGISTER, false);
3961
3962        if (verboseReplication && !oldConfig.verboseReplication)
3963            dbenv.set_verbose(DbConstants.DB_VERB_REPLICATION, true);
3964        if (!verboseReplication && oldConfig.verboseReplication)
3965            dbenv.set_verbose(DbConstants.DB_VERB_REPLICATION, false);
3966
3967        if (verboseWaitsFor && !oldConfig.verboseWaitsFor)
3968            dbenv.set_verbose(DbConstants.DB_VERB_WAITSFOR, true);
3969        if (!verboseWaitsFor && oldConfig.verboseWaitsFor)
3970            dbenv.set_verbose(DbConstants.DB_VERB_WAITSFOR, false);
3971
3972        /* Callbacks */
3973        if (feedbackHandler != oldConfig.feedbackHandler)
3974            dbenv.set_feedback(feedbackHandler);
3975        if (logRecordHandler != oldConfig.logRecordHandler)
3976            dbenv.set_app_dispatch(logRecordHandler);
3977        if (eventHandler != oldConfig.eventHandler)
3978            dbenv.set_event_notify(eventHandler);
3979        if (messageHandler != oldConfig.messageHandler)
3980            dbenv.set_msgcall(messageHandler);
3981        if (panicHandler != oldConfig.panicHandler)
3982            dbenv.set_paniccall(panicHandler);
3983        if (replicationTransport != oldConfig.replicationTransport)
3984            dbenv.rep_set_transport(envid, replicationTransport);
3985
3986        /* Other settings */
3987        if (cacheSize != oldConfig.cacheSize ||
3988            cacheCount != oldConfig.cacheCount)
3989            dbenv.set_cachesize(cacheSize, cacheCount);
3990        if (cacheMax != oldConfig.cacheMax)
3991            dbenv.set_cache_max(cacheMax);
3992        for (final java.util.Enumeration e = dataDirs.elements();
3993            e.hasMoreElements();) {
3994            final java.io.File dir = (java.io.File)e.nextElement();
3995            if (!oldConfig.dataDirs.contains(dir))
3996                dbenv.set_data_dir(dir.toString());
3997        }
3998        if (!lockConflictsEqual(lockConflicts, oldConfig.lockConflicts))
3999            dbenv.set_lk_conflicts(lockConflicts);
4000        if (lockDetectMode != oldConfig.lockDetectMode)
4001            dbenv.set_lk_detect(lockDetectMode.getFlag());
4002        if (maxLocks != oldConfig.maxLocks)
4003            dbenv.set_lk_max_locks(maxLocks);
4004        if (maxLockers != oldConfig.maxLockers)
4005            dbenv.set_lk_max_lockers(maxLockers);
4006        if (maxLockObjects != oldConfig.maxLockObjects)
4007            dbenv.set_lk_max_objects(maxLockObjects);
4008        if (maxLogFileSize != oldConfig.maxLogFileSize)
4009            dbenv.set_lg_max(maxLogFileSize);
4010        if (logBufferSize != oldConfig.logBufferSize)
4011            dbenv.set_lg_bsize(logBufferSize);
4012        if (logDirectory != oldConfig.logDirectory && logDirectory != null &&
4013            !logDirectory.equals(oldConfig.logDirectory))
4014            dbenv.set_lg_dir(logDirectory.toString());
4015        if (logFileMode != oldConfig.logFileMode)
4016            dbenv.set_lg_filemode(logFileMode);
4017        if (logRegionSize != oldConfig.logRegionSize)
4018            dbenv.set_lg_regionmax(logRegionSize);
4019        if (maxOpenFiles != oldConfig.maxOpenFiles)
4020            dbenv.set_mp_max_openfd(maxOpenFiles);
4021        if (maxWrite != oldConfig.maxWrite ||
4022            maxWriteSleep != oldConfig.maxWriteSleep)
4023            dbenv.set_mp_max_write(maxWrite, maxWriteSleep);
4024        if (messageStream != oldConfig.messageStream)
4025            dbenv.set_message_stream(messageStream);
4026        if (mmapSize != oldConfig.mmapSize)
4027            dbenv.set_mp_mmapsize(mmapSize);
4028        if (password != null)
4029            dbenv.set_encrypt(password, DbConstants.DB_ENCRYPT_AES);
4030        if (replicationClockskewFast != oldConfig.replicationClockskewFast ||
4031            replicationClockskewSlow != oldConfig.replicationClockskewSlow)
4032            dbenv.rep_set_clockskew(replicationClockskewFast, replicationClockskewSlow);
4033        if (replicationLimit != oldConfig.replicationLimit)
4034            dbenv.rep_set_limit(replicationLimit);
4035        if (replicationRequestMin != oldConfig.replicationRequestMin ||
4036            replicationRequestMax != oldConfig.replicationRequestMax)
4037            dbenv.rep_set_request(replicationRequestMin, replicationRequestMax);
4038        if (segmentId != oldConfig.segmentId)
4039            dbenv.set_shm_key(segmentId);
4040        if (mutexAlignment != oldConfig.mutexAlignment)
4041            dbenv.mutex_set_align(mutexAlignment);
4042        if (mutexIncrement != oldConfig.mutexIncrement)
4043            dbenv.mutex_set_increment(mutexIncrement);
4044        if (maxMutexes != oldConfig.maxMutexes)
4045            dbenv.mutex_set_max(maxMutexes);
4046        if (mutexTestAndSetSpins != oldConfig.mutexTestAndSetSpins)
4047            dbenv.mutex_set_tas_spins(mutexTestAndSetSpins);
4048        if (replicationNumSites != oldConfig.replicationNumSites)
4049            dbenv.rep_set_nsites(replicationNumSites);
4050        if (replicationPriority != oldConfig.replicationPriority)
4051            dbenv.rep_set_priority(replicationPriority);
4052        if (lockTimeout != oldConfig.lockTimeout)
4053            dbenv.set_timeout(lockTimeout, DbConstants.DB_SET_LOCK_TIMEOUT);
4054        if (txnMaxActive != oldConfig.txnMaxActive)
4055            dbenv.set_tx_max(txnMaxActive);
4056        if (txnTimeout != oldConfig.txnTimeout)
4057            dbenv.set_timeout(txnTimeout, DbConstants.DB_SET_TXN_TIMEOUT);
4058        if (txnTimestamp != oldConfig.txnTimestamp && txnTimestamp != null &&
4059            !txnTimestamp.equals(oldConfig.txnTimestamp))
4060            dbenv.set_tx_timestamp(txnTimestamp);
4061        if (temporaryDirectory != oldConfig.temporaryDirectory &&
4062            temporaryDirectory != null &&
4063            !temporaryDirectory.equals(oldConfig.temporaryDirectory))
4064            dbenv.set_tmp_dir(temporaryDirectory.toString());
4065        if (repmgrAckPolicy != oldConfig.repmgrAckPolicy)
4066            dbenv.repmgr_set_ack_policy(repmgrAckPolicy.getId());
4067        if (repmgrLocalSiteAddr != oldConfig.repmgrLocalSiteAddr) {
4068            dbenv.repmgr_set_local_site(
4069                repmgrLocalSiteAddr.host, repmgrLocalSiteAddr.port, 0);
4070        }
4071	java.util.Iterator elems = repmgrRemoteSites.entrySet().iterator();
4072	while (elems.hasNext()){
4073	    java.util.Map.Entry ent = (java.util.Map.Entry)elems.next();
4074	    ReplicationHostAddress nextAddr =
4075		(ReplicationHostAddress)ent.getKey();
4076	    Boolean isPeer = (Boolean)ent.getValue();
4077            dbenv.repmgr_add_remote_site(nextAddr.host, nextAddr.port,
4078                isPeer ? DbConstants.DB_REPMGR_PEER : 0);
4079        }
4080    }
4081
4082    /* package */
4083    EnvironmentConfig(final DbEnv dbenv)
4084        throws DatabaseException {
4085
4086        final int openFlags = dbenv.get_open_flags();
4087
4088        allowCreate = ((openFlags & DbConstants.DB_CREATE) != 0);
4089        initializeCache = ((openFlags & DbConstants.DB_INIT_MPOOL) != 0);
4090        initializeCDB = ((openFlags & DbConstants.DB_INIT_CDB) != 0);
4091        initializeLocking = ((openFlags & DbConstants.DB_INIT_LOCK) != 0);
4092        initializeLogging = ((openFlags & DbConstants.DB_INIT_LOG) != 0);
4093        initializeReplication = ((openFlags & DbConstants.DB_INIT_REP) != 0);
4094        joinEnvironment = ((openFlags & DbConstants.DB_JOINENV) != 0);
4095        lockDown = ((openFlags & DbConstants.DB_LOCKDOWN) != 0);
4096        isPrivate = ((openFlags & DbConstants.DB_PRIVATE) != 0);
4097        register = ((openFlags & DbConstants.DB_REGISTER) != 0);
4098        runRecovery = ((openFlags & DbConstants.DB_RECOVER) != 0);
4099        runFatalRecovery = ((openFlags & DbConstants.DB_RECOVER_FATAL) != 0);
4100        systemMemory = ((openFlags & DbConstants.DB_SYSTEM_MEM) != 0);
4101        threaded = ((openFlags & DbConstants.DB_THREAD) != 0);
4102        transactional = ((openFlags & DbConstants.DB_INIT_TXN) != 0);
4103        useEnvironment = ((openFlags & DbConstants.DB_USE_ENVIRON) != 0);
4104        useEnvironmentRoot =
4105            ((openFlags & DbConstants.DB_USE_ENVIRON_ROOT) != 0);
4106
4107        final int envFlags = dbenv.get_flags();
4108
4109        cdbLockAllDatabases = ((envFlags & DbConstants.DB_CDB_ALLDB) != 0);
4110        directDatabaseIO = ((envFlags & DbConstants.DB_DIRECT_DB) != 0);
4111        dsyncDatabases = ((envFlags & DbConstants.DB_DSYNC_DB) != 0);
4112        initializeRegions = ((envFlags & DbConstants.DB_REGION_INIT) != 0);
4113        multiversion = ((envFlags & DbConstants.DB_MULTIVERSION) != 0);
4114        noLocking = ((envFlags & DbConstants.DB_NOLOCKING) != 0);
4115        noMMap = ((envFlags & DbConstants.DB_NOMMAP) != 0);
4116        noPanic = ((envFlags & DbConstants.DB_NOPANIC) != 0);
4117        overwrite = ((envFlags & DbConstants.DB_OVERWRITE) != 0);
4118        txnNoSync = ((envFlags & DbConstants.DB_TXN_NOSYNC) != 0);
4119        txnNoWait = ((envFlags & DbConstants.DB_TXN_NOWAIT) != 0);
4120        txnNotDurable = ((envFlags & DbConstants.DB_TXN_NOT_DURABLE) != 0);
4121        txnSnapshot = ((envFlags & DbConstants.DB_TXN_SNAPSHOT) != 0);
4122        txnWriteNoSync = ((envFlags & DbConstants.DB_TXN_WRITE_NOSYNC) != 0);
4123        yieldCPU = ((envFlags & DbConstants.DB_YIELDCPU) != 0);
4124
4125	/* Log flags */
4126        if (initializeLogging) {
4127            directLogIO = dbenv.log_get_config(DbConstants.DB_LOG_DIRECT);
4128            dsyncLog = dbenv.log_get_config(DbConstants.DB_LOG_DSYNC);
4129            logAutoRemove = dbenv.log_get_config(DbConstants.DB_LOG_AUTO_REMOVE);
4130            logInMemory = dbenv.log_get_config(DbConstants.DB_LOG_IN_MEMORY);
4131            logZero = dbenv.log_get_config(DbConstants.DB_LOG_ZERO);
4132        }
4133
4134        /* Verbose flags */
4135        verboseDeadlock = dbenv.get_verbose(DbConstants.DB_VERB_DEADLOCK);
4136        verboseFileops = dbenv.get_verbose(DbConstants.DB_VERB_FILEOPS);
4137        verboseFileopsAll = dbenv.get_verbose(DbConstants.DB_VERB_FILEOPS_ALL);
4138        verboseRecovery = dbenv.get_verbose(DbConstants.DB_VERB_RECOVERY);
4139        verboseRegister = dbenv.get_verbose(DbConstants.DB_VERB_REGISTER);
4140        verboseReplication = dbenv.get_verbose(DbConstants.DB_VERB_REPLICATION);
4141        verboseWaitsFor = dbenv.get_verbose(DbConstants.DB_VERB_WAITSFOR);
4142
4143        /* Callbacks */
4144        errorHandler = dbenv.get_errcall();
4145        feedbackHandler = dbenv.get_feedback();
4146        logRecordHandler = dbenv.get_app_dispatch();
4147        eventHandler = dbenv.get_event_notify();
4148        messageHandler = dbenv.get_msgcall();
4149        panicHandler = dbenv.get_paniccall();
4150        // XXX: replicationTransport and envid aren't available?
4151
4152        /* Other settings */
4153        if (initializeCache) {
4154            cacheSize = dbenv.get_cachesize();
4155            cacheMax = dbenv.get_cache_max();
4156            cacheCount = dbenv.get_cachesize_ncache();
4157            mmapSize = dbenv.get_mp_mmapsize();
4158            maxOpenFiles = dbenv.get_mp_max_openfd();
4159            maxWrite = dbenv.get_mp_max_write();
4160            maxWriteSleep = dbenv.get_mp_max_write_sleep();
4161        }
4162
4163        String[] dataDirArray = dbenv.get_data_dirs();
4164        if (dataDirArray == null)
4165            dataDirArray = new String[0];
4166        dataDirs = new java.util.Vector(dataDirArray.length);
4167        dataDirs.setSize(dataDirArray.length);
4168        for (int i = 0; i < dataDirArray.length; i++)
4169            dataDirs.set(i, new java.io.File(dataDirArray[i]));
4170
4171        errorPrefix = dbenv.get_errpfx();
4172        errorStream = dbenv.get_error_stream();
4173
4174        if (initializeLocking) {
4175            lockConflicts = dbenv.get_lk_conflicts();
4176            lockDetectMode = LockDetectMode.fromFlag(dbenv.get_lk_detect());
4177            lockTimeout = dbenv.get_timeout(DbConstants.DB_SET_LOCK_TIMEOUT);
4178            maxLocks = dbenv.get_lk_max_locks();
4179            maxLockers = dbenv.get_lk_max_lockers();
4180            maxLockObjects = dbenv.get_lk_max_objects();
4181            txnTimeout = dbenv.get_timeout(DbConstants.DB_SET_TXN_TIMEOUT);
4182        } else {
4183            lockConflicts = null;
4184            lockDetectMode = LockDetectMode.NONE;
4185            lockTimeout = 0L;
4186            maxLocks = 0;
4187            maxLockers = 0;
4188            maxLockObjects = 0;
4189            txnTimeout = 0L;
4190        }
4191        if (initializeLogging) {
4192            maxLogFileSize = dbenv.get_lg_max();
4193            logBufferSize = dbenv.get_lg_bsize();
4194            logDirectory = (dbenv.get_lg_dir() == null) ? null :
4195                new java.io.File(dbenv.get_lg_dir());
4196            logFileMode = dbenv.get_lg_filemode();
4197            logRegionSize = dbenv.get_lg_regionmax();
4198        } else {
4199            maxLogFileSize = 0;
4200            logBufferSize = 0;
4201            logDirectory = null;
4202            logRegionSize = 0;
4203        }
4204        messageStream = dbenv.get_message_stream();
4205
4206        // XXX: intentional information loss?
4207        password = (dbenv.get_encrypt_flags() == 0) ? null : "";
4208
4209        if (initializeReplication) {
4210            replicationLimit = dbenv.rep_get_limit();
4211	    replicationRequestMin = dbenv.rep_get_request_min();
4212	    replicationRequestMax = dbenv.rep_get_request_max();
4213	    repmgrRemoteSites = new java.util.HashMap();
4214	    java.util.Iterator sites =
4215		java.util.Arrays.asList(dbenv.repmgr_site_list()).listIterator();
4216	    while (sites.hasNext()){
4217		ReplicationManagerSiteInfo site =
4218		    (ReplicationManagerSiteInfo)sites.next();
4219		repmgrRemoteSites.put(site.addr, Boolean.FALSE);
4220	    }
4221        } else {
4222            replicationLimit = 0L;
4223            replicationRequestMin = 0;
4224            replicationRequestMax = 0;
4225        }
4226
4227        // XXX: no way to find RPC server?
4228        rpcServer = null;
4229        rpcClientTimeout = 0;
4230        rpcServerTimeout = 0;
4231
4232        segmentId = dbenv.get_shm_key();
4233        mutexAlignment = dbenv.mutex_get_align();
4234        mutexIncrement = dbenv.mutex_get_increment();
4235        maxMutexes = dbenv.mutex_get_max();
4236        mutexTestAndSetSpins = dbenv.mutex_get_tas_spins();
4237        replicationNumSites = dbenv.rep_get_nsites();
4238        replicationPriority = dbenv.rep_get_priority();
4239        replicationClockskewFast = dbenv.rep_get_clockskew_fast();
4240        replicationClockskewSlow = dbenv.rep_get_clockskew_slow();
4241        if (transactional) {
4242            txnMaxActive = dbenv.get_tx_max();
4243            final long txnTimestampSeconds = dbenv.get_tx_timestamp();
4244            if (txnTimestampSeconds != 0L)
4245                txnTimestamp = new java.util.Date(txnTimestampSeconds * 1000);
4246            else
4247                txnTimestamp = null;
4248        } else {
4249            txnMaxActive = 0;
4250            txnTimestamp = null;
4251        }
4252        temporaryDirectory = new java.io.File(dbenv.get_tmp_dir());
4253    }
4254}
4255