Search in sources :

Example 1 with RestoreScript

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"));
}
Also used : Region(org.apache.geode.cache.Region) RestoreScript(org.apache.geode.internal.cache.persistence.RestoreScript) BackupManager(org.apache.geode.internal.cache.persistence.BackupManager) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)1 Region (org.apache.geode.cache.Region)1 BackupManager (org.apache.geode.internal.cache.persistence.BackupManager)1 RestoreScript (org.apache.geode.internal.cache.persistence.RestoreScript)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1