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);
}
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));
}
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.");
}
}
}
}
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);
}
}
}
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);
}
Aggregations