Search in sources :

Example 6 with AsyncEventQueueFactory

use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.

the class MyGatewayEventSubstitutionFilter method createAsyncEventQueueWithCustomListener.

public static void createAsyncEventQueueWithCustomListener(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, String diskStoreName, boolean isDiskSynchronous, int nDispatchers) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        createDiskStore(asyncChannelId, diskStoreName);
        AsyncEventListener asyncEventListener = new CustomAsyncEventListener();
        AsyncEventQueueFactory factory = getInitialAsyncEventQueueFactory(isParallel, maxMemory, batchSize, isPersistent, diskStoreName);
        factory.setDispatcherThreads(nDispatchers);
        AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener);
    } finally {
        exp.remove();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) IgnoredException(org.apache.geode.test.dunit.IgnoredException) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 7 with AsyncEventQueueFactory

use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.

the class AsyncEventQueueValidationsJUnitTest method testConcurrentParallelAsyncEventQueueAttributesWrongDispatcherThreads.

@Test
public void testConcurrentParallelAsyncEventQueueAttributesWrongDispatcherThreads() {
    cache = new CacheFactory().set(MCAST_PORT, "0").create();
    try {
        AsyncEventQueueFactory fact = cache.createAsyncEventQueueFactory();
        fact.setParallel(true);
        fact.setDispatcherThreads(-5);
        fact.setOrderPolicy(OrderPolicy.KEY);
        fact.create("id", new org.apache.geode.internal.cache.wan.MyAsyncEventListener());
        fail("Expected AsyncEventQueueConfigurationException.");
    } catch (AsyncEventQueueConfigurationException e) {
        assertTrue(e.getMessage().contains(" can not be created with dispatcher threads less than 1"));
    }
}
Also used : AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) CacheFactory(org.apache.geode.cache.CacheFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 8 with AsyncEventQueueFactory

use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory in project geode by apache.

the class MyGatewayEventSubstitutionFilter method createAsyncEventQueueWithDiskStore.

public static String createAsyncEventQueueWithDiskStore(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) {
    AsyncEventListener asyncEventListener = new MyAsyncEventListener();
    File persistentDirectory = null;
    if (diskStoreName == null) {
        persistentDirectory = new File(asyncChannelId + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
    } else {
        persistentDirectory = new File(diskStoreName);
    }
    LogWriterUtils.getLogWriter().info("The ds is : " + persistentDirectory.getName());
    persistentDirectory.mkdir();
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    File[] dirs1 = new File[] { persistentDirectory };
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setBatchSize(batchSize);
    factory.setParallel(isParallel);
    if (isPersistent) {
        factory.setPersistent(isPersistent);
        factory.setDiskStoreName(dsf.setDiskDirs(dirs1).create(asyncChannelId).getName());
    }
    factory.setMaximumQueueMemory(maxMemory);
    // set dispatcher threads
    factory.setDispatcherThreads(numDispatcherThreadsForTheRun);
    AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener);
    return persistentDirectory.getName();
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 9 with AsyncEventQueueFactory

use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory 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, final AsyncEventListener asyncEventListener) {
    createDiskStore(asyncChannelId, diskStoreName);
    AsyncEventQueueFactory factory = getInitialAsyncEventQueueFactory(isParallel, maxMemory, batchSize, isPersistent, diskStoreName);
    factory.setDiskSynchronous(isDiskSynchronous);
    factory.setBatchConflationEnabled(isConflation);
    // set dispatcher threads
    factory.setDispatcherThreads(numDispatcherThreadsForTheRun);
    // Set GatewayEventSubstitutionFilter
    AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener);
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue)

Example 10 with AsyncEventQueueFactory

use of org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory 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());
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue)

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