Search in sources :

Example 16 with RegionType

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();
    }
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) RegionType(org.apache.geode.cache.snapshot.RegionGenerator.RegionType) HashMap(java.util.HashMap) MyObject(com.examples.snapshot.MyObject) MyObject(com.examples.snapshot.MyObject) CacheFactory(org.apache.geode.cache.CacheFactory) SerializationType(org.apache.geode.cache.snapshot.RegionGenerator.SerializationType) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

RegionType (org.apache.geode.cache.snapshot.RegionGenerator.RegionType)16 SerializationType (org.apache.geode.cache.snapshot.RegionGenerator.SerializationType)16 MyObject (com.examples.snapshot.MyObject)15 Test (org.junit.Test)11 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 File (java.io.File)4 Entry (java.util.Map.Entry)4 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)4 Cache (org.apache.geode.cache.Cache)3 MyPdxSerializer (com.examples.snapshot.MyPdxSerializer)2 HashMap (java.util.HashMap)2 CacheFactory (org.apache.geode.cache.CacheFactory)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2 FileFilter (java.io.FileFilter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AttributesMutator (org.apache.geode.cache.AttributesMutator)1 DiskStore (org.apache.geode.cache.DiskStore)1