use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createAsyncEventQueue.
public static void createAsyncEventQueue(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, String diskStoreName, boolean isDiskSynchronous, String asyncListenerClass, String substitutionFilterClass) throws Exception {
createDiskStore(asyncChannelId, diskStoreName);
AsyncEventQueueFactory factory = getInitialAsyncEventQueueFactory(isParallel, maxMemory, batchSize, isPersistent, diskStoreName);
factory.setDiskSynchronous(isDiskSynchronous);
factory.setBatchConflationEnabled(isConflation);
if (substitutionFilterClass != null) {
factory.setGatewayEventSubstitutionListener((GatewayEventSubstitutionFilter) getClass(substitutionFilterClass).newInstance());
}
// set dispatcher threads
factory.setDispatcherThreads(numDispatcherThreadsForTheRun);
AsyncEventQueue asyncChannel = factory.create(asyncChannelId, (AsyncEventListener) getClass(asyncListenerClass).newInstance());
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method checkAsyncEventQueueStats.
public static void checkAsyncEventQueueStats(String queueId, final int queueSize, final int eventsReceived, final int eventsQueued, final int eventsDistributed) {
Set<AsyncEventQueue> asyncQueues = cache.getAsyncEventQueues();
AsyncEventQueue queue = null;
for (AsyncEventQueue q : asyncQueues) {
if (q.getId().equals(queueId)) {
queue = q;
break;
}
}
final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl) queue).getStatistics();
assertEquals(queueSize, statistics.getEventQueueSize());
assertEquals(eventsReceived, statistics.getEventsReceived());
assertEquals(eventsQueued, statistics.getEventsQueued());
assert (statistics.getEventsDistributed() >= eventsDistributed);
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method checkAsyncEventQueueBatchStats.
public static void checkAsyncEventQueueBatchStats(String asyncQueueId, final int batches) {
Set<AsyncEventQueue> queues = cache.getAsyncEventQueues();
AsyncEventQueue queue = null;
for (AsyncEventQueue q : queues) {
if (q.getId().equals(asyncQueueId)) {
queue = q;
break;
}
}
final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl) queue).getStatistics();
assert (statistics.getBatchesDistributed() >= batches);
assertEquals(0, statistics.getBatchesRedistributed());
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class CacheXml70DUnitTest method testAsyncEventQueueWithGatewayEventFilter.
/**
* Added to test the scenario of defect #50600.
*/
@Test
public void testAsyncEventQueueWithGatewayEventFilter() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
String id = "WBCLChannel";
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
factory.setBatchSize(100);
factory.setBatchTimeInterval(500);
factory.setBatchConflationEnabled(true);
factory.setMaximumQueueMemory(200);
factory.setDiskSynchronous(true);
factory.setParallel(false);
factory.setDispatcherThreads(33);
AsyncEventListener eventListener = new MyAsyncEventListener();
AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
RegionAttributesCreation attrs = new RegionAttributesCreation();
attrs.addAsyncEventQueueId(asyncEventQueue.getId());
cache.createRegion("UserRegion", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
CacheXml70DUnitTest.validateAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class CacheXml70DUnitTest method testConcurrentAsyncEventQueue.
@Test
public void testConcurrentAsyncEventQueue() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
String id = "WBCLChannel";
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
factory.setBatchSize(100);
factory.setBatchTimeInterval(500);
factory.setBatchConflationEnabled(true);
factory.setMaximumQueueMemory(200);
factory.setDiskSynchronous(true);
factory.setDispatcherThreads(5);
factory.setOrderPolicy(OrderPolicy.THREAD);
AsyncEventListener eventListener = new MyAsyncEventListener();
AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
RegionAttributesCreation attrs = new RegionAttributesCreation();
attrs.addAsyncEventQueueId(asyncEventQueue.getId());
cache.createRegion("UserRegion", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
validateConcurrentAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
}
}
Aggregations