use of org.apache.geode.cache.asyncqueue.AsyncEventListener 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.AsyncEventListener 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);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventListener in project geode by apache.
the class RebalanceOperationDUnitTest method createPRRegionWithAsyncQueue.
private DistributedMember createPRRegionWithAsyncQueue(VM vm0, final int localMaxMemory) {
SerializableCallable createPrRegion = new SerializableCallable("createRegion") {
public Object call() {
Cache cache = getCache();
// Create an async event listener that doesn't dispatch anything
cache.createAsyncEventQueueFactory().setMaximumQueueMemory(1).setParallel(true).create("parallelQueue", new AsyncEventListener() {
@Override
public void close() {
}
@Override
public boolean processEvents(List<AsyncEvent> events) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
return false;
}
return false;
}
});
AttributesFactory attr = new AttributesFactory();
attr.addAsyncEventQueueId("parallelQueue");
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setRecoveryDelay(-1);
paf.setStartupRecoveryDelay(-1);
paf.setLocalMaxMemory(localMaxMemory);
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
cache.createRegion("region1", attr.create());
return cache.getDistributedSystem().getDistributedMember();
}
};
final DistributedMember member1 = (DistributedMember) vm0.invoke(createPrRegion);
return member1;
}
use of org.apache.geode.cache.asyncqueue.AsyncEventListener 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.AsyncEventListener 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);
}
}
Aggregations