use of org.apache.geode.cache.asyncqueue.AsyncEventQueue 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.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method checkAsyncEventQueueStats_Failover.
public static void checkAsyncEventQueueStats_Failover(String asyncEventQueueId, final int eventsReceived) {
Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
AsyncEventQueue queue = null;
for (AsyncEventQueue q : asyncEventQueues) {
if (q.getId().equals(asyncEventQueueId)) {
queue = q;
break;
}
}
final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl) queue).getStatistics();
assertEquals(eventsReceived, statistics.getEventsReceived());
assertEquals(eventsReceived, (statistics.getEventsQueued() + statistics.getUnprocessedTokensAddedByPrimary() + statistics.getUnprocessedEventsRemovedByPrimary()));
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method validateConcurrentAsyncEventQueueAttributes.
/**
* Validate whether all the attributes set on AsyncEventQueueFactory are set on the sender
* underneath the AsyncEventQueue.
*/
public static void validateConcurrentAsyncEventQueueAttributes(String asyncChannelId, int maxQueueMemory, int batchSize, int batchTimeInterval, boolean isPersistent, String diskStoreName, boolean isDiskSynchronous, boolean batchConflationEnabled, int dispatcherThreads, OrderPolicy policy) {
AsyncEventQueue theChannel = null;
Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncChannel : asyncEventChannels) {
if (asyncChannelId.equals(asyncChannel.getId())) {
theChannel = asyncChannel;
}
}
GatewaySender theSender = ((AsyncEventQueueImpl) theChannel).getSender();
assertEquals("maxQueueMemory", maxQueueMemory, theSender.getMaximumQueueMemory());
assertEquals("batchSize", batchSize, theSender.getBatchSize());
assertEquals("batchTimeInterval", batchTimeInterval, theSender.getBatchTimeInterval());
assertEquals("isPersistent", isPersistent, theSender.isPersistenceEnabled());
assertEquals("diskStoreName", diskStoreName, theSender.getDiskStoreName());
assertEquals("isDiskSynchronous", isDiskSynchronous, theSender.isDiskSynchronous());
assertEquals("batchConflation", batchConflationEnabled, theSender.isBatchConflationEnabled());
assertEquals("dispatcherThreads", dispatcherThreads, theSender.getDispatcherThreads());
assertEquals("orderPolicy", policy, theSender.getOrderPolicy());
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method checkAsyncEventQueueSize.
public static void checkAsyncEventQueueSize(String asyncQueueId, int numQueueEntries) {
AsyncEventQueue theAsyncEventQueue = null;
Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncChannel : asyncEventChannels) {
if (asyncQueueId.equals(asyncChannel.getId())) {
theAsyncEventQueue = asyncChannel;
}
}
GatewaySender sender = ((AsyncEventQueueImpl) theAsyncEventQueue).getSender();
if (sender.isParallel()) {
Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
assertEquals(numQueueEntries, queues.toArray(new RegionQueue[queues.size()])[0].getRegion().size());
} else {
Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
int size = 0;
for (RegionQueue q : queues) {
size += q.size();
}
assertEquals(numQueueEntries, size);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue 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();
}
Aggregations