* to clear, then read again.
*/
StatsConfig statsConfig = new StatsConfig();
statsConfig.setFast(true);
statsConfig.setClear(true);
EnvironmentStats stats = env.getStats(statsConfig); // clear stats
stats = env.getStats(statsConfig); // read again
assertEquals(0, stats.getNCheckpoints());
/*
* From the last checkpoint start LSN, there should be the
* checkpoint end log entry and a trace message. These take 196
* bytes.
*/
CheckpointConfig checkpointConfig = new CheckpointConfig();
/* Should not cause a checkpoint, too little growth. */
checkpointConfig.setKBytes(1);
env.checkpoint(checkpointConfig);
stats = env.getStats(statsConfig); // read again
assertEquals(0, stats.getNCheckpoints());
/* Fill up the log, there should be a checkpoint. */
String filler = "123456789012345678901245678901234567890123456789";
EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
for (int i = 0; i < 20; i++) {
Tracer.trace(Level.SEVERE, envImpl, filler);
}
env.checkpoint(checkpointConfig);
stats = env.getStats(statsConfig); // read again
assertEquals(1, stats.getNCheckpoints());
/* Try time based, should not checkpoint. */
checkpointConfig.setKBytes(0);
checkpointConfig.setMinutes(1);
env.checkpoint(checkpointConfig);
stats = env.getStats(statsConfig); // read again
assertEquals(0, stats.getNCheckpoints());
/*
* Sleep, enough time has passed for a checkpoint, but nothing was
* written to the log.
*/
Thread.sleep(1000);
env.checkpoint(checkpointConfig);
stats = env.getStats(statsConfig); // read again
assertEquals(0, stats.getNCheckpoints());
/* Log something, now try a checkpoint. */
Tracer.trace(Level.SEVERE, envImpl, filler);
env.checkpoint(checkpointConfig);
stats = env.getStats(statsConfig); // read again