use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createAsyncEventQueueWithListener2.
public static void createAsyncEventQueueWithListener2(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) {
createDiskStore(asyncChannelId, diskStoreName);
AsyncEventListener asyncEventListener = new MyAsyncEventListener2();
AsyncEventQueueFactory factory = getInitialAsyncEventQueueFactory(isParallel, maxMemory, batchSize, isPersistent, diskStoreName);
// set dispatcher threads
factory.setDispatcherThreads(numDispatcherThreadsForTheRun);
AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener);
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method pauseAsyncEventQueueAndWaitForDispatcherToPause.
public static void pauseAsyncEventQueueAndWaitForDispatcherToPause(String asyncChannelId) {
AsyncEventQueue theChannel = null;
Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncChannel : asyncEventChannels) {
if (asyncChannelId.equals(asyncChannel.getId())) {
theChannel = asyncChannel;
break;
}
}
((AsyncEventQueueImpl) theChannel).getSender().pause();
((AbstractGatewaySender) ((AsyncEventQueueImpl) theChannel).getSender()).getEventProcessor().waitForDispatcherToPause();
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method getAsyncEventQueueSize.
public static int getAsyncEventQueueSize(String asyncEventQueueId) {
AsyncEventQueue theQueue = null;
Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncQueue : asyncEventQueues) {
if (asyncEventQueueId.equals(asyncQueue.getId())) {
theQueue = asyncQueue;
}
}
assertNotNull(theQueue);
return theQueue.size();
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class AsyncEventQueueValidationsJUnitTest method testAsyncEventQueueConfiguredFromXmlUsesFilter.
@Test
@Parameters(method = "getCacheXmlFileBaseNames")
public void testAsyncEventQueueConfiguredFromXmlUsesFilter(String cacheXmlFileBaseName) {
// Create cache with xml
String cacheXmlFileName = TestUtil.getResourcePath(getClass(), getClass().getSimpleName() + "." + cacheXmlFileBaseName + ".cache.xml");
cache = new CacheFactory().set(MCAST_PORT, "0").set(CACHE_XML_FILE, cacheXmlFileName).create();
// Get region and do puts
Region region = cache.getRegion(cacheXmlFileBaseName);
int numPuts = 10;
for (int i = 0; i < numPuts; i++) {
region.put(i, i);
}
// Get AsyncEventQueue and GatewayEventFilter
AsyncEventQueue aeq = cache.getAsyncEventQueue(cacheXmlFileBaseName);
List<GatewayEventFilter> filters = aeq.getGatewayEventFilters();
assertTrue(filters.size() == 1);
MyGatewayEventFilter filter = (MyGatewayEventFilter) filters.get(0);
// Validate filter callbacks were invoked
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> filter.getBeforeEnqueueInvocations() == numPuts);
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> filter.getBeforeTransmitInvocations() == numPuts);
Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> filter.getAfterAcknowledgementInvocations() == numPuts);
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method validateAsyncEventListener.
public static void validateAsyncEventListener(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 = ((MyAsyncEventListener) 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);
}
Aggregations