Search in sources :

Example 1 with DelayedAction

use of org.apache.geode.internal.util.DelayedAction in project geode by apache.

the class Bug45934DUnitTest method testNormal.

@Test
public void testNormal() throws Exception {
    int count = 1000;
    Host host = Host.getHost(0);
    final VM remote = host.getVM(1);
    final String name = getName();
    // 0. create the remote region, set error flag
    createRemoteRegion(remote, name);
    // 1. create the local cache
    CacheFactory cf = new CacheFactory();
    cf.set(MCAST_PORT, "45934");
    cf.set(CONSERVE_SOCKETS, "false");
    Cache cache = getCache(cf);
    // 2. create normal region locally
    RegionFactory<Integer, Integer> rf = cache.<Integer, Integer>createRegionFactory();
    rf.setDataPolicy(DataPolicy.NORMAL);
    rf.setScope(Scope.DISTRIBUTED_ACK);
    Region<Integer, Integer> region = rf.create(name);
    // 3. reset the error flag after initial failure
    DistributedCacheOperation.test_InvalidVersionAction = new DelayedAction(new Runnable() {

        @Override
        public void run() {
            unsetRemoteFlag(remote);
        }
    });
    DistributedCacheOperation.test_InvalidVersionAction.allowToProceed();
    // 3. put data
    Map<Integer, Integer> values = new HashMap<Integer, Integer>();
    for (int i = 0; i < count; i++) {
        values.put(i, i);
    }
    region.putAll(values);
    // 5. double check
    verifyLocal(region, count);
    verify(remote, name, count);
    cache.close();
}
Also used : HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) CacheFactory(org.apache.geode.cache.CacheFactory) DelayedAction(org.apache.geode.internal.util.DelayedAction) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

HashMap (java.util.HashMap)1 Cache (org.apache.geode.cache.Cache)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 DelayedAction (org.apache.geode.internal.util.DelayedAction)1 Host (org.apache.geode.test.dunit.Host)1 VM (org.apache.geode.test.dunit.VM)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1