use of org.apache.bookkeeper.stream.proto.kv.store.CheckpointMetadata in project bookkeeper by apache.
the class RocksCheckpointerTest method testRestoreCleanupCheckpoints.
@Test
public void testRestoreCleanupCheckpoints() throws Exception {
// create 3 checkpoints and leave them locally
List<String> checkpointIds = createMultipleCheckpoints(3, false, false);
store.close();
List<String> remoteCheckpoints = checkpointStore.listFiles(RocksUtils.getDestCheckpointsPath(store.name()));
assertEquals(checkpointIds.size(), remoteCheckpoints.size());
for (String checkpoint : checkpointIds) {
assertTrue(remoteCheckpoints.contains(checkpoint));
assertTrue(new File(localCheckpointsDir, checkpoint).exists());
}
// restore from checkpoints
CheckpointMetadata metadata = RocksCheckpointer.restore(store.name(), localDir, checkpointStore);
assertNotNull(metadata);
assertArrayEquals("checkpoint-2".getBytes(UTF_8), metadata.getTxid().toByteArray());
for (int i = 0; i < 3; i++) {
String checkpoint = checkpointIds.get(i);
if (i == 2) {
assertTrue(new File(localCheckpointsDir, checkpoint).exists());
} else {
assertFalse(new File(localCheckpointsDir, checkpoint).exists());
}
assertTrue(checkpointStore.fileExists(RocksUtils.getDestCheckpointPath(store.name(), checkpoint)));
}
// restore from the latest checkpoint
store = new RocksdbKVStore<>();
store.init(spec);
verifyNumKvs(300);
}
Aggregations