use of org.apache.geode.cache.snapshot.RegionGenerator.RegionType in project geode by apache.
the class RegionSnapshotJUnitTest method testDSID.
@Test
public void testDSID() throws Exception {
cache.close();
CacheFactory cf = new CacheFactory().set(MCAST_PORT, "0").set(LOG_LEVEL, "error").setPdxSerializer(new MyPdxSerializer()).set(DISTRIBUTED_SYSTEM_ID, "1");
cache = cf.create();
RegionType rt = RegionType.REPLICATE;
SerializationType st = SerializationType.PDX_SERIALIZER;
String name = "test-" + rt.name() + "-" + st.name() + "-dsid";
Region<Integer, MyObject> region = rgen.createRegion(cache, ds.getName(), rt, name);
final Map<Integer, MyObject> expected = createExpected(st);
region.putAll(expected);
region.getSnapshotService().save(f, SnapshotFormat.GEMFIRE);
cache.close();
// change the DSID from 1 -> 100
CacheFactory cf2 = new CacheFactory().set(MCAST_PORT, "0").set(LOG_LEVEL, "error").setPdxSerializer(new MyPdxSerializer()).set(DISTRIBUTED_SYSTEM_ID, "100");
cache = cf2.create();
final Map<Integer, Object> read = new HashMap<Integer, Object>();
SnapshotIterator<Integer, Object> iter = SnapshotReader.read(f);
try {
while (iter.hasNext()) {
Entry<Integer, Object> entry = iter.next();
read.put(entry.getKey(), entry.getValue());
}
assertEquals("Comparison failure for " + rt.name() + "/" + st.name(), expected, read);
} finally {
iter.close();
}
}
Aggregations