Search in sources :

Example 21 with EnvironmentConfig

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

the class BdbStorageEngineTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    this.envConfig = new EnvironmentConfig();
    this.envConfig.setDurability(Durability.COMMIT_NO_SYNC);
    this.envConfig.setAllowCreate(true);
    this.envConfig.setTransactional(true);
    this.tempDir = TestUtils.createTempDir();
    this.environment = new Environment(this.tempDir, envConfig);
    this.databaseConfig = new DatabaseConfig();
    databaseConfig.setAllowCreate(true);
    databaseConfig.setTransactional(true);
    databaseConfig.setSortedDuplicates(false);
    this.database = environment.openDatabase(null, "test", databaseConfig);
    this.runtimeConfig = new BdbRuntimeConfig();
    runtimeConfig.setLockMode(LOCK_MODE);
    this.store = makeBdbStorageEngine("test", this.environment, this.database, runtimeConfig, this.prefixPartitionId);
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) DatabaseConfig(com.sleepycat.je.DatabaseConfig) Before(org.junit.Before)

Example 22 with EnvironmentConfig

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

the class BdbSplitStorageEngineTest method testSharedCache.

@Test
public void testSharedCache() throws DatabaseException {
    EnvironmentConfig environmentConfig = new EnvironmentConfig();
    environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
    environmentConfig.setAllowCreate(true);
    environmentConfig.setTransactional(true);
    environmentConfig.setSharedCache(true);
    environmentConfig.setCacheSize(CACHE_SIZE);
    DatabaseConfig databaseConfig = new DatabaseConfig();
    databaseConfig.setAllowCreate(true);
    databaseConfig.setTransactional(true);
    databaseConfig.setSortedDuplicates(true);
    long maxCacheSize = getMaxCacheUsage(environmentConfig, databaseConfig);
    // Include a buffer of 1mb.. since the actual cache usage can be a few
    // bytes more
    assertEquals("MaxCacheSize" + maxCacheSize + " <= CACHE_SIZE:" + CACHE_SIZE, true, maxCacheSize <= (CACHE_SIZE + ByteUtils.BYTES_PER_MB));
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) DatabaseConfig(com.sleepycat.je.DatabaseConfig) Test(org.junit.Test)

Example 23 with EnvironmentConfig

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

the class OrphanConfigurationRecordPurger method purge.

private void purge() throws Exception {
    EnvironmentConfig config = EnvironmentConfig.DEFAULT;
    config.setAllowCreate(false);
    config.setTransactional(true);
    try (Environment env = createEnvironment(config)) {
        final int version = getVersion(env, READ_ONLY_DB_CONFIG);
        if (!ALLOWED_VERSIONS.contains(version)) {
            throw new IllegalStateException(String.format("Store has unexpected version. Found %d expected %s", version, ALLOWED_VERSIONS));
        }
        final Transaction tx = env.beginTransaction(null, TransactionConfig.DEFAULT);
        boolean success = false;
        try {
            purgeOrphans(env, tx);
            success = true;
        } finally {
            if (!success) {
                System.out.println("No config or config hierarchy records purged.");
                tx.abort();
            } else if (_dryRun) {
                System.out.println("No config or config hierarchy records purged - -dryRun flag specified.");
                tx.abort();
            } else {
                tx.commit();
                System.out.format("Config records(s) and associated hierarchy records purged.");
            }
        }
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) ReplicatedEnvironment(com.sleepycat.je.rep.ReplicatedEnvironment)

Example 24 with EnvironmentConfig

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

the class BDBPreferenceStoreTest method populateTestData.

private void populateTestData(final List<PreferenceRecord> records, final String modelVersion) {
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    envConfig.setTransactional(false);
    try (Environment environment = new Environment(_storeFile, envConfig)) {
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        try (Database versionDb = environment.openDatabase(null, "USER_PREFERENCES_VERSION", dbConfig);
            Database preferencesDb = environment.openDatabase(null, "USER_PREFERENCES", dbConfig)) {
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry value = new DatabaseEntry();
            UUIDTupleBinding keyBinding = UUIDTupleBinding.getInstance();
            MapBinding valueBinding = MapBinding.getInstance();
            for (PreferenceRecord record : records) {
                keyBinding.objectToEntry(record.getId(), key);
                valueBinding.objectToEntry(record.getAttributes(), value);
                preferencesDb.put(null, key, value);
            }
            ByteBinding.byteToEntry((byte) 0, value);
            StringBinding.stringToEntry(modelVersion, key);
            versionDb.put(null, key, value);
        }
    }
}
Also used : MapBinding(org.apache.qpid.server.store.berkeleydb.tuple.MapBinding) EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Database(com.sleepycat.je.Database) PreferenceRecord(org.apache.qpid.server.store.preferences.PreferenceRecord) Environment(com.sleepycat.je.Environment) UUIDTupleBinding(org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 25 with EnvironmentConfig

use of com.sleepycat.je.EnvironmentConfig in project bboxdb by jnidzwetzki.

the class FileLineIndex method openDatabase.

/**
 * Open the Berkeley DB
 * @throws IOException
 */
protected void openDatabase() throws IOException {
    final EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setTransactional(false);
    envConfig.setAllowCreate(true);
    envConfig.setSharedCache(true);
    tmpDatabaseDir = Files.createTempDirectory(null);
    dbEnv = new Environment(tmpDatabaseDir.toFile(), envConfig);
    logger.info("Database dir is {}", tmpDatabaseDir);
    // Delete database on exit
    FileUtil.deleteDirOnExit(tmpDatabaseDir);
    final DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(false);
    dbConfig.setAllowCreate(true);
    dbConfig.setDeferredWrite(true);
    database = dbEnv.openDatabase(null, "lines", dbConfig);
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) 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