use of com.sleepycat.je.DatabaseConfig in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method openTable.
public boolean openTable(DatabaseSession databaseSession, String tableName, boolean transactional) throws BimserverDatabaseException {
if (tables.containsKey(tableName)) {
throw new BimserverDatabaseException("Table " + tableName + " already opened");
}
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(false);
boolean finalTransactional = transactional && useTransactions;
// if (!transactional) {
// databaseConfig.setCacheMode(CacheMode.EVICT_BIN);
// }
databaseConfig.setDeferredWrite(!finalTransactional);
databaseConfig.setTransactional(finalTransactional);
databaseConfig.setSortedDuplicates(false);
Database database = environment.openDatabase(null, tableName, databaseConfig);
if (database == null) {
throw new BimserverDatabaseException("Table " + tableName + " not found in database");
}
tables.put(tableName, new TableWrapper(database, finalTransactional));
return true;
}
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.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 qpid-broker-j by apache.
the class AbstractBDBPreferenceStore method getPreferencesVersionDb.
private Database getPreferencesVersionDb() {
Database preferencesVersionDb;
try {
DatabaseConfig config = new DatabaseConfig().setTransactional(true).setAllowCreate(false);
preferencesVersionDb = getEnvironmentFacade().openDatabase(PREFERENCES_VERSION_DB_NAME, config);
} catch (DatabaseNotFoundException e) {
preferencesVersionDb = updateVersion(null, BrokerModel.MODEL_VERSION);
}
return preferencesVersionDb;
}
use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method testOpenDatabaseReusesCachedHandle.
public void testOpenDatabaseReusesCachedHandle() throws Exception {
DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true);
EnvironmentFacade ef = createMaster();
Database handle1 = ef.openDatabase("myDatabase", createIfAbsentDbConfig);
assertNotNull(handle1);
Database handle2 = ef.openDatabase("myDatabase", createIfAbsentDbConfig);
assertSame("Database handle should be cached", handle1, handle2);
ef.closeDatabase("myDatabase");
Database handle3 = ef.openDatabase("myDatabase", createIfAbsentDbConfig);
assertNotSame("Expecting a new handle after database closure", handle1, handle3);
}
use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class UpgraderTest method getStoreVersion.
private int getStoreVersion(Environment environment) {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
int storeVersion = -1;
Database versionDb = null;
Cursor cursor = null;
try {
versionDb = environment.openDatabase(null, Upgrader.VERSION_DB_NAME, dbConfig);
cursor = versionDb.openCursor(null, null);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS) {
int version = IntegerBinding.entryToInt(key);
if (storeVersion < version) {
storeVersion = version;
}
}
} finally {
if (cursor != null) {
cursor.close();
}
if (versionDb != null) {
versionDb.close();
}
}
return storeVersion;
}
Aggregations