use of com.sleepycat.je.Environment 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.Environment in project qpid-broker-j by apache.
the class UpgradeFrom5To6Test method testPerformXidUpgrade.
@Test
public void testPerformXidUpgrade() throws Exception {
File storeLocation = new File(TMP_FOLDER, getTestName());
storeLocation.mkdirs();
Environment environment = createEnvironment(storeLocation);
try {
populateOldXidEntries(environment);
UpgradeFrom5To6 upgrade = new UpgradeFrom5To6();
upgrade.performUpgrade(environment, UpgradeInteractionHandler.DEFAULT_HANDLER, getVirtualHost());
assertXidEntries(environment);
} finally {
try {
environment.close();
} finally {
deleteDirectoryIfExists(storeLocation);
}
}
}
use of com.sleepycat.je.Environment in project qpid-broker-j by apache.
the class UpgraderTest method testEmptyDatabaseUpgradeDoesNothing.
@Test
public void testEmptyDatabaseUpgradeDoesNothing() throws Exception {
File nonExistentStoreLocation = new File(TMP_FOLDER, getTestName());
deleteDirectoryIfExists(nonExistentStoreLocation);
nonExistentStoreLocation.mkdir();
Environment emptyEnvironment = createEnvironment(nonExistentStoreLocation);
try {
_upgrader = new Upgrader(emptyEnvironment, getVirtualHost());
_upgrader.upgradeIfNecessary();
List<String> databaseNames = emptyEnvironment.getDatabaseNames();
List<String> expectedDatabases = new ArrayList<String>();
expectedDatabases.add(Upgrader.VERSION_DB_NAME);
assertEquals("Expectedonly VERSION table in initially empty store after upgrade: ", expectedDatabases, databaseNames);
assertEquals("Unexpected store version", BDBConfigurationStore.VERSION, getStoreVersion(emptyEnvironment));
} finally {
emptyEnvironment.close();
nonExistentStoreLocation.delete();
}
}
use of com.sleepycat.je.Environment 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.Environment 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.");
}
}
}
}
Aggregations