Search in sources :

Example 1 with MyPdxSerializer

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

the class ParallelSnapshotDUnitTest method loadCache.

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

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
            Cache cache = getCache(cf);
            RegionGenerator rgen = new RegionGenerator();
            rgen.createRegion(cache, null, RegionType.PARTITION, "test");
            return null;
        }
    };
    forEachVm(setup, true);
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache)

Example 2 with MyPdxSerializer

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

the class SnapshotByteArrayDUnitTest 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);
            RegionGenerator rgen = new RegionGenerator();
            rgen.createRegion(cache, null, RegionType.REPLICATE, "snapshot-ops");
            return null;
        }
    };
    SnapshotDUnitTest.forEachVm(setup, true);
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache)

Example 3 with MyPdxSerializer

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

the class SnapshotPerformanceDUnitTest method createCache.

private void createCache() throws Exception {
    SerializableCallable setup = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
            getCache(cf);
            return null;
        }
    };
    SnapshotDUnitTest.forEachVm(setup, true);
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) CacheFactory(org.apache.geode.cache.CacheFactory)

Example 4 with MyPdxSerializer

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

the class PdxTypeExportDUnitTest method loadCache.

@SuppressWarnings("serial")
public void loadCache() throws Exception {
    SerializableCallable peer = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
            Cache cache = getCache(cf);
            Region r = cache.createRegionFactory(RegionShortcut.REPLICATE).create("pdxtest");
            r.put(1, new MyObjectPdx(1, "test", MyEnumPdx.const1));
            return null;
        }
    };
    final Host host = Host.getHost(0);
    host.getVM(1).invoke(peer);
    SerializableCallable server = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
            CacheServer server = getCache().addCacheServer();
            int port = AvailablePortHelper.getRandomAvailableTCPPort();
            server.setPort(port);
            server.start();
            Region r = getCache().createRegionFactory(RegionShortcut.REPLICATE).create("pdxtest");
            return port;
        }
    };
    final int port = (Integer) host.getVM(2).invoke(server);
    SerializableCallable client = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory().setPdxSerializer(new MyPdxSerializer()).addPoolServer(NetworkUtils.getServerHostName(host), port);
            ClientCache cache = getClientCache(cf);
            Region r = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("pdxtest");
            return null;
        }
    };
    host.getVM(3).invoke(client);
    peer.call();
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) MyObjectPdx(com.examples.snapshot.MyObjectPdx) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) CacheServer(org.apache.geode.cache.server.CacheServer) Host(org.apache.geode.test.dunit.Host) ClientCache(org.apache.geode.cache.client.ClientCache) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 5 with MyPdxSerializer

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

the class ClientSnapshotDUnitTest method loadCache.

@SuppressWarnings("serial")
public void loadCache() throws Exception {
    CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
    Cache cache = getCache(cf);
    CacheServer server = cache.addCacheServer();
    final int port = AvailablePortHelper.getRandomAvailableTCPPort();
    server.setPort(port);
    server.start();
    region = cache.<Integer, MyObject>createRegionFactory(RegionShortcut.REPLICATE).create("clienttest");
    final Host host = Host.getHost(0);
    SerializableCallable client = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory().set(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel()).setPdxSerializer(new MyPdxSerializer()).addPoolServer(NetworkUtils.getServerHostName(host), port).setPoolSubscriptionEnabled(true).setPoolPRSingleHopEnabled(false);
            ClientCache cache = getClientCache(cf);
            Region r = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU).setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(5)).create("clienttest");
            return null;
        }
    };
    SerializableCallable remote = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
            Cache cache = getCache(cf);
            cache.<Integer, MyObject>createRegionFactory(RegionShortcut.REPLICATE).create("clienttest");
            return null;
        }
    };
    host.getVM(3).invoke(client);
    host.getVM(2).invoke(remote);
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) CacheServer(org.apache.geode.cache.server.CacheServer) MyObject(com.examples.snapshot.MyObject) Region(org.apache.geode.cache.Region) Host(org.apache.geode.test.dunit.Host) ClientCache(org.apache.geode.cache.client.ClientCache) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

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