use of org.apache.geode.internal.cache.persistence.RestoreScript in project geode by apache.
the class BackupJUnitTest method testCompactionDuringBackup.
@Test
public void testCompactionDuringBackup() throws IOException, InterruptedException {
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(diskDirs);
dsf.setMaxOplogSize(1);
dsf.setAutoCompact(false);
dsf.setAllowForceCompaction(true);
dsf.setCompactionThreshold(20);
String name = "diskStore";
DiskStoreImpl ds = (DiskStoreImpl) dsf.create(name);
Region region = createRegion();
// Put enough data to roll some oplogs
for (int i = 0; i < 1024; i++) {
region.put(i, getBytes(i));
}
RestoreScript script = new RestoreScript();
ds.startBackup(backupDir, null, script);
for (int i = 2; i < 1024; i++) {
assertTrue(region.destroy(i) != null);
}
assertTrue(ds.forceCompaction());
// Put another key to make sure we restore
// from a backup that doesn't contain this key
region.put("A", "A");
ds.finishBackup(new BackupManager(cache.getInternalDistributedSystem().getDistributedMember(), cache));
script.generate(backupDir);
cache.close();
destroyDiskDirs();
restoreBackup(false);
createCache();
ds = createDiskStore();
region = createRegion();
validateEntriesExist(region, 0, 1024);
assertNull(region.get("A"));
}
Aggregations