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();
}
}
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"));
}
}
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();
}
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);
}
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());
}
Aggregations