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);
}
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);
}
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);
}
}
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());
}
}
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");
}
}
Aggregations