envConfig.setAllowCreate(true);
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
Environment env = new Environment(envHome, envConfig);
EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
FileManager fileManager =
DbInternal.envGetEnvironmentImpl(env).getFileManager();
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
Database db1 =
env.openDatabase(null, "db1", dbConfig);
Database db2 =
env.openDatabase(null, "db2", dbConfig);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
IntegerBinding.intToEntry(1, key);
data.setData(new byte[100000]);
for (int i = 0; i < 50; i++) {
assertEquals(OperationStatus.SUCCESS, db2.put(null, key, data));
}
db1.close();
db2.close();
assertEquals("Should have 0 as current file", 0L,
fileManager.getCurrentFileNum());
envImpl.forceLogFileFlip();
env.close();
env = new Environment(envHome, envConfig);
fileManager = DbInternal.envGetEnvironmentImpl(env).getFileManager();
assertEquals("Should have 1 as current file", 1L,
fileManager.getCurrentFileNum());
db2 = env.openDatabase(null, "db2", dbConfig);
for (int i = 0; i < 250; i++) {
assertEquals(OperationStatus.SUCCESS, db2.put(null, key, data));