Search in sources :

Example 11 with Environment

use of com.sleepycat.je.Environment in project voldemort by voldemort.

the class BdbStorageConfiguration method checkPointAllEnvironments.

/**
 * Forceful checkpointing
 */
@JmxOperation(description = "Forcefully checkpoint all the environments")
public void checkPointAllEnvironments() {
    synchronized (lock) {
        try {
            for (Environment environment : environments.values()) {
                CheckpointConfig checkPointConfig = new CheckpointConfig();
                checkPointConfig.setForce(true);
                environment.checkpoint(checkPointConfig);
            }
        } catch (DatabaseException e) {
            throw new VoldemortException(e);
        }
    }
}
Also used : CheckpointConfig(com.sleepycat.je.CheckpointConfig) Environment(com.sleepycat.je.Environment) DatabaseException(com.sleepycat.je.DatabaseException) VoldemortException(voldemort.VoldemortException) JmxOperation(voldemort.annotations.jmx.JmxOperation)

Example 12 with Environment

use of com.sleepycat.je.Environment in project voldemort by voldemort.

the class BdbSplitStorageEngineTest method getMaxCacheUsage.

private long getMaxCacheUsage(EnvironmentConfig environmentConfig, DatabaseConfig databaseConfig) throws DatabaseException {
    File dirA = new File(bdbMasterDir + "/" + "storeA");
    if (!dirA.exists()) {
        dirA.mkdirs();
    }
    Environment environmentA = new Environment(dirA, environmentConfig);
    Database databaseA = environmentA.openDatabase(null, "storeA", databaseConfig);
    BdbStorageEngine storeA = BdbStorageEngineTest.makeBdbStorageEngine("storeA", environmentA, databaseA, new BdbRuntimeConfig(), this.prefixPartitionId);
    File dirB = new File(bdbMasterDir + "/" + "storeB");
    if (!dirB.exists()) {
        dirB.mkdirs();
    }
    Environment environmentB = new Environment(dirB, environmentConfig);
    Database databaseB = environmentB.openDatabase(null, "storeB", databaseConfig);
    BdbStorageEngine storeB = BdbStorageEngineTest.makeBdbStorageEngine("storeB", environmentB, databaseB, new BdbRuntimeConfig(), this.prefixPartitionId);
    long maxCacheUsage = 0;
    for (int i = 0; i <= 10000; i++) {
        byte[] value = new byte[(int) (CACHE_SIZE / 10000)];
        // try to push values in cache
        storeA.put(TestUtils.toByteArray(i + "A"), new Versioned<byte[]>(value), null);
        storeA.get(TestUtils.toByteArray(i + "A"), null);
        storeB.put(TestUtils.toByteArray(i + "B"), new Versioned<byte[]>(value), null);
        storeB.get(TestUtils.toByteArray(i + "B"), null);
        EnvironmentStats statsA = environmentA.getStats(new StatsConfig());
        EnvironmentStats statsB = environmentB.getStats(new StatsConfig());
        long totalCacheSize = statsA.getCacheTotalBytes() + statsB.getCacheTotalBytes();
        System.out.println("A.size:" + statsA.getCacheTotalBytes() + " B.size:" + statsB.getCacheTotalBytes() + " total:" + totalCacheSize + " max:" + maxCacheUsage + " cacheMax:" + environmentA.getConfig().getCacheSize());
        System.out.println("Shared.A:" + statsA.getSharedCacheTotalBytes() + " nSharedEnv:" + statsA.getNSharedCacheEnvironments());
        maxCacheUsage = Math.max(maxCacheUsage, totalCacheSize);
    }
    return maxCacheUsage;
}
Also used : StatsConfig(com.sleepycat.je.StatsConfig) Database(com.sleepycat.je.Database) Environment(com.sleepycat.je.Environment) EnvironmentStats(com.sleepycat.je.EnvironmentStats) File(java.io.File)

Example 13 with Environment

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

the class OrphanConfigurationRecordPurger method createEnvironment.

private Environment createEnvironment(final EnvironmentConfig config) throws Exception {
    final Environment env;
    if (_ha) {
        final ReplicationConfig repConfig = (ReplicationConfig) ReplicationConfig.DEFAULT.setNodeHostPort(_nodeHost).setGroupName(_groupName).setNodeName(_nodeName).setDesignatedPrimary(true).setElectableGroupSizeOverride(1);
        env = new ReplicatedEnvironment(new File(_storePath), repConfig, config);
    } else {
        env = new Environment(new File(_storePath), config);
    }
    return env;
}
Also used : ReplicationConfig(com.sleepycat.je.rep.ReplicationConfig) Environment(com.sleepycat.je.Environment) ReplicatedEnvironment(com.sleepycat.je.rep.ReplicatedEnvironment) File(java.io.File) ReplicatedEnvironment(com.sleepycat.je.rep.ReplicatedEnvironment)

Example 14 with Environment

use of com.sleepycat.je.Environment 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 15 with Environment

use of com.sleepycat.je.Environment in project janusgraph by JanusGraph.

the class BerkeleyJEStoreManager method initialize.

private void initialize(int cachePercent, final boolean sharedCache, final CacheMode cacheMode) throws BackendException {
    try {
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        envConfig.setTransactional(transactional);
        envConfig.setCachePercent(cachePercent);
        envConfig.setSharedCache(sharedCache);
        envConfig.setCacheMode(cacheMode);
        if (batchLoading) {
            envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER, "false");
            envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, "false");
        }
        // Open the environment
        environment = new Environment(directory, envConfig);
    } catch (DatabaseException e) {
        throw new PermanentBackendException("Error during BerkeleyJE initialization: ", e);
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) DatabaseException(com.sleepycat.je.DatabaseException)

Aggregations

Environment (com.sleepycat.je.Environment)38 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)20 DatabaseConfig (com.sleepycat.je.DatabaseConfig)18 File (java.io.File)15 Database (com.sleepycat.je.Database)10 DatabaseException (com.sleepycat.je.DatabaseException)9 DatabaseEntry (com.sleepycat.je.DatabaseEntry)5 Transaction (com.sleepycat.je.Transaction)5 IOException (java.io.IOException)5 Cursor (com.sleepycat.je.Cursor)3 EnvironmentMutableConfig (com.sleepycat.je.EnvironmentMutableConfig)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 VoldemortException (voldemort.VoldemortException)3 CheckpointConfig (com.sleepycat.je.CheckpointConfig)2 StatsConfig (com.sleepycat.je.StatsConfig)2 ReplicatedEnvironment (com.sleepycat.je.rep.ReplicatedEnvironment)2 RuntimeIOException (htsjdk.samtools.util.RuntimeIOException)2 LineIterator (htsjdk.tribble.readers.LineIterator)2 BdbDbCreationException (nl.knaw.huygens.timbuctoo.v5.berkeleydb.exceptions.BdbDbCreationException)2