use of com.sleepycat.je.DatabaseConfig in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method createTable.
public boolean createTable(String tableName, DatabaseSession databaseSession, boolean transactional) throws BimserverDatabaseException {
if (tables.containsKey(tableName)) {
throw new BimserverDatabaseException("Table " + tableName + " already created");
}
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setKeyPrefixing(keyPrefixing);
databaseConfig.setAllowCreate(true);
boolean finalTransactional = transactional && useTransactions;
databaseConfig.setDeferredWrite(!finalTransactional);
// if (!transactional) {
// databaseConfig.setCacheMode(CacheMode.EVICT_BIN);
// }
databaseConfig.setTransactional(finalTransactional);
databaseConfig.setSortedDuplicates(false);
Database database = environment.openDatabase(null, tableName, databaseConfig);
if (database == null) {
return false;
}
tables.put(tableName, new TableWrapper(database, finalTransactional));
return true;
}
use of com.sleepycat.je.DatabaseConfig in project radixdlt by radixdlt.
the class BerkeleySafetyStateStore method open.
private Database open() {
DatabaseConfig primaryConfig = new DatabaseConfig();
primaryConfig.setAllowCreate(true);
primaryConfig.setTransactional(true);
try {
// This SuppressWarnings here is valid, as ownership of the underlying
// resource is not changed here, the resource is just accessed.
@SuppressWarnings("resource") Environment env = this.dbEnv.getEnvironment();
return env.openDatabase(null, SAFETY_STORE_NAME, primaryConfig);
} catch (Exception e) {
throw new BerkeleyStoreException("Error while opening database", e);
}
}
use of com.sleepycat.je.DatabaseConfig in project radixdlt by radixdlt.
the class BerkeleyRecoverableProcessedTxnStore method open.
@Override
public void open(DatabaseEnvironment dbEnv) {
recoverableTransactionsDatabase = dbEnv.getEnvironment().openDatabase(null, RECOVERABLE_TRANSACTIONS_DB_NAME, new DatabaseConfig().setAllowCreate(true).setTransactional(true).setKeyPrefixing(true).setBtreeComparator(lexicographicalComparator()));
accumulatorDatabase = dbEnv.getEnvironment().openDatabase(null, ACCUMULATOR_HASH_DB_NAME, new DatabaseConfig().setAllowCreate(true).setTransactional(true).setKeyPrefixing(true).setBtreeComparator(lexicographicalComparator()));
try (var cursor = accumulatorDatabase.openCursor(null, null)) {
var key = new DatabaseEntry(Longs.toByteArray(Long.MAX_VALUE));
var value = new DatabaseEntry();
cursor.getSearchKeyRange(key, value, null);
var status = cursor.getPrev(key, value, null);
if (status == SUCCESS) {
var accumulatorHash = HashCode.fromBytes(value.getData());
var stateVersion = Longs.fromByteArray(key.getData());
this.accumulatorState = new AccumulatorState(stateVersion, accumulatorHash);
} else {
this.accumulatorState = new AccumulatorState(0, HashUtils.zero256());
}
}
}
use of com.sleepycat.je.DatabaseConfig in project kcache by rayokota.
the class BdbJECache method openDB.
@Override
protected void openDB() {
try {
// Environment and database opens
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
// Data is synced in flush()
envConfig.setDurability(Durability.COMMIT_NO_SYNC);
env = new Environment(dbDir(), envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(true);
dbConfig.setKeyPrefixing(true);
dbConfig.setBtreeComparator(new KeyBytesComparator<>(keySerde(), comparator()));
db = env.openDatabase(null, name(), dbConfig);
} catch (final Exception e) {
throw new CacheInitializationException("Error opening store " + name() + " at location " + dbDir(), e);
}
}
use of com.sleepycat.je.DatabaseConfig in project parliament by SemWebCentral.
the class PersistentTemporalIndex method initializeEnvironment.
private void initializeEnvironment(boolean newEnvironment) throws EnvironmentLockedException, DatabaseException {
if (newEnvironment) {
File dirFile = new File(dirName);
dirFile.mkdirs();
envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setLocking(false);
envConfig.setReadOnly(false);
envConfig.setTransactional(false);
environment = new Environment(dirFile, envConfig);
}
dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setDeferredWrite(true);
dbConfig.setReadOnly(false);
dbConfig.setTransactional(false);
// Create secondary database for indexing Starts
startsConfig = new SecondaryConfig();
startsConfig.setAllowCreate(true);
startsConfig.setSortedDuplicates(true);
startsConfig.setAllowPopulate(true);
startsConfig.setKeyCreator(new StartsKeyCreator());
// Create secondary database for indexing Ends
endsConfig = new SecondaryConfig();
endsConfig.setAllowCreate(true);
endsConfig.setSortedDuplicates(true);
endsConfig.setAllowPopulate(true);
endsConfig.setKeyCreator(new EndsKeyCreator());
initialized = true;
}
Aggregations