|
Berkeley DB Java Edition version 1.5.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.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 which isinitialized 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 true if we may create this environment. |
int |
getCachePercent()
Return the percentage value used in the JE cache size calculation. |
long |
getCacheSize()
Return the memory available to the database system, in bytes. |
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 supports transactions. |
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 |
setCachePercent(int percent)
By default, JE sets its cache size proportionally to the JVM memory. |
void |
setCacheSize(long cacheSize)
Configure the memory available to the database system, in bytes. |
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 to support transactions. |
void |
setTxnTimeout(long txnTimeout)
Configure the transaction timeout, in microseconds. |
Methods inherited from class com.sleepycat.je.EnvironmentMutableConfig |
getTxnNoSync, setTxnNoSync |
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
- Note that supported properties are described
in the sample property file.
IllegalArgumenentException
- if any properties read from the
the properties param are invalid.
IllegalArgumentException
Method Detail |
public void setAllowCreate(boolean allowCreate) throws IllegalArgumentException
allowCreate
- If true, the database environment is created if it doesn't already exist.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public boolean getAllowCreate() throws IllegalArgumentException
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public void setCacheSize(long cacheSize) throws IllegalArgumentException
By default, JE sets the cache size to
je.maxMemoryPercent * JVM maximum memorywhere JVM maximum memory is specified by the JVM -Xmx flag. However, calling setCacheSize() with a non-zero value overrides the percentage based calculation and sets the cache size explicitly.
cacheSize
- The memory available to the database system, in bytes.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public long getCacheSize() throws IllegalArgumentException
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public void setCachePercent(int percent) throws IllegalArgumentException
je.maxMemoryPercent * JVM maximum memorywhere JVM maximum memory is specified by the JVM -Xmx flag. setCachePercent() specifies the percentage used and is equivalent to setting the je.maxMemory property in the je.properties file.
Calling setCacheSize() with a non-zero value overrides the percentage based calculation and sets the cache size explicitly.
percent
- The percent of JVM memory to allocate to the JE cache.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public int getCachePercent() throws IllegalArgumentException
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() throws IllegalArgumentException
A value of 0 means no timeout is set.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public void setReadOnly(boolean readOnly) throws IllegalArgumentException
readOnly
- If true, configure the database environment to be read only, and any
attempt to modify a database will fail.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public boolean getReadOnly() throws IllegalArgumentException
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public void setTransactional(boolean transactional) throws IllegalArgumentException
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 to support transactions.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.public boolean getTransactional() throws IllegalArgumentException
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.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() throws IllegalArgumentException
A value of 0 means transaction timeouts are not configured.
IllegalArgumentException
- if an invalid parameter was specified.
DatabaseException
- if a failure occurs.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) throws IllegalArgumentException
EnvironmentMutableConfig
getConfigParam
in class EnvironmentMutableConfig
configParamName
- Name of the requested parameter.
IllegalArgumentException
- if the configParamName is invalid.
|
Berkeley DB Java Edition version 1.5.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |