DirectoryEnvironmentConfig.java revision d319724fed3be916a9f68676aac6eb203d44b551
/*
* 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 2008 Sun Microsystems, Inc.
*/
/**
* This class provides a set of properties that may control various
* aspects of the server environment. Note that these properties may
* only be altered before the Directory Server is started. Any
* attempt to change an environment configuration property while the
* server is running will be rejected.
*/
mayInstantiate=true,
mayExtend=false,
mayInvoke=true)
public final class DirectoryEnvironmentConfig
{
// The set of properties for the environment config.
/**
* Creates a new directory environment configuration initialized
* from the system properties defined in the JVM.
*/
public DirectoryEnvironmentConfig()
{
this(System.getProperties());
}
/**
* Creates a new directory environment configuration initialized
* with a copy of the provided set of properties.
*
* @param properties The properties to use when initializing this
* environment configuration, or {@code null}
* to use an empty set of properties.
*/
{
if (properties != null)
{
while (propertyNames.hasMoreElements())
{
}
}
}
/**
* Creates a new directory environment configuration initialized
* with a copy of the provided set of properties.
*
* @param properties The properties to use when initializing this
* environment configuration, or {@code null}
* to use an empty set of properties.
*/
{
if (properties == null)
{
}
else
{
}
}
/**
* Retrieves the property with the specified name. The check will
* first be made in the local config properties, but if no value is
* found then the JVM system properties will be checked.
*
* @param name The name of the property to retrieve.
*
* @return The property with the specified name, or {@code null} if
* no such property is defined.
*/
{
{
}
return value;
}
/**
* Specifies a property with the given name and value. If a
* property is already defined with the given name, then its value
* will be replaced with the provided value, or the property will be
* removed if the given value is {@code null}.
*
* @param name The name of the property to set.
* @param value The value of the property to set, or {@code null}
* if the property is to be removed.
*
* @return The previous value held for the property, or
* {@code null} if it was not previously set.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
{
}
else
{
}
}
/**
* Retrieves the directory that should be considered the server
* root. The determination will first be based on the properties
* defined in this config object. If no value is found there, then
* the JVM system properties will be checked, followed by an
* environment variable.
*
* @return The directory that should be considered the server root,
* or {@code null} if it is not defined.
*/
public File getServerRoot()
{
if (serverRootPath == null)
{
}
if (serverRootPath == null)
{
return null;
}
else
{
return new File(serverRootPath);
}
}
/**
* Retrieves the directory that should be considered the instance
* root. The determination will first be based on the properties
* defined in this config object. If no value is found there, then
* the JVM system properties will be checked, followed by an
* environment variable.
*
* @param serverRoot the server Root
*
* @return The directory that should be considered the instance
* root, or {@code null} if it is not defined.
*/
{
}
/**
* Specifies the directory that should be considered the server
* root. Any relative path used in the server should be considered
* relative to the server root.
*
* @param serverRoot The directory that should be considered the
* server root.
*
* @return The previous server root, or {@code null} if there was
* none.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* server root.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
{
throw new InitializationException(
}
try
{
}
catch (Exception e)
{
}
if (oldRootPath == null)
{
return null;
}
else
{
return new File(oldRootPath);
}
}
/**
* Specifies the directory that should be considered the instance
* root. Any relative path used in the server should be considered
* relative to the instance root.
*
* @param instanceRoot The directory that should be considered the
* instanceRoot root.
*
* @return The previous server root, or {@code null} if there was
* none.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* server root.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
{
throw new InitializationException(
}
try
{
}
catch (Exception e)
{
}
if (oldInstancePath == null)
{
return null;
}
else
{
return new File(oldInstancePath);
}
}
/**
* Retrieves the configuration file that should be used to
* initialize the Directory Server config handler. If no default
* configuration file is specified, then the server will attempt to
* use "config/config.ldif" below the server root if it exists.
*
* @return The configuration file that should be used to initialize
* the Directory Server config handler, or {@code null} if
* no configuration file is defined.
*/
public File getConfigFile()
{
if (configFilePath == null)
{
if (serverRoot != null)
{
if (configFile.exists())
{
return configFile;
}
}
return null;
}
else
{
return new File(configFilePath);
}
}
/**
* Specifies the configuration file that should be used to
* initialize the Directory Server config handler.
*
* @param configFile The configuration file that should be used to
* initialize the Directory Server config
* handler.
*
* @return The previously-defined configuration file, or
* {@code null} if none was defined.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* configuration file.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
{
throw new InitializationException(
}
try
{
}
catch (Exception e)
{
}
if (oldConfigFilePath == null)
{
return null;
}
else
{
return new File(oldConfigFilePath);
}
}
/**
* Retrieves the class that provides the Directory Server
* configuration handler implementation. If no config handler class
* is defined, or if a problem occurs while attempting to determine
* the config handler class, then a default class of
* org.opends.server.extensions.ConfigFileHandler will be returned.
*
* @return The class that provides the Directory Server
* configuration handler implementation.
*/
public Class getConfigClass()
{
{
return ConfigFileHandler.class;
}
else
{
try
{
}
catch (Exception e)
{
return ConfigFileHandler.class;
}
}
}
/**
* Specifies the class that provides the Directory Server
* configuration handler implementation. The class must be a
* subclass of the org.opends.server.api.ConfigHandler superclass.
*
* @param configClass The class that proviedes the Directory
* Server configuration handler implementation.
*
* @return The class that was previously configured to provide the
* Directory Server configuration handler implementation,
* or {@code null} if none was defined.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* config handler class.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
{
throw new InitializationException(
configClass.getName()));
}
configClass.getName());
if (oldClassName == null)
{
return null;
}
else
{
try
{
}
catch (Exception e)
{
return null;
}
}
}
/**
* Indicates whether the Directory Server should attempt to start
* with the "last known good" configuration rather than the current
* active configuration file. Note that if there is no "last known
* good" configuration file available, then the server should try to
* start using the current, active configuration file. If no
* explicit value is defined, then a default result of {@code false}
* will be returned.
*
* @return {@code true} if the Directory Server should attempt to
* start using the "last known good" configuration, or
* {@code false} if it should try to start using the
* active configuration.
*/
public boolean useLastKnownGoodConfiguration()
{
if (useLastKnownGoodStr == null)
{
return false;
}
}
/**
* Specifies whether the Directory Server should attempt to start
* using the last known good configuration rather than the
* current active configuration.
*
* @param useLastKnownGoodConfiguration Indicates whether the
* Directory Server should
* attempt to start using the
* last known good
* configuration.
*
* @return The previous setting for this configuration option. If
* no previous value was specified, then {@code false} will
* be returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public boolean setUseLastKnownGoodConfiguration(
boolean useLastKnownGoodConfiguration)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (oldUseLastKnownGoodStr == null)
{
return false;
}
else
{
}
}
/**
* Indicates whether the Directory Server should maintain an archive
* of previous configurations. If no explicit value is defined,
* then a default result of {@code true} will be returned.
*
* @return {@code true} if the Directory Server should maintain an
* archive of previous configurations, or {@code false} if
* not.
*/
public boolean maintainConfigArchive()
{
if (maintainArchiveStr == null)
{
return true;
}
}
/**
* Specifies whether the Directory Server should maintain an archive
* of previous configurations.
*
* @param maintainConfigArchive Indicates whether the Directory
* Server should maintain an archive
* of previous configurations.
*
* @return The previous setting for this configuration option. If
* no previous value was specified, then {@code true} will
* be returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public boolean setMaintainConfigArchive(
boolean maintainConfigArchive)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (oldMaintainStr == null)
{
return true;
}
else
{
}
}
/**
* Retrieves the maximum number of archived configurations that the
* Directory Server should maintain. If no value is defined, then a
* value of zero will be returned.
*
* @return The maximum number of archived configurations that the
* Directory Server should maintain, or zero if there
* should not be any limit.
*/
public int getMaxConfigArchiveSize()
{
if (maxSizeStr == null)
{
return 0;
}
try
{
if (maxSize > 0)
{
return maxSize;
}
else
{
return 0;
}
}
catch (Exception e)
{
return 0;
}
}
/**
* Specifies the maximum number of archived configurations that the
* Directory Server should maintain. A value that is less than or
* equal to zero may be used to indicate that there should not be
* any limit to the number of archived configurations.
*
* @param maxConfigArchiveSize The maximum number of archived
* configurations that the Directory
* Server should maintain.
*
* @return The previous setting for this configuration option. If
* no previous value was specified, then zero will be
* returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public int setMaxConfigArchiveSize(int maxConfigArchiveSize)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (maxConfigArchiveSize < 0)
{
maxConfigArchiveSize = 0;
}
if (oldMaxSizeStr == null)
{
return 0;
}
else
{
try
{
if (oldMaxSize > 0)
{
return oldMaxSize;
}
else
{
return 0;
}
}
catch (Exception e)
{
return 0;
}
}
}
/**
* Retrieves the directory that contains the server schema
* configuration files. If no value is defined, but a default
* that will be returned.
*
* @param userSchema indicates if we need to retrieve user schema or
* "unmodified" schema.
*
* @return The directory that contains the server schema
* configuration files, or {@code null} if none is defined.
*/
{
if (schemaDirectoryPath == null)
{
if (serverRoot != null)
{
if (userSchema)
{
}
else
{
}
{
return schemaDir;
}
}
return null;
}
else
{
return new File(schemaDirectoryPath);
}
}
/**
* Specifies the directory that should contain the server schema
* configuration files. It must exist and must be a directory.
*
* @param schemaDirectory The directory that should contain the
* server schema configuration files.
*
* @return The previously-defined schema configuration directory,
* or {@code null} if none was defined.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* schema directory.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if ((! schemaDirectory.exists()) ||
(! schemaDirectory.isDirectory()))
{
throw new InitializationException(
}
try
{
}
catch (Exception e)
{
}
if (oldSchemaDir == null)
{
return null;
}
else
{
return new File(oldSchemaDir);
}
}
/**
* Retrieves the directory that should be used to hold the server
* lock files. If no value is defined, then the server will attempt
* to use a default directory of "locks" below the server root.
*
* @return The directory that should be used to hold the server
* lock files, or {@code null} if it cannot be determined.
*/
public File getLockDirectory()
{
if (lockFilePath == null)
{
if (serverRoot == null)
{
return null;
}
else
{
}
}
else
{
return new File(lockFilePath);
}
}
/**
* Specifies the directory that should be used to hold the server
* lock files. If the specified path already exists, then it must
* be a directory and its contents must be writable by the server.
* If it does not exist, then its parent directory must exist and
* the server should have permission to create a new subdirectory in
* it.
*
* @param lockDirectory The directory that should be used to hold
* the server lock files.
*
* @return The previously-defined lock directory, or {@code null}
* if none was defined.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided lock
* directory.
*/
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (lockDirectory.exists())
{
if (! lockDirectory.isDirectory())
{
throw new InitializationException(
}
}
else
{
{
throw new InitializationException(
}
}
try
{
}
catch (Exception e)
{
}
if (oldLockDir == null)
{
return null;
}
else
{
return new File(oldLockDir);
}
}
/**
* Indicates whether the Directory Server startup process should
* skip the connection handler creation and initialization phases.
*
* @return {@code true} if the Directory Server should not start
* its connection handlers, or {@code false} if the
* connection handlers should be enabled.
*/
public boolean disableConnectionHandlers()
{
if (disableStr == null)
{
return false;
}
}
/**
* Specifies whether the Directory Server startup process should
* skip the connection handler creation and initialization phases.
*
* @param disableConnectionHandlers Indicates whether the
* Directory Server should skip
* the connection handler
* creation and initialization
* phases.
*
* @return The previous setting for this configuration option. If
* no previous value was specified, then {@code false} will
* be returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public boolean setDisableConnectionHandlers(
boolean disableConnectionHandlers)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (oldDisableStr == null)
{
return false;
}
else
{
}
}
/**
* Indicates whether all threads created by the Directory Server
* should be created as daemon threads.
*
* @return {@code true} if all threads created by the Directory
* Server should be created as daemon threads, or
* {@code false} if not.
*/
public boolean forceDaemonThreads()
{
if (forceDaemonStr == null)
{
return false;
}
else
{
}
}
/**
* Specifies whether all threads created by the Directory Server
* should be created as daemon threads.
*
* @param forceDaemonThreads Indicates whether all threads created
* by the Directory Server should be
* created as daemon threads.
*
* @return The previous setting for this configuration option. If
* no previous value was specified, then {@code false} will
* be returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public boolean setForceDaemonThreads(boolean forceDaemonThreads)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (oldForceDaemonStr == null)
{
return false;
}
else
{
}
}
/**
* Indicates whether the Directory Server should be allowed to use
* the {@code Runtime.exec()} method to be able to launch external
* commands on the underlying system.
*
* @return {@code true} if the Directory Server should be allowed
* to use {@code Runtime.exec()}, or {@code false} if not.
*/
public boolean disableExec()
{
if (disableStr == null)
{
return false;
}
else
{
}
}
/**
* Specifies whether the Directory Server should be allowed to use
* the {@code Runtime.exec()} method to be able to launch external
* commands on the underlying system.
*
* @param disableExec Indicates whether the Directory Server
* should be allowed to launch external
* commands on the underlying system.
*
* @return The previous setting for this configuration option. If
* no previous value was specified, then {@code false} will
* be returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public boolean setDisableExec(boolean disableExec)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (oldDisableStr == null)
{
return false;
}
else
{
}
}
/**
* Retrieves the concurrency level for the Directory Server lock
* table.
*
* @return The concurrency level for the Directory Server lock
* table.
*/
public int getLockManagerConcurrencyLevel()
{
{
return LockManager.DEFAULT_CONCURRENCY_LEVEL;
}
int concurrencyLevel = -1;
try
{
}
catch (Exception e)
{
return LockManager.DEFAULT_CONCURRENCY_LEVEL;
}
if (concurrencyLevel <= 0)
{
return LockManager.DEFAULT_CONCURRENCY_LEVEL;
}
else
{
return concurrencyLevel;
}
}
/**
* Specifies the concurrency level for the Directory Server lock
* table. This should be set to the maximum number of threads that
* could attempt to interact with the lock table at any given time.
*
* @param concurrencyLevel The concurrency level for the Directory
* Server lock manager.
*
* @return The previously-configured concurrency level. If there
* was no previously-configured value, then the default
* concurrency level will be returned.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* concurrency level value.
*/
public int setLockManagerConcurrencyLevel(int concurrencyLevel)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (concurrencyLevel <= 0)
{
throw new InitializationException(
}
if (concurrencyStr == null)
{
return LockManager.DEFAULT_CONCURRENCY_LEVEL;
}
else
{
try
{
}
catch (Exception e)
{
return LockManager.DEFAULT_CONCURRENCY_LEVEL;
}
}
}
/**
* Retrieves whether a fair ordering should be used for the lock
* manager.
*
* @return True if fair orderin should be used or false otherwise
*/
public boolean getLockManagerFairOrdering()
{
{
return LockManager.DEFAULT_FAIR_ORDERING;
}
else
{
try
{
}
catch (Exception e)
{
return LockManager.DEFAULT_FAIR_ORDERING;
}
}
}
/**
* Specifies whether a fair ordering should be used for the lock
* manager.
*
* @param fairOrdering {@code true} if fair ordering should be
* used, or {@code false} if not.
*
* @return The previously-configured setting for fair ordering. If
* there was no previously-configured value, then the
* default initial setting will be returned.
*
* @throws InitializationException If the Directory Server is
* already running.
*/
public boolean setLockManagerFairOrdering(boolean fairOrdering)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (fairOrderingStr == null)
{
return LockManager.DEFAULT_FAIR_ORDERING;
}
else
{
try
{
}
catch (Exception e)
{
return LockManager.DEFAULT_FAIR_ORDERING;
}
}
}
/**
* Retrieves the initial table size for the server lock table. This
* can be used to ensure that the lock table has the appropriate
* size for the expected number of locks that will be held at any
* given time.
*
* @return The initial table size for the server lock table.
*/
public int getLockManagerTableSize()
{
{
}
else
{
try
{
}
catch (Exception e)
{
}
}
}
/**
* Specifies the initial table size for the server lock table. This
* can be used to ensure taht the lock table has the appropriate
* size for the expected number of locks that will be held at any
* given time.
*
* @param lockTableSize The initial table size for the server lock
* table.
*
* @return The previously-configured initial lock table size. If
* there was no previously-configured value, then the
* default initial table size will be returned.
*
* @throws InitializationException If the Directory Server is
* already running or there is a
* problem with the provided
* initial table size.
*/
public int setLockManagerTableSize(int lockTableSize)
throws InitializationException
{
if (DirectoryServer.isRunning())
{
throw new InitializationException(
}
if (lockTableSize <= 0)
{
throw new InitializationException(
}
if (tableSizeStr == null)
{
}
else
{
try
{
}
catch (Exception e)
{
}
}
}
}