Search in sources :

Example 11 with EnvironmentConfig

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

the class ReplicatedEnvironmentFacadeTest method createIntruder.

private void createIntruder(String nodeName, String node1NodeHostPort) {
    File environmentPathFile = new File(_storePath, nodeName);
    environmentPathFile.mkdirs();
    ReplicationConfig replicationConfig = new ReplicationConfig(TEST_GROUP_NAME, nodeName, node1NodeHostPort);
    replicationConfig.setHelperHosts(TEST_NODE_HOST_PORT);
    replicationConfig.setConsistencyPolicy(NoConsistencyRequiredPolicy.NO_CONSISTENCY);
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    envConfig.setTransactional(true);
    envConfig.setDurability(TEST_DURABILITY);
    ReplicatedEnvironment intruder = null;
    try {
        intruder = new ReplicatedEnvironment(environmentPathFile, replicationConfig, envConfig);
    } finally {
        if (intruder != null) {
            intruder.close();
        }
    }
}
Also used : ReplicationConfig(com.sleepycat.je.rep.ReplicationConfig) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) File(java.io.File) ReplicatedEnvironment(com.sleepycat.je.rep.ReplicatedEnvironment)

Example 12 with EnvironmentConfig

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

the class MultiNodeTest method testClusterCannotStartWithIntruder.

@Test
public void testClusterCannotStartWithIntruder() throws Exception {
    int intruderPort = new PortHelper().getNextAvailable(Arrays.stream(getBrokerAdmin().getBdbPorts()).max().getAsInt() + 1);
    String nodeName = "intruder";
    String nodeHostPort = getBrokerAdmin().getHost() + ":" + intruderPort;
    File environmentPathFile = Files.createTempDirectory("qpid-work-intruder").toFile();
    try {
        environmentPathFile.mkdirs();
        ReplicationConfig replicationConfig = new ReplicationConfig("test", nodeName, nodeHostPort);
        replicationConfig.setHelperHosts(getBrokerAdmin().getHelperHostPort());
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        envConfig.setTransactional(true);
        envConfig.setDurability(new Durability(Durability.SyncPolicy.SYNC, Durability.SyncPolicy.WRITE_NO_SYNC, Durability.ReplicaAckPolicy.SIMPLE_MAJORITY));
        final String currentThreadName = Thread.currentThread().getName();
        try (ReplicatedEnvironment intruder = new ReplicatedEnvironment(environmentPathFile, replicationConfig, envConfig)) {
            LOGGER.debug("Intruder started");
        } finally {
            Thread.currentThread().setName(currentThreadName);
        }
        Set<Integer> ports = Arrays.stream(getBrokerAdmin().getGroupAmqpPorts()).boxed().collect(Collectors.toSet());
        for (int port : ports) {
            getBrokerAdmin().awaitNodeToAttainAttributeValue(port, BDBHAVirtualHostNode.STATE, State.ERRORED.name());
        }
        getBrokerAdmin().stop();
        try {
            getBrokerAdmin().start();
            fail("Cluster cannot start with an intruder node");
        } catch (Exception e) {
        // pass
        }
    } finally {
        FileUtils.delete(environmentPathFile, true);
    }
}
Also used : ReplicationConfig(com.sleepycat.je.rep.ReplicationConfig) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) PortHelper(org.apache.qpid.test.utils.PortHelper) Durability(com.sleepycat.je.Durability) File(java.io.File) ReplicatedEnvironment(com.sleepycat.je.rep.ReplicatedEnvironment) JMSException(javax.jms.JMSException) TransactionRolledBackException(javax.jms.TransactionRolledBackException) Test(org.junit.Test)

Example 13 with EnvironmentConfig

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

the class AbstractUpgradeTestCase method createEnvironment.

protected Environment createEnvironment(File storeLocation) {
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    envConfig.setTransactional(true);
    envConfig.setConfigParam("je.lock.nLockTables", "7");
    envConfig.setReadOnly(false);
    envConfig.setSharedCache(false);
    envConfig.setCacheSize(0);
    return new Environment(storeLocation, envConfig);
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment)

Example 14 with EnvironmentConfig

use of com.sleepycat.je.EnvironmentConfig 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)

Example 15 with EnvironmentConfig

use of com.sleepycat.je.EnvironmentConfig in project sessdb by ppdai.

the class BdbBenchmark method open.

@Override
public void open() {
    try {
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        envConfig.setCachePercent(90);
        File file = new File(databaseDir_);
        if (!file.exists()) {
            file.mkdirs();
        }
        env_ = new Environment(file, envConfig);
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        bdb_ = env_.openDatabase(null, BdbBenchmark.DATABASE_NAME, dbConfig);
    } catch (DatabaseException e) {
        e.printStackTrace();
    }
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) File(java.io.File) DatabaseException(com.sleepycat.je.DatabaseException) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Aggregations

EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)28 Environment (com.sleepycat.je.Environment)20 DatabaseConfig (com.sleepycat.je.DatabaseConfig)16 File (java.io.File)11 Database (com.sleepycat.je.Database)5 DatabaseEntry (com.sleepycat.je.DatabaseEntry)5 ReplicatedEnvironment (com.sleepycat.je.rep.ReplicatedEnvironment)5 ReplicationConfig (com.sleepycat.je.rep.ReplicationConfig)5 Transaction (com.sleepycat.je.Transaction)4 IOException (java.io.IOException)4 Cursor (com.sleepycat.je.Cursor)3 DatabaseException (com.sleepycat.je.DatabaseException)3 RuntimeIOException (htsjdk.samtools.util.RuntimeIOException)2 LineIterator (htsjdk.tribble.readers.LineIterator)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Parameter (com.beust.jcommander.Parameter)1 IOUtils (com.github.lindenb.jvarkit.io.IOUtils)1 JvarkitException (com.github.lindenb.jvarkit.lang.JvarkitException)1 Percentile (com.github.lindenb.jvarkit.math.stats.Percentile)1