Search in sources :

Example 6 with MyPdxSerializer

use of com.examples.snapshot.MyPdxSerializer in project geode by apache.

the class SnapshotDUnitTest method loadCache.

public void loadCache() throws Exception {
    SerializableCallable setup = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer()).setPdxPersistent(true);
            Cache cache = getCache(cf);
            DiskStore ds = cache.createDiskStoreFactory().setMaxOplogSize(1).setDiskDirs(getDiskDirs()).create("snapshotTest");
            RegionGenerator rgen = new RegionGenerator();
            for (final RegionType rt : RegionType.values()) {
                for (final SerializationType st : SerializationType.values()) {
                    rgen.createRegion(cache, ds.getName(), rt, "test-" + rt.name() + "-" + st.name());
                }
            }
            return null;
        }
    };
    forEachVm(setup, true);
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) DiskStore(org.apache.geode.cache.DiskStore) RegionType(org.apache.geode.cache.snapshot.RegionGenerator.RegionType) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache) SerializationType(org.apache.geode.cache.snapshot.RegionGenerator.SerializationType)

Example 7 with MyPdxSerializer

use of com.examples.snapshot.MyPdxSerializer 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)

Example 8 with MyPdxSerializer

use of com.examples.snapshot.MyPdxSerializer in project geode by apache.

the class OfflineSnapshotJUnitTest method reset.

private void reset() {
    CacheFactory cf = new CacheFactory().set(MCAST_PORT, "0").set(LOG_LEVEL, "error").setPdxSerializer(new MyPdxSerializer()).setPdxPersistent(true);
    cache = cf.create();
    ds = cache.createDiskStoreFactory().setMaxOplogSize(1).create("snapshotTest");
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) CacheFactory(org.apache.geode.cache.CacheFactory)

Aggregations

MyPdxSerializer (com.examples.snapshot.MyPdxSerializer)8 CacheFactory (org.apache.geode.cache.CacheFactory)8 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)6 Cache (org.apache.geode.cache.Cache)5 MyObject (com.examples.snapshot.MyObject)2 Region (org.apache.geode.cache.Region)2 ClientCache (org.apache.geode.cache.client.ClientCache)2 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)2 CacheServer (org.apache.geode.cache.server.CacheServer)2 RegionType (org.apache.geode.cache.snapshot.RegionGenerator.RegionType)2 SerializationType (org.apache.geode.cache.snapshot.RegionGenerator.SerializationType)2 Host (org.apache.geode.test.dunit.Host)2 MyObjectPdx (com.examples.snapshot.MyObjectPdx)1 HashMap (java.util.HashMap)1 DiskStore (org.apache.geode.cache.DiskStore)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1