Search in sources :

Example 1 with SnapshotOptionsImpl

use of org.apache.geode.internal.cache.snapshot.SnapshotOptionsImpl in project geode by apache.

the class ParallelSnapshotDUnitTest method doExport.

private void doExport(boolean explode) throws Exception {
    Region region = getCache().getRegion("test");
    for (int i = 0; i < 1000; i++) {
        region.put(i, ffff);
    }
    RegionSnapshotService rss = region.getSnapshotService();
    final TestSnapshotFileMapper mapper = new TestSnapshotFileMapper();
    mapper.explode = explode;
    SnapshotOptionsImpl opt = (SnapshotOptionsImpl) rss.createOptions();
    opt.setParallelMode(true);
    opt.setMapper(mapper);
    final File f = new File("mysnap");
    rss.save(f, SnapshotFormat.GEMFIRE, opt);
    mapper.explode = false;
    SerializableCallable check = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            getCache().getDistributedSystem().getDistributedMember();
            File snap = mapper.mapExportPath(getCache().getDistributedSystem().getDistributedMember(), f);
            assertTrue("Could not find snapshot: " + snap, snap.exists());
            return null;
        }
    };
    forEachVm(check, true);
}
Also used : SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) SnapshotOptionsImpl(org.apache.geode.internal.cache.snapshot.SnapshotOptionsImpl) File(java.io.File)

Example 2 with SnapshotOptionsImpl

use of org.apache.geode.internal.cache.snapshot.SnapshotOptionsImpl in project geode by apache.

the class ParallelSnapshotDUnitTest method doImport.

private void doImport(boolean explode) throws ClassNotFoundException, IOException {
    Region region = getCache().getRegion("test");
    RegionSnapshotService rss = region.getSnapshotService();
    final TestSnapshotFileMapper mapper = new TestSnapshotFileMapper();
    mapper.explode = explode;
    SnapshotOptionsImpl opt = (SnapshotOptionsImpl) rss.createOptions();
    opt.setParallelMode(true);
    opt.setMapper(mapper);
    final File f = new File("mysnap");
    for (int i = 0; i < 1000; i++) {
        region.put(i, eeee);
    }
    rss.load(f, SnapshotFormat.GEMFIRE, opt);
    for (int i = 0; i < 1000; i++) {
        assertTrue(Arrays.equals(ffff, (byte[]) region.get(i)));
    }
}
Also used : Region(org.apache.geode.cache.Region) SnapshotOptionsImpl(org.apache.geode.internal.cache.snapshot.SnapshotOptionsImpl) File(java.io.File)

Aggregations

File (java.io.File)2 Region (org.apache.geode.cache.Region)2 SnapshotOptionsImpl (org.apache.geode.internal.cache.snapshot.SnapshotOptionsImpl)2 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)1