SEnvironmentConfig (Oracle - Berkeley DB Client-Server API)
Date: 2018-05-29

com.sleepycat.client

## Class SEnvironmentConfig

- java.lang.Object
- - com.sleepycat.client.SEnvironmentConfig

-     public class SEnvironmentConfig
      extends java.lang.Object

  Specifies the attributes of an environment.

  For a user created instance, no attribute is set by default. In addition, calling the getter method of an unset attribute results in an IllegalStateException. To set an attribute, call the setter method of the attribute.

  When used to construct an environment, system default values are used for unset attributes. When used to modify the configuration of an existing environment, only set attributes are modified; unset attributes are not modified.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SEnvironmentConfig()` Create an empty SEnvironmentConfig with no attribute set.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `getAllowCreate()` Return true if the environment is configured to create any underlying files, as necessary.
    `int` | `getCacheCount()` Return the number of shared memory buffer pools, that is, the number of cache regions.
    `long` | `getCacheSize()` Return the size of the shared memory buffer pool, that is, the cache.
    `protected java.lang.Object` | `getField(F field)` Return the value set on a specified field.
    `boolean` | `getInitializeCache()` Always return true.
    `boolean` | `getInitializeCDB()` Always return false.
    `boolean` | `getInitializeLocking()` Always return true.
    `SLockDetectMode` | `getLockDetectMode()` Return the policy used by the deadlock detector.
    `boolean` | `getMultiversion()` Return true if the handle is configured to open all databases for multiversion concurrency control.
    `boolean` | `getRunRecovery()` Return true if the handle is configured to run normal recovery on the environment before opening it for use.
    `protected T` | `getThriftObj()`
    `boolean` | `getTransactional()` Always return true.
    `boolean` | `getTxnNoSync()` Return true if the system has been configured to not write or synchronously flush the log on transaction commit.
    `boolean` | `getTxnNoWait()` Return true if the transactions have been configured to not wait for locks by default.
    `boolean` | `getTxnSnapshot()` Return true if the handle is configured to run all transactions at snapshot isolation.
    `boolean` | `getTxnWriteNoSync()` Return true if the system has been configured to write, but not synchronously flush, the log on transaction commit.
    `SEnvironmentConfig` | `setAllowCreate(boolean allowCreate)` Configure the environment to create any underlying files, as necessary.
    `SEnvironmentConfig` | `setCacheCount(int cacheCount)` Set the number of shared memory buffer pools.
    `SEnvironmentConfig` | `setCacheSize(long cacheSize)` Set the size of the cache.
    `SEnvironmentConfig` | `setEncrypted(java.lang.String password)` Set the password used to perform encryption and decryption.
    `SEnvironmentConfig` | `setLockDetectMode(SLockDetectMode lockDetectMode)` Set policy used by the deadlock detector.
    `SEnvironmentConfig` | `setMultiversion(boolean multiversion)` Configure the database environment to open all databases that are not using the queue access method for multiversion concurrency control.
    `SEnvironmentConfig` | `setRunRecovery(boolean runRecovery)` Configure to run normal recovery on this environment before opening it for normal use.
    `SEnvironmentConfig` | `setTxnNoSync(boolean txnNoSync)` Configure the system to not write or synchronously flush the log on transaction commit.
    `SEnvironmentConfig` | `setTxnNoWait(boolean txnNoWait)` If a lock is unavailable for any Berkeley DB operation performed in the context of a transaction, cause the operation to throw `SLockNotGrantedException` without waiting for the lock.
    `SEnvironmentConfig` | `setTxnSnapshot(boolean txnSnapshot)` Configure the database environment to run transactions at snapshot isolation by default.
    `SEnvironmentConfig` | `setTxnWriteNoSync(boolean txnWriteNoSync)` Configure the system to write, but not synchronously flush, the log on transaction commit.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SEnvironmentConfig

          public SEnvironmentConfig()

      Create an empty SEnvironmentConfig with no attribute set.

  - ### Method Detail

    - #### getAllowCreate

          public boolean getAllowCreate()

      Return true if the environment is configured to create any underlying files, as necessary.
      Returns:
        true if the environment is configured to create any underlying files, as necessary

    - #### setAllowCreate

          public SEnvironmentConfig setAllowCreate(boolean allowCreate)

      Configure the environment to create any underlying files, as necessary.
      Parameters:
        `allowCreate` - if true, configure the environment to create any underlying files, as necessary
      Returns:
        this

    - #### getCacheCount

          public int getCacheCount()

      Return the number of shared memory buffer pools, that is, the number of cache regions.
      Returns:
        the number of shared memory buffer pools

    - #### setCacheCount

          public SEnvironmentConfig setCacheCount(int cacheCount)

      Set the number of shared memory buffer pools.

      It is possible to specify caches large enough so that they cannot be allocated contiguously on some architectures. This method allows applications to break the cache into a number of equally sized, separate pieces of memory.

      This method configures an environment, including all handles on the environment, not only the operations performed using a specified handle.

      This attribute cannot be changed after the environment is constructed. If joining an existing environment, this attribute is ignored.

      Parameters:
        `cacheCount` - the number of shared buffer pools
      Returns:
        this

    - #### getCacheSize

          public long getCacheSize()

      Return the size of the shared memory buffer pool, that is, the cache.
      Returns:
        the size of the cache

    - #### setCacheSize

          public SEnvironmentConfig setCacheSize(long cacheSize)

      Set the size of the cache.

      The cache should be the size of the normal working data set of the application, with some small amount of additional memory for unusual situations. (Note: the working set is not the same as the number of pages accessed simultaneously, and is usually much larger.)

      The default cache size is 256KB, and may not be specified as less than 20KB. Any cache size less than 500MB is automatically increased by 25% to account for buffer pool overhead; cache sizes larger than 500MB are used as specified. The current maximum size of a single cache is 4GB. (All sizes are in powers-of-two, that is, 256KB is 2^18 not 256,000.)

      This method configures an environment, including all handles on the environment, not only the operations performed using a specified handle.

      This attribute cannot be changed after the environment is constructed. If joining an existing environment, this attribute is ignored.

      Parameters:
        `cacheSize` - the size of the cache
      Returns:
        this

    - #### setEncrypted

          public SEnvironmentConfig setEncrypted(java.lang.String password)

      Set the password used to perform encryption and decryption.
      Parameters:
        `password` - the password
      Returns:
        this

    - #### getInitializeCache

          public boolean getInitializeCache()

      Always return true. For compatibility with DPL APIs.
      Returns:
        always true

    - #### getInitializeLocking

          public boolean getInitializeLocking()

      Always return true. For compatibility with DPL APIs.
      Returns:
        always true

    - #### getInitializeCDB

          public boolean getInitializeCDB()

      Always return false. For compatibility with DPL APIs.
      Returns:
        always false

    - #### getLockDetectMode

          public SLockDetectMode getLockDetectMode()

      Return the policy used by the deadlock detector.
      Returns:
        the deadlock detector policy

    - #### setLockDetectMode

          public SEnvironmentConfig setLockDetectMode(SLockDetectMode lockDetectMode)

      Set policy used by the deadlock detector.

      This method configures an environment, including all handles on the environment, not only the operations performed using a specified handle.

      This attribute cannot be changed after the environment is constructed. If joining an existing environment, this attribute is ignored.

      Parameters:
        `lockDetectMode` - the lock request to be rejected
      Returns:
        this

    - #### getMultiversion

          public boolean getMultiversion()

      Return true if the handle is configured to open all databases for multiversion concurrency control.
      Returns:
        true if the handle is configured to open all databases for multiversion concurrency control.

    - #### setMultiversion

          public SEnvironmentConfig setMultiversion(boolean multiversion)

      Configure the database environment to open all databases that are not using the queue access method for multiversion concurrency control.

      This method only affects the specified `SEnvironment` handle (and any other library handles opened within the scope of that handle). For consistent behavior across the environment, all SEnvironment handles opened in the database environment must call this method.

      Parameters:
        `multiversion` - if true, all databases that are not using the queue access method will be opened for multiversion concurrency control.
      Returns:
        this

    - #### getRunRecovery

          public boolean getRunRecovery()

      Return true if the handle is configured to run normal recovery on the environment before opening it for use.
      Returns:
        true if the handle is configured to run normal recovery before opening the environment

    - #### setRunRecovery

          public SEnvironmentConfig setRunRecovery(boolean runRecovery)

      Configure to run normal recovery on this environment before opening it for normal use.

      A standard part of the recovery process is to remove the existing database environment and create a new one. If the thread of control performing recovery does not specify the correct database environment initialization information (for example, the correct memory pool cache size), the result can be an application running in an environment with incorrect cache and other subsystem sizes. For this reason, the thread of control performing recovery should specify correct configuration information before recovering the environment.

      All recovery processing must be single-threaded; that is, only a single thread of control may perform recovery or access a database environment while recovery is being performed.

      Parameters:
        `runRecovery` - if true, configure to run normal recovery on this environment before opening it for normal use.
      Returns:
        this

    - #### getTransactional

          public boolean getTransactional()

      Always return true. For compatibility with DPL APIs.
      Returns:
        always true

    - #### getTxnNoWait

          public boolean getTxnNoWait()

      Return true if the transactions have been configured to not wait for locks by default.
      Returns:
        true if the transactions have been configured to not wait for locks by default.

    - #### setTxnNoWait

          public SEnvironmentConfig setTxnNoWait(boolean txnNoWait)

      If a lock is unavailable for any Berkeley DB operation performed in the context of a transaction, cause the operation to throw `SLockNotGrantedException` without waiting for the lock.

      This method only affects the specified `SEnvironment` handle (and any other library handles opened within the scope of that handle). For consistent behavior across the environment, all SEnvironment handles opened in the database environment must call this method.

      Parameters:
        `txnNoWait` - if true, configure transactions to not wait for locks by default.
      Returns:
        this

    - #### getTxnSnapshot

          public boolean getTxnSnapshot()

      Return true if the handle is configured to run all transactions at snapshot isolation.
      Returns:
        true if the handle is configured to run all transactions at snapshot isolation.

    - #### setTxnSnapshot

          public SEnvironmentConfig setTxnSnapshot(boolean txnSnapshot)

      Configure the database environment to run transactions at snapshot isolation by default.

      This method only affects the specified `SEnvironment` handle (and any other library handles opened within the scope of that handle). For consistent behavior across the environment, all SEnvironment handles opened in the database environment must call this method.

      Parameters:
        `txnSnapshot` - if true, configure the system to default to snapshot isolation.
      Returns:
        this

    - #### getTxnNoSync

          public boolean getTxnNoSync()

      Return true if the system has been configured to not write or synchronously flush the log on transaction commit.
      Returns:
        true if the system has been configured to not write or synchronously flush the log on transaction commit.

    - #### setTxnNoSync

          public SEnvironmentConfig setTxnNoSync(boolean txnNoSync)

      Configure the system to not write or synchronously flush the log on transaction commit.

      This means that transactions exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but if the server fails, it is possible some number of the most recently committed transactions may be undone during recovery. The number of transactions at risk is governed by how many log updates can fit into the log buffer, how often the server operating system flushes dirty buffers to disk, and how often the log is checkpointed.

      This method only affects the specified `SEnvironment` handle (and any other library handles opened within the scope of that handle). For consistent behavior across the environment, all SEnvironment handles opened in the database environment must call this method.

      Parameters:
        `txnNoSync` - if true, configure the system to not write or synchronously flush the log on transaction commit.
      Returns:
        this

    - #### getTxnWriteNoSync

          public boolean getTxnWriteNoSync()

      Return true if the system has been configured to write, but not synchronously flush, the log on transaction commit.
      Returns:
        true if the system has been configured to write, but not synchronously flush, the log on transaction commit.

    - #### setTxnWriteNoSync

          public SEnvironmentConfig setTxnWriteNoSync(boolean txnWriteNoSync)

      Configure the system to write, but not synchronously flush, the log on transaction commit.

      This means that transactions exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but if the server fails, it is possible some number of the most recently committed transactions may be undone during recovery. The number of transactions at risk is governed by how often the server system flushes dirty buffers to disk and how often the log is checkpointed.

      This method only affects the specified `SEnvironment` handle (and any other library handles opened within the scope of that handle). For consistent behavior across the environment, all SEnvironment handles opened in the database environment must call this method.

      Parameters:
        `txnWriteNoSync` - if true, configure the system to write, but not synchronously flush, the log on transaction commit.
      Returns:
        this

    - #### getThriftObj

          protected T getThriftObj()

    - #### getField

          protected java.lang.Object getField(F field)
                                       throws java.lang.IllegalStateException

      Return the value set on a specified field. Throw IllegalStateException if the field is not set.
      Parameters:
        `field` - the field
      Returns:
        the field's value
      Throws:
        `java.lang.IllegalStateException` - if the field is not set

Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.