Search in sources :

Example 6 with ReplicationConfig

use of com.sleepycat.je.rep.ReplicationConfig in project qpid-broker-j by apache.

the class ReplicatedEnvironmentFacade method createReplicationGroupAdmin.

private ReplicationGroupAdmin createReplicationGroupAdmin() {
    final Set<InetSocketAddress> helpers = new HashSet<InetSocketAddress>();
    final ReplicationConfig repConfig = getEnvironment().getRepConfig();
    helpers.addAll(repConfig.getHelperSockets());
    helpers.add(HostPortPair.getSocket(HostPortPair.getString(repConfig.getNodeHostname(), repConfig.getNodePort())));
    return new ReplicationGroupAdmin(_configuration.getGroupName(), helpers);
}
Also used : ReplicationConfig(com.sleepycat.je.rep.ReplicationConfig) InetSocketAddress(java.net.InetSocketAddress) ReplicationGroupAdmin(com.sleepycat.je.rep.util.ReplicationGroupAdmin) HashSet(java.util.HashSet)

Example 7 with ReplicationConfig

use of com.sleepycat.je.rep.ReplicationConfig 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

ReplicationConfig (com.sleepycat.je.rep.ReplicationConfig)7 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)5 ReplicatedEnvironment (com.sleepycat.je.rep.ReplicatedEnvironment)5 File (java.io.File)5 Durability (com.sleepycat.je.Durability)1 Environment (com.sleepycat.je.Environment)1 ReplicationGroupAdmin (com.sleepycat.je.rep.util.ReplicationGroupAdmin)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 JMSException (javax.jms.JMSException)1 TransactionRolledBackException (javax.jms.TransactionRolledBackException)1 Slf4jLoggingHandler (org.apache.qpid.server.store.berkeleydb.logging.Slf4jLoggingHandler)1 PortHelper (org.apache.qpid.test.utils.PortHelper)1 Test (org.junit.Test)1