Search in sources :

Example 1 with AsyncEventQueueFactory

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);
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 2 with AsyncEventQueueFactory

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());
}
Also used : CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) Test(org.junit.Test) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 3 with AsyncEventQueueFactory

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();
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 4 with AsyncEventQueueFactory

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);
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 5 with AsyncEventQueueFactory

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
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueueTestBase(org.apache.geode.internal.cache.wan.AsyncEventQueueTestBase) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

AsyncEventQueueFactory (org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory)20 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)13 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)10 Test (org.junit.Test)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)6 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)5 Cache (org.apache.geode.cache.Cache)4 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)3 File (java.io.File)2 Properties (java.util.Properties)2 CacheFactory (org.apache.geode.cache.CacheFactory)2 CacheXml70DUnitTest (org.apache.geode.cache30.CacheXml70DUnitTest)2 AsyncEventQueueConfigurationException (org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 HashMap (java.util.HashMap)1 CacheClosedException (org.apache.geode.cache.CacheClosedException)1 Declarable (org.apache.geode.cache.Declarable)1 Region (org.apache.geode.cache.Region)1 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)1