|
Berkeley DB Java Edition version 1.7.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.EnvironmentMutableConfig
com.sleepycat.je.EnvironmentConfig
Specifies the attributes of an environment.
To change the default settings for a database environment, an application creates a configuration object, customizes settings and uses it for environment construction. The set methods of this class validate the configuration values when the method is invoked. An IllegalArgumentException is thrown if the value is not valid for that attribute.
All commonly used environment attributes have convenience setter/getter methods defined in this class. For example, to change the default transaction timeout setting for an environment, the application should do the following:
// customize an environment configuration EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTxnTimeout(10000); // will throw if timeout value is invalid // Open the environment. Environment myEnvironment = new Environment(home, envConfig);
Additional parameters are described in the example.properties file found at the top level of the distribution package. These additional parameters will not be needed by most applications. This category of properties can be specified for the EnvironmentConfig object through a Properties object read by EnvironmentConfig(Properties), or individually through EnvironmentConfig.setConfigParam().
For example, an application can change the default btree node size with:
envConfig.setConfigParam("je.nodeMaxEntries", "256");
Environment configuration follows this order of precedence:
An EnvironmentConfig can be used to specify both mutable and immutable environment properties. Immutable properties may be specified when the first Environment handle (instance) is opened for a given physical environment. When more handles are opened for the same environment, the following rules apply:
After an Environment has been constructed, it's mutable properties may
be changed using
Environment.setMutableConfig(com.sleepycat.je.EnvironmentMutableConfig)
. See EnvironmentMutableConfig
for a list of mutable properties; all other properties are immutable.
Whether a property is mutable or immutable is also listed in the
example.properties file found at the top level of the distribution
package.
Constructor Summary | |
EnvironmentConfig()
Create an EnvironmentConfig initialized with the system default settings. |
|
EnvironmentConfig(Properties properties)
Create an EnvironmentConfig which includes the properties specified in the properties parameter. |
Method Summary | |
boolean |
getAllowCreate()
Return if we may create this environment. |
String |
getConfigParam(String configParamName)
Return the value for this configuration parameter. |
long |
getLockTimeout()
Return the lock timeout setting, in microseconds. |
boolean |
getReadOnly()
Return if the database environment is configured to be read only. |
boolean |
getTransactional()
Return if the database environment is configured for transactions. |
boolean |
getTxnSerializableIsolation()
Return if all transactions for this environment has been configured to have Serializable (Degree 3) isolation. |
long |
getTxnTimeout()
Return the transaction timeout, in microseconds. |
void |
setAllowCreate(boolean allowCreate)
If true, the database environment is created if it doesn't already exist. |
void |
setConfigParam(String configParamName,
String value)
Validate the value prescribed for the configuration parameter; if it is valid, the value is set in the configuration. |
void |
setLockTimeout(long lockTimeout)
Configure the lock timeout, in microseconds. |
void |
setReadOnly(boolean readOnly)
Configure the database environment to be read only, and any attempt to modify a database will fail. |
void |
setTransactional(boolean transactional)
Configure the database environment for transactions. |
void |
setTxnSerializableIsolation(boolean serializableIsolation)
Configure all transactions for this environment to have Serializable (Degree 3) isolation. |
void |
setTxnTimeout(long txnTimeout)
Configure the transaction timeout, in microseconds. |
Methods inherited from class com.sleepycat.je.EnvironmentMutableConfig |
getCachePercent, getCacheSize, getTxnNoSync, getTxnWriteNoSync, setCachePercent, setCacheSize, setTxnNoSync, setTxnWriteNoSync |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EnvironmentConfig()
public EnvironmentConfig(Properties properties) throws IllegalArgumentException
properties
- Supported properties are described in the sample property file.
IllegalArgumentException
- If any properties read from the properties param are invalid.Method Detail |
public void setAllowCreate(boolean allowCreate)
allowCreate
- If true, the database environment is created if it doesn't already
exist.public boolean getAllowCreate()
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public void setLockTimeout(long lockTimeout) throws IllegalArgumentException
A value of 0 turns off lock timeouts.
Equivalent to setting the je.lock.timeout parameter in the je.properties file.
lockTimeout
- The lock timeout, in microseconds.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public long getLockTimeout()
A value of 0 means no timeout is set.
public void setReadOnly(boolean readOnly)
readOnly
- If true, configure the database environment to be read only, and any
attempt to modify a database will fail.public boolean getReadOnly()
This method may be called at any time during the life of the application.
public void setTxnTimeout(long txnTimeout) throws IllegalArgumentException
A value of 0 turns off transaction timeouts.
Equivalent to setting the je.lock.timeout parameter in the je.properties file.
txnTimeout
- The transaction timeout, in microseconds.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public long getTxnTimeout()
A value of 0 means transaction timeouts are not configured.
public void setTxnSerializableIsolation(boolean serializableIsolation)
The default is false for the database environment.
public boolean getTxnSerializableIsolation()
public void setConfigParam(String configParamName, String value) throws IllegalArgumentException
EnvironmentMutableConfig
setConfigParam
in class EnvironmentMutableConfig
configParamName
- The name of the configuration parameter. See the sample je.properties
file for descriptions of all parameters.
value
- The value for this configuration parameter.
IllegalArgumentException
- if an invalid parameter was specified.
public String getConfigParam(String configParamName)
EnvironmentMutableConfig
getConfigParam
in class EnvironmentMutableConfig
configParamName
- Name of the requested parameter.public void setTransactional(boolean transactional)
This configuration option should be used when transactional guarantees such as atomicity of multiple operations and durability are important.
transactional
- If true, configure the database environment for transactions.public boolean getTransactional()
This method may be called at any time during the life of the application.
|
Berkeley DB Java Edition version 1.7.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |