boolean newCompactEncoding;
String newCacheType = DEFAULT_FSCACHE_TYPE;
String newCacheHome = DEFAULT_FSCACHE_HOME;
SortedSet<String> newJEProperties;
EnvironmentMutableConfig newMutableEnvConfig =
new EnvironmentMutableConfig();
EnvironmentConfig newEnvConfig =
new EnvironmentConfig();
// Read configuration.
newConfigEntryDN = configuration.dn();
newLockTimeout = configuration.getLockTimeout();
// If the value of zero arrives make sure it is traslated
// to the maximum possible value we can cap maxEntries to.
newMaxEntries = configuration.getMaxEntries();
if (newMaxEntries <= 0) {
newMaxEntries = DEFAULT_FSCACHE_MAX_ENTRIES;
}
// Maximum memory/space this cache can utilize.
newMaxAllowedMemory = configuration.getMaxMemorySize();
// Determine JE cache percent.
newJECachePercent = configuration.getDBCachePercent();
// Determine JE cache size.
newJECacheSize = configuration.getDBCacheSize();
// Check if this cache is persistent.
newPersistentCache = configuration.isPersistentCache();
// Check if this cache should use compact encoding.
newCompactEncoding = configuration.isCompactEncoding();
// Get native JE properties.
newJEProperties = configuration.getJEProperty();
switch (errorHandler.getConfigPhase())
{
case PHASE_INIT:
// Determine the cache type.
newCacheType = configuration.getCacheType().toString();
// Determine the cache home.
newCacheHome = configuration.getCacheDirectory();
newIncludeFilters = EntryCacheCommon.getFilters(
configuration.getIncludeFilter(),
ERR_CACHE_INVALID_INCLUDE_FILTER,
errorHandler,
newConfigEntryDN
);
newExcludeFilters = EntryCacheCommon.getFilters (
configuration.getExcludeFilter(),
ERR_CACHE_INVALID_EXCLUDE_FILTER,
errorHandler,
newConfigEntryDN
);
// JE configuration properties.
try {
newMutableEnvConfig.setCachePercent((newJECachePercent != 0 ?
newJECachePercent :
EnvironmentConfig.DEFAULT.getCachePercent()));
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
errorHandler.reportError(
ERR_FSCACHE_CANNOT_SET_JE_MEMORY_PCT.get(),
false,
DirectoryServer.getServerErrorResultCode()
);
}
try {
newMutableEnvConfig.setCacheSize(newJECacheSize);
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
errorHandler.reportError(
ERR_FSCACHE_CANNOT_SET_JE_MEMORY_SIZE.get(),
false,
DirectoryServer.getServerErrorResultCode()
);
}
// JE native properties.
try {
newEnvConfig = ConfigurableEnvironment.setJEProperties(
newEnvConfig, newJEProperties, configAttrMap);
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
errorHandler.reportError(
ERR_FSCACHE_CANNOT_SET_JE_PROPERTIES.get(e.getMessage()),
false, DirectoryServer.getServerErrorResultCode());
}
break;
case PHASE_ACCEPTABLE: // acceptable and apply are using the same
case PHASE_APPLY: // error ID codes
newIncludeFilters = EntryCacheCommon.getFilters (
configuration.getIncludeFilter(),
ERR_CACHE_INVALID_INCLUDE_FILTER,
errorHandler,
newConfigEntryDN
);
newExcludeFilters = EntryCacheCommon.getFilters (
configuration.getExcludeFilter(),
ERR_CACHE_INVALID_EXCLUDE_FILTER,
errorHandler,
newConfigEntryDN
);
// Iterate through native JE properties.
try {
Map paramsMap = EnvironmentParams.SUPPORTED_PARAMS;
// If this entry cache is disabled then there is no open JE
// environment to check against, skip mutable check if so.
if (configuration.isEnabled()) {
newMutableEnvConfig =
ConfigurableEnvironment.setJEProperties(
entryCacheEnv.getConfig(), newJEProperties, configAttrMap);
EnvironmentConfig oldEnvConfig = entryCacheEnv.getConfig();
for (String jeEntry : newJEProperties) {
// There is no need to validate properties yet again.
StringTokenizer st = new StringTokenizer(jeEntry, "=");
if (st.countTokens() == 2) {
String jePropertyName = st.nextToken();
String jePropertyValue = st.nextToken();
ConfigParam param = (ConfigParam) paramsMap.get(jePropertyName);
if (!param.isMutable()) {
String oldValue = oldEnvConfig.getConfigParam(param.getName());
String newValue = jePropertyValue;
if (!oldValue.equalsIgnoreCase(newValue)) {
Message message =
INFO_CONFIG_JE_PROPERTY_REQUIRES_RESTART.get(
jePropertyName);
errorHandler.reportError(message, true, ResultCode.SUCCESS,
true);
if (debugEnabled()) {
TRACER.debugInfo("The change to the following property " +
"will take effect when the component is restarted: " +
jePropertyName);
}
}
}
}
}
} else {
newMutableEnvConfig =
ConfigurableEnvironment.setJEProperties(
new EnvironmentConfig(), newJEProperties, configAttrMap);
}
} catch (ConfigException ce) {
errorHandler.reportError(ce.getMessageObject(),
false, DirectoryServer.getServerErrorResultCode());
} catch (Exception e) {
errorHandler.reportError(
Message.raw(stackTraceToSingleLineString(e)),
false, DirectoryServer.getServerErrorResultCode());
}
break;
}
if (applyChanges && errorHandler.getIsAcceptable())
{
switch (errorHandler.getConfigPhase()) {
case PHASE_INIT:
cacheType = newCacheType;
cacheHome = newCacheHome;
entryCacheEnvConfig = newEnvConfig;
entryCacheEnvMutableConfig = newMutableEnvConfig;
break;
case PHASE_APPLY:
try {
newMutableEnvConfig =
entryCacheEnv.getMutableConfig();
newMutableEnvConfig.setCachePercent((newJECachePercent != 0 ?
newJECachePercent :
EnvironmentConfig.DEFAULT.getCachePercent()));
entryCacheEnv.setMutableConfig(newMutableEnvConfig);
entryCacheEnv.evictMemory();
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
errorHandler.reportError(
ERR_FSCACHE_CANNOT_SET_JE_MEMORY_PCT.get(),
false,
DirectoryServer.getServerErrorResultCode()
);
}
try {
newMutableEnvConfig =
entryCacheEnv.getMutableConfig();
newMutableEnvConfig.setCacheSize(newJECacheSize);
entryCacheEnv.setMutableConfig(newMutableEnvConfig);
entryCacheEnv.evictMemory();
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);