ConfigurableEnvironment.java revision 998747bfaaa3c6b28bbfaf0e282e6c0ccbf46bc0
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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-2010 Sun Microsystems, Inc.
* Portions Copyright 2010-2015 ForgeRock AS.
*/
/**
* This class maps JE properties to configuration attributes.
*/
public class ConfigurableEnvironment
{
/**
* 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 the minimum number of threads
* of the database cache evictor pool.
*/
public static final String ATTR_EVICTOR_CORE_THREADS =
/**
* The name of the attribute which configures the maximum number of threads
* of the database cache evictor pool.
*/
public static final String ATTR_EVICTOR_MAX_THREADS =
/**
* The name of the attribute which configures the time excess threads
* of the database cache evictor pool are kept alive.
*/
public static final String ATTR_EVICTOR_KEEP_ALIVE =
/**
* 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 configures the size of the file
* handle cache.
*/
public static final String ATTR_LOG_FILECACHE_SIZE =
/**
* 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
{
{
// Automatically choose based on the number of processors. We will use
// similar heuristics to those used to define the default number of
// worker threads.
}
{
// Automatically choose based on the number of processors.
// We'll assume that the user has also allowed automatic
// configuration of cleaners and workers.
logger.debug(INFO_ERGONOMIC_SIZING_OF_JE_LOCK_TABLES, cfg.dn().rdn().getAttributeValue(0), (Number) value);
}
}
}
catch (Exception e)
{
logger.traceException(e);
return "";
}
}
static
{
// Register the parameters that have JE property names.
try
{
registerProp("je.checkpointer.bytesInterval",
registerProp("je.checkpointer.wakeupInterval",
}
catch (Exception e)
{
logger.traceException(e);
}
}
/**
* 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);
// "je.env.sharedLatches" is "true" by default since JE #12136 (3.3.62?)
// 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.
// Under heavy write load the check point can fall behind causing
// uncontrolled DB growth over time. This parameter makes the out of
// the box configuration more robust at the cost of a slight
// reduction in maximum write throughput. Experiments have shown
// that response time predictability is not impacted negatively.
// If the JVM is reasonably large then we can safely default to
// bigger read buffers. This will result in more scalable checkpointer
// and cleaner performance.
{
}
// Disable lock timeouts, meaning that no lock wait
// timelimit is enforced and a deadlocked operation
// will block indefinitely.
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
{
// See if the db cache size setting is valid.
{
throw new ConfigException(
}
throw new ConfigException(
}
}
// Durability settings.
{
throw new ConfigException(
}
if (cfg.isDBTxnNoSync())
{
}
if (cfg.isDBTxnWriteNoSync())
{
}
// Iterate through the config attributes associated with a JE property.
{
}
// Set logging and file handler levels.
try
{
}
catch (Exception e)
{
}
// See if there are any native JE properties specified in the config
// and if so try to parse, evaluate and set them.
}
/**
* 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 {
// If this property shadows an existing config attribute.
throw new ConfigException(message);
}
// Add this property to unique set.
} catch(IllegalArgumentException e) {
logger.traceException(e);
jeEntry, e.getMessage());
}
} else {
throw new ConfigException(message);
}
}
return envConfig;
}
}