Search in sources :

Example 66 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class InterestListRecoveryDUnitTest method verifyRegionToProxyMapForNoRegistrationRetry.

public static void verifyRegionToProxyMapForNoRegistrationRetry() {
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            try {
                verifyRegionToProxyMapForNoRegistration();
                return true;
            } catch (VirtualMachineError e) {
                SystemFailure.initiateFailure(e);
                throw e;
            } catch (Error e) {
                return false;
            } catch (RuntimeException re) {
                return false;
            }
        }

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 20 * 1000, 200, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 67 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class InterestListRecoveryDUnitTest method verifyRegionToProxyMapForFullRegistrationRetry.

public static void verifyRegionToProxyMapForFullRegistrationRetry() {
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            try {
                verifyRegionToProxyMapForFullRegistration();
                return true;
            } catch (VirtualMachineError e) {
                SystemFailure.initiateFailure(e);
                throw e;
            } catch (Error e) {
                return false;
            } catch (RuntimeException re) {
                return false;
            }
        }

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 20 * 1000, 200, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 68 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class InterestListDUnitTest method flushQueues.

/** wait for queues to drain in the server */
private static void flushQueues() throws Exception {
    CacheServerImpl impl = (CacheServerImpl) server;
    for (CacheClientProxy proxy : (Set<CacheClientProxy>) impl.getAllClientSessions()) {
        final CacheClientProxy fproxy = proxy;
        WaitCriterion ev = new WaitCriterion() {

            @Override
            public boolean done() {
                return fproxy.getHARegionQueue().size() == 0;
            }

            @Override
            public String description() {
                return "waiting for queues to drain for " + fproxy.getProxyID();
            }
        };
        Wait.waitForCriterion(ev, 5 * 10 * 1000, 200, true);
    }
}
Also used : Set(java.util.Set) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl)

Example 69 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class MyGatewayEventSubstitutionFilter method validateCustomAsyncEventListener.

public static void validateCustomAsyncEventListener(String asyncQueueId, final int expectedSize) {
    AsyncEventListener theListener = null;
    Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
    for (AsyncEventQueue asyncQueue : asyncEventQueues) {
        if (asyncQueueId.equals(asyncQueue.getId())) {
            theListener = asyncQueue.getAsyncEventListener();
        }
    }
    final Map eventsMap = ((CustomAsyncEventListener) theListener).getEventsMap();
    assertNotNull(eventsMap);
    WaitCriterion wc = new WaitCriterion() {

        public boolean done() {
            if (eventsMap.size() == expectedSize) {
                return true;
            }
            return false;
        }

        public String description() {
            return "Expected map entries: " + expectedSize + " but actual entries: " + eventsMap.size();
        }
    };
    // TODO:Yogs
    Wait.waitForCriterion(wc, 60000, 500, true);
    Iterator<AsyncEvent> itr = eventsMap.values().iterator();
    while (itr.hasNext()) {
        AsyncEvent event = itr.next();
        assertTrue("possibleDuplicate should be true for event: " + event, event.getPossibleDuplicate());
    }
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) AsyncEvent(org.apache.geode.cache.asyncqueue.AsyncEvent) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 70 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class MyGatewayEventSubstitutionFilter method waitForAsyncEventQueueSize.

/**
   * This method verifies the queue size of a ParallelGatewaySender. For ParallelGatewaySender
   * conflation happens in a separate thread, hence test code needs to wait for some time for
   * expected result
   * 
   * @param asyncQueueId Async Queue ID
   * @param numQueueEntries expected number of Queue entries
   * @throws Exception
   */
public static void waitForAsyncEventQueueSize(String asyncQueueId, final int numQueueEntries) throws Exception {
    AsyncEventQueue theAsyncEventQueue = null;
    Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
    for (AsyncEventQueue asyncChannel : asyncEventChannels) {
        if (asyncQueueId.equals(asyncChannel.getId())) {
            theAsyncEventQueue = asyncChannel;
        }
    }
    GatewaySender sender = ((AsyncEventQueueImpl) theAsyncEventQueue).getSender();
    if (sender.isParallel()) {
        final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        Wait.waitForCriterion(new WaitCriterion() {

            public String description() {
                return "Waiting for EventQueue size to be " + numQueueEntries;
            }

            public boolean done() {
                boolean done = numQueueEntries == queues.toArray(new RegionQueue[queues.size()])[0].getRegion().size();
                return done;
            }
        }, MAX_WAIT, 500, true);
    } else {
        throw new Exception("This method should be used for only ParallelGatewaySender,SerialGatewaySender should use checkAsyncEventQueueSize() method instead");
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) AsyncEventQueueImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl) RegionQueue(org.apache.geode.internal.cache.RegionQueue) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) IOException(java.io.IOException)

Aggregations

WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)368 Test (org.junit.Test)132 Region (org.apache.geode.cache.Region)105 VM (org.apache.geode.test.dunit.VM)96 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)93 Host (org.apache.geode.test.dunit.Host)73 LocalRegion (org.apache.geode.internal.cache.LocalRegion)58 CacheException (org.apache.geode.cache.CacheException)57 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)53 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)50 AttributesFactory (org.apache.geode.cache.AttributesFactory)41 IgnoredException (org.apache.geode.test.dunit.IgnoredException)40 IOException (java.io.IOException)36 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)36 Cache (org.apache.geode.cache.Cache)34 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)34 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)33 Properties (java.util.Properties)31 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)28 Iterator (java.util.Iterator)27