use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.
the class CacheXml70GatewayDUnitTest 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);
factory.addGatewayEventFilter(new MyGatewayEventFilter());
AsyncEventListener eventListener = new CacheXml70DUnitTest.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.AsyncEventQueueFactory in project geode by apache.
the class CacheXml80GatewayDUnitTest method testAsyncEventQueueWithSubstitutionFilter.
@Test
public void testAsyncEventQueueWithSubstitutionFilter() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
// Create an AsyncEventQueue with GatewayEventSubstitutionFilter.
String id = getName();
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
factory.setGatewayEventSubstitutionListener(new MyGatewayEventSubstitutionFilter());
AsyncEventQueue queue = factory.create(id, new CacheXml70DUnitTest.MyAsyncEventListener());
// Verify the GatewayEventSubstitutionFilter is set on the AsyncEventQueue.
assertNotNull(queue.getGatewayEventSubstitutionFilter());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
// Get the AsyncEventQueue. Verify the GatewayEventSubstitutionFilter is not null.
AsyncEventQueue queueOnCache = c.getAsyncEventQueue(id);
assertNotNull(queueOnCache);
assertNotNull(queueOnCache.getGatewayEventSubstitutionFilter());
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.
the class CacheXmlGeode10DUnitTest method testAsyncEventQueueIsForwardExpirationDestroyAttribute.
@SuppressWarnings("rawtypes")
@Test
public void testAsyncEventQueueIsForwardExpirationDestroyAttribute() throws Exception {
final String regionName = this.testName.getMethodName();
// Create AsyncEventQueue with Listener
final CacheCreation cache = new CacheCreation();
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
AsyncEventListener listener = new MyAsyncEventListenerGeode10();
// Test for default forwardExpirationDestroy attribute value (which is false)
String aeqId1 = "aeqWithDefaultFED";
factory.create(aeqId1, listener);
AsyncEventQueue aeq1 = cache.getAsyncEventQueue(aeqId1);
assertFalse(aeq1.isForwardExpirationDestroy());
// Test by setting forwardExpirationDestroy attribute value.
String aeqId2 = "aeqWithFEDsetToTrue";
factory.setForwardExpirationDestroy(true);
factory.create(aeqId2, listener);
AsyncEventQueue aeq2 = cache.getAsyncEventQueue(aeqId2);
assertTrue(aeq2.isForwardExpirationDestroy());
// Create region and set the AsyncEventQueue
final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.addAsyncEventQueueId(aeqId2);
final Region regionBefore = cache.createRegion(regionName, attrs);
assertNotNull(regionBefore);
assertTrue(regionBefore.getAttributes().getAsyncEventQueueIds().size() == 1);
testXml(cache);
final Cache c = getCache();
assertNotNull(c);
aeq1 = c.getAsyncEventQueue(aeqId1);
assertFalse(aeq1.isForwardExpirationDestroy());
aeq2 = c.getAsyncEventQueue(aeqId2);
assertTrue(aeq2.isForwardExpirationDestroy());
final Region regionAfter = c.getRegion(regionName);
assertNotNull(regionAfter);
assertTrue(regionAfter.getAttributes().getAsyncEventQueueIds().size() == 1);
regionAfter.localDestroyRegion();
// Clear AsyncEventQueues.
c.close();
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.
the class CacheXml70DUnitTest method testAsyncEventQueue.
@Test
public void testAsyncEventQueue() 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(19);
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) {
validateAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.
the class AsyncEventListenerDUnitTest method testCreateAsyncEventQueueWithNullListener.
/**
* Test to verify that AsyncEventQueue can not be created when null listener is passed.
*/
@Test
public void testCreateAsyncEventQueueWithNullListener() {
AsyncEventQueueTestBase test = new AsyncEventQueueTestBase();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
AsyncEventQueueFactory asyncQueueFactory = cache.createAsyncEventQueueFactory();
try {
asyncQueueFactory.create("testId", null);
fail("AsyncQueueFactory should not allow to create AsyncEventQueue with null listener");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations