Search in sources :

Example 1 with Slf4jLoggingHandler

use of org.apache.qpid.server.store.berkeleydb.logging.Slf4jLoggingHandler in project qpid-broker-j by apache.

the class ReplicatedEnvironmentFacade method createEnvironment.

private void createEnvironment(boolean createEnvironmentInSeparateThread, Runnable postCreationAction) {
    String groupName = _configuration.getGroupName();
    String helperHostPort = _configuration.getHelperHostPort();
    String hostPort = _configuration.getHostPort();
    boolean designatedPrimary = _configuration.isDesignatedPrimary();
    int priority = _configuration.getPriority();
    int quorumOverride = _configuration.getQuorumOverride();
    String nodeName = _configuration.getName();
    String helperNodeName = _configuration.getHelperNodeName();
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Creating environment");
        LOGGER.info("Environment path " + _environmentDirectory.getAbsolutePath());
        LOGGER.info("Group name " + groupName);
        LOGGER.info("Node name " + nodeName);
        LOGGER.info("Node host port " + hostPort);
        LOGGER.info("Helper host port " + helperHostPort);
        LOGGER.info("Helper node name " + helperNodeName);
        LOGGER.info("Durability " + _defaultDurability);
        LOGGER.info("Designated primary (applicable to 2 node case only) " + designatedPrimary);
        LOGGER.info("Node priority " + priority);
        LOGGER.info("Quorum override " + quorumOverride);
        LOGGER.info("Permitted node list " + _permittedNodes);
    }
    Map<String, String> replicationEnvironmentParameters = new HashMap<>(ReplicatedEnvironmentFacade.REPCONFIG_DEFAULTS);
    replicationEnvironmentParameters.putAll(_configuration.getReplicationParameters());
    ReplicationConfig replicationConfig = new ReplicationConfig(groupName, nodeName, hostPort);
    replicationConfig.setHelperHosts(helperHostPort);
    replicationConfig.setDesignatedPrimary(designatedPrimary);
    replicationConfig.setNodePriority(priority);
    replicationConfig.setElectableGroupSizeOverride(quorumOverride);
    for (Map.Entry<String, String> configItem : replicationEnvironmentParameters.entrySet()) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Setting ReplicationConfig key " + configItem.getKey() + " to '" + configItem.getValue() + "'");
        }
        replicationConfig.setConfigParam(configItem.getKey(), configItem.getValue());
    }
    Map<String, String> environmentParameters = new HashMap<>(EnvironmentFacade.ENVCONFIG_DEFAULTS);
    environmentParameters.putAll(_configuration.getParameters());
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    envConfig.setTransactional(true);
    envConfig.setExceptionListener(new ExceptionListener());
    envConfig.setDurability(_defaultDurability);
    envConfig.setCacheMode(_configuration.getCacheMode());
    envConfig.setLoggingHandler(new Slf4jLoggingHandler(_configuration));
    LOGGER.info("Cache mode {}", envConfig.getCacheMode());
    for (Map.Entry<String, String> configItem : environmentParameters.entrySet()) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Setting EnvironmentConfig key " + configItem.getKey() + " to '" + configItem.getValue() + "'");
        }
        envConfig.setConfigParam(configItem.getKey(), configItem.getValue());
    }
    DbInternal.setLoadPropertyFile(envConfig, false);
    File propsFile = new File(_environmentDirectory, "je.properties");
    if (propsFile.exists()) {
        LOGGER.warn("The BDB configuration file at '" + _environmentDirectory + File.separator + "je.properties' will NOT be loaded.  Configure BDB using Qpid context variables instead.");
    }
    if (createEnvironmentInSeparateThread) {
        createEnvironmentInSeparateThread(_environmentDirectory, envConfig, replicationConfig, postCreationAction);
    } else {
        createEnvironment(_environmentDirectory, envConfig, replicationConfig, postCreationAction);
    }
}
Also used : ReplicationConfig(com.sleepycat.je.rep.ReplicationConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Slf4jLoggingHandler(org.apache.qpid.server.store.berkeleydb.logging.Slf4jLoggingHandler) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) File(java.io.File)

Aggregations

EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)1 ReplicationConfig (com.sleepycat.je.rep.ReplicationConfig)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Slf4jLoggingHandler (org.apache.qpid.server.store.berkeleydb.logging.Slf4jLoggingHandler)1