ConfigurableEnvironment.java revision a395dd575518d9e5280fc5d5d5ef47c61b174647
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
*/
/**
* This class maps JE properties to configuration attributes.
*/
public class ConfigurableEnvironment
{
/**
* The tracer object for the debug logger.
*/
/**
* The name of the attribute which configures the database cache size as a
* percentage of Java VM heap size.
*/
public static final String ATTR_DATABASE_CACHE_PERCENT =
/**
* The name of the attribute which configures the database cache size as an
* approximate number of bytes.
*/
public static final String ATTR_DATABASE_CACHE_SIZE =
/**
* The name of the attribute which configures whether data updated by a
* database transaction is forced to disk.
*/
public static final String ATTR_DATABASE_TXN_NO_SYNC =
/**
* The name of the attribute which configures whether data updated by a
* database transaction is written from the Java VM to the O/S.
*/
public static final String ATTR_DATABASE_TXN_WRITE_NO_SYNC =
/**
* The name of the attribute which configures whether the database background
* cleaner thread runs.
*/
public static final String ATTR_DATABASE_RUN_CLEANER =
/**
* The name of the attribute which configures the minimum percentage of log
* space that must be used in log files.
*/
public static final String ATTR_CLEANER_MIN_UTILIZATION =
/**
* The name of the attribute which configures the maximum size of each
* individual JE log file, in bytes.
*/
public static final String ATTR_DATABASE_LOG_FILE_MAX =
/**
* The name of the attribute which configures the database cache eviction
* algorithm.
*/
public static final String ATTR_EVICTOR_LRU_ONLY =
/**
* The name of the attribute which configures the number of nodes in one scan
* of the database cache evictor.
*/
public static final String ATTR_EVICTOR_NODES_PER_SCAN =
/**
* The name of the attribute which configures whether the logging file
* handler will be on or off.
*/
public static final String ATTR_LOGGING_FILE_HANDLER_ON =
/**
* The name of the attribute which configures the trace logging message level.
*/
public static final String ATTR_LOGGING_LEVEL =
/**
* The name of the attribute which configures how many bytes are written to
* the log before the checkpointer runs.
*/
public static final String ATTR_CHECKPOINTER_BYTES_INTERVAL =
/**
* The name of the attribute which configures the amount of time between
* runs of the checkpointer.
*/
public static final String ATTR_CHECKPOINTER_WAKEUP_INTERVAL =
"db-checkpointer-wakeup-interval";
/**
* The name of the attribute which configures the number of lock tables.
*/
public static final String ATTR_NUM_LOCK_TABLES =
/**
* The name of the attribute which configures the number threads
* allocated by the cleaner for log file processing.
*/
public static final String ATTR_NUM_CLEANER_THREADS =
/**
* The name of the attribute which may specify any native JE properties.
*/
public static final String ATTR_JE_PROPERTY =
/**
* A map of JE property names to the corresponding configuration attribute.
*/
/**
* A map of configuration attribute names to the corresponding configuration
* object getter method.
*/
/**
* A map of configuration attribute names to the corresponding configuration
* PropertyDefinition.
*/
// Pulled from resource/admin/ABBREVIATIONS.xsl. db is mose common.
{"aci", "ip", "ssl", "dn", "rdn", "jmx", "smtp", "http",
"https", "ldap", "ldaps", "ldif", "jdbc", "tcp", "tls",
"pkcs11", "sasl", "gssapi", "md5", "je", "dse", "fifo",
"vlv", "uuid", "md5", "sha1", "sha256", "sha384", "sha512",
"tls", "db"});
/*
* e.g. db-cache-percent -> DBCachePercent
*/
{
} else {
}
}
}
/**
* Register a JE property and its corresponding configuration attribute.
*
* @param propertyName The name of the JE property to be registered.
* @param attrName The name of the configuration attribute associated
* with the property.
* @throws Exception If there is an error in the attribute name.
*/
throws Exception
{
// Strip off NAME_PREFIX_CFG.
if (propDefn instanceof BooleanPropertyDefinition)
{
}
else
{
}
}
/**
* Get the name of the configuration attribute associated with a JE property.
* @param jeProperty The name of the JE property.
* @return The name of the associated configuration attribute.
*/
{
}
/**
* Get the value of a JE property that is mapped to a configuration attribute.
* @param cfg The configuration containing the property values.
* @param attrName The conriguration attribute type name.
* @return The string value of the JE property.
*/
{
try
{
if (propDefn instanceof DurationPropertyDefinition)
{
// JE durations are in microseconds so we must convert.
}
else
{
}
}
catch (Exception e)
{
if (debugEnabled())
{
}
return "";
}
}
static
{
// Register the parameters that have JE property names.
try
{
registerProp("java.util.logging.FileHandler.on",
registerProp("je.checkpointer.bytesInterval",
registerProp("je.checkpointer.wakeupInterval",
}
catch (Exception e)
{
if (debugEnabled())
{
}
}
}
/**
* Create a JE environment configuration with default values.
*
* @return A JE environment config containing default values.
*/
public static EnvironmentConfig defaultConfig()
{
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
// This property was introduced in JE 3.0. Shared latches are now used on
// all internal nodes of the b-tree, which increases concurrency for many
// operations.
// This parameter was set to false while diagnosing a Berkeley DB JE bug.
// Normally cleansed log files are deleted, but if this is set false
// they are instead renamed from .jdb to .del.
return envConfig;
}
/**
* Parse a configuration associated with a JE environment and create an
* environment config from it.
*
* @param cfg The configuration to be parsed.
* @return An environment config instance corresponding to the config entry.
* @throws ConfigException If there is an error in the provided configuration
* entry.
*/
throws ConfigException
{
// Handle the attributes that do not have a JE property.
// Iterate through the config attributes associated with a JE property.
{
}
// See if there are any native JE properties specified in the config
// and if so try to parse, evaluate and set them.
try {
} catch (ConfigException e) {
throw e;
}
return envConfig;
}
/**
* Parse, validate and set native JE environment properties for
* a given environment config.
*
* @param envConfig The JE environment config for which to set
* the properties.
* @param jeProperties The JE environment properties to parse,
* validate and set.
* @param configAttrMap Component supported JE properties to
* their configuration attributes map.
* @return An environment config instance with given properties
* set.
* @throws ConfigException If there is an error while parsing,
* validating and setting any of the properties provided.
*/
throws ConfigException
{
if (jeProperties.isEmpty()) {
// return default config.
return envConfig;
}
// Set to catch duplicate properties.
// Iterate through the config values associated with a JE property.
{
// Check if it is a duplicate.
throw new ConfigException(message);
}
// Set JE property.
try {
// This is a special case that JE cannot validate before
// actually setting it. Validate it before it gets to JE.
}
// If this property shadows an existing config attribute.
throw new ConfigException(message);
}
// Add this property to unique set.
} catch(IllegalArgumentException e) {
if (debugEnabled()) {
}
jeEntry, e.getMessage());
}
} else {
throw new ConfigException(message);
}
}
return envConfig;
}
}