use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class Upgrader method upgradeIfNecessary.
public void upgradeIfNecessary() {
boolean isEmpty = _environment.getDatabaseNames().isEmpty();
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
Database versionDb = null;
try {
versionDb = _environment.openDatabase(null, VERSION_DB_NAME, dbConfig);
if (versionDb.count() == 0L) {
int sourceVersion = isEmpty ? BDBConfigurationStore.VERSION : identifyOldStoreVersion();
DatabaseEntry key = new DatabaseEntry();
IntegerBinding.intToEntry(sourceVersion, key);
DatabaseEntry value = new DatabaseEntry();
LongBinding.longToEntry(System.currentTimeMillis(), value);
versionDb.put(null, key, value);
}
int version = getSourceVersion(versionDb);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Source message store version is " + version);
}
if (version > BDBConfigurationStore.VERSION) {
throw new StoreException("Database version " + version + " is higher than the most recent known version: " + BDBConfigurationStore.VERSION);
}
performUpgradeFromVersion(version, versionDb);
} finally {
if (versionDb != null) {
versionDb.close();
}
}
}
use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class DatabaseTemplate method call.
public <T> T call(DatabaseCallable<T> databaseCallable) {
Database sourceDatabase = null;
Database targetDatabase = null;
try {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
sourceDatabase = _environment.openDatabase(_parentTransaction, _sourceDatabaseName, dbConfig);
if (_targetDatabaseName != null) {
targetDatabase = _environment.openDatabase(_parentTransaction, _targetDatabaseName, dbConfig);
}
return databaseCallable.call(sourceDatabase, targetDatabase, _parentTransaction);
} finally {
closeDatabase(sourceDatabase);
closeDatabase(targetDatabase);
}
}
use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class UpgradeFrom6To7 method performUpgrade.
@Override
public void performUpgrade(Environment environment, UpgradeInteractionHandler handler, ConfiguredObject<?> parent) {
reportStarting(environment, 6);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
Database versionDb = environment.openDatabase(null, "CONFIG_VERSION", dbConfig);
if (versionDb.count() == 0L) {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
IntegerBinding.intToEntry(DEFAULT_CONFIG_VERSION, value);
ByteBinding.byteToEntry((byte) 0, key);
OperationStatus status = versionDb.put(null, key, value);
if (status != OperationStatus.SUCCESS) {
throw new StoreException("Error initialising config version: " + status);
}
}
versionDb.close();
reportFinished(environment, 7);
}
use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method testOpenDatabaseWhenFacadeIsNotOpened.
@Test
public void testOpenDatabaseWhenFacadeIsNotOpened() throws Exception {
DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true);
EnvironmentFacade ef = createMaster();
ef.close();
try {
ef.openDatabase("myDatabase", createIfAbsentDbConfig);
fail("Database open should fail");
} catch (ConnectionScopedRuntimeException e) {
assertEquals("Unexpected exception", "Environment facade is not in opened state", e.getMessage());
}
}
use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method createDatabaseConfig.
private DatabaseConfig createDatabaseConfig() {
final DatabaseConfig createConfig = new DatabaseConfig();
createConfig.setAllowCreate(true);
createConfig.setTransactional(true);
return createConfig;
}
Aggregations