Search in sources :

Example 1 with ConfigParam

use of com.sleepycat.je.config.ConfigParam in project qpid-broker-j by apache.

the class EnvironmentUtils method updateMutableConfig.

public static void updateMutableConfig(Environment environment, Set<String> paramsSetByDefault, boolean includeHA, final ConfiguredObject<?> object) {
    EnvironmentMutableConfig mutableConfig = environment.getMutableConfig();
    final Set<String> contextVariables = object.getContextKeys(false);
    for (Map.Entry<String, ConfigParam> entry : EnvironmentParams.SUPPORTED_PARAMS.entrySet()) {
        String paramName = entry.getKey();
        ConfigParam param = entry.getValue();
        if (param.isMutable() && (includeHA || !param.isForReplication())) {
            boolean contextValueSet = contextVariables.contains(paramName);
            boolean currentlySetInEnv = mutableConfig.isConfigParamSet(paramName);
            String contextValue = contextValueSet ? object.getContextValue(String.class, paramName) : null;
            contextValueSet = (contextValue != null);
            try {
                if (contextValueSet) {
                    if (!currentlySetInEnv || !contextValue.equals(mutableConfig.getConfigParam(paramName))) {
                        mutableConfig.setConfigParam(paramName, contextValue);
                        LOGGER.debug("Setting BDB configuration parameter '{}' to value '{}'.", param, contextValue);
                    }
                } else if (currentlySetInEnv && !paramsSetByDefault.contains(paramName)) {
                    mutableConfig.setConfigParam(paramName, param.getDefault());
                    LOGGER.debug("Setting BDB configuration parameter '{}' to its default value.", param);
                }
            } catch (IllegalArgumentException e) {
                LOGGER.warn("Unable to set BDB configuration parameter '{}' to value '{}'.", param, contextValue, e);
            }
        }
    }
}
Also used : ConfigParam(com.sleepycat.je.config.ConfigParam) EnvironmentMutableConfig(com.sleepycat.je.EnvironmentMutableConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

EnvironmentMutableConfig (com.sleepycat.je.EnvironmentMutableConfig)1 ConfigParam (com.sleepycat.je.config.ConfigParam)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1