use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method getAsyncEventListener.
public static AsyncEventListener getAsyncEventListener(String asyncEventQueueId) {
AsyncEventListener theListener = null;
Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncQueue : asyncEventQueues) {
if (asyncEventQueueId.equals(asyncQueue.getId())) {
return asyncQueue.getAsyncEventListener();
}
}
return null;
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method checkAsyncEventQueueUnprocessedStats.
public static void checkAsyncEventQueueUnprocessedStats(String asyncQueueId, int events) {
Set<AsyncEventQueue> asyncQueues = cache.getAsyncEventQueues();
AsyncEventQueue queue = null;
for (AsyncEventQueue q : asyncQueues) {
if (q.getId().equals(asyncQueueId)) {
queue = q;
break;
}
}
final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl) queue).getStatistics();
assertEquals(events, (statistics.getUnprocessedEventsAddedBySecondary() + statistics.getUnprocessedTokensRemovedBySecondary()));
assertEquals(events, (statistics.getUnprocessedEventsRemovedByPrimary() + statistics.getUnprocessedTokensAddedByPrimary()));
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method verifySubstitutionFilterInvocations.
public static void verifySubstitutionFilterInvocations(String asyncEventQueueId, int expectedNumInvocations) {
AsyncEventQueue queue = cache.getAsyncEventQueue(asyncEventQueueId);
assertNotNull(queue);
// Verify the GatewayEventSubstitutionFilter has been invoked the appropriate number of times
MyGatewayEventSubstitutionFilter filter = (MyGatewayEventSubstitutionFilter) queue.getGatewayEventSubstitutionFilter();
assertNotNull(filter);
assertEquals(expectedNumInvocations, filter.getNumInvocations());
// Verify the AsyncEventListener has received the substituted values
MyAsyncEventListener listener = (MyAsyncEventListener) queue.getAsyncEventListener();
final Map eventsMap = listener.getEventsMap();
assertNotNull(eventsMap);
assertEquals(expectedNumInvocations, eventsMap.size());
for (Iterator i = eventsMap.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<Integer, String> entry = (Map.Entry<Integer, String>) i.next();
assertEquals(MyGatewayEventSubstitutionFilter.SUBSTITUTION_PREFIX + entry.getKey(), entry.getValue());
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class ClusterConfigDistributionDUnitTest method testIndexAndAsyncEventQueueCommands.
@Test
public void testIndexAndAsyncEventQueueCommands() throws Exception {
final String DESTROY_REGION = "regionToBeDestroyed";
gfshConnector.executeAndVerifyCommand("create region --name=" + REPLICATE_REGION + " --type=REPLICATE");
gfshConnector.executeAndVerifyCommand("create region --name=" + PARTITION_REGION + " --type=PARTITION");
gfshConnector.executeAndVerifyCommand("create region --name=" + DESTROY_REGION + " --type=REPLICATE");
gfshConnector.executeAndVerifyCommand("create index --name=" + INDEX1 + " --expression=AAPL --region=" + REPLICATE_REGION);
gfshConnector.executeAndVerifyCommand("create index --name=" + INDEX2 + " --expression=VMW --region=" + PARTITION_REGION);
String asyncEventQueueJarPath = createAsyncEventQueueJar();
gfshConnector.executeAndVerifyCommand("deploy --jar=" + asyncEventQueueJarPath);
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, AsyncEventQueue1);
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER, "com.qcdunit.QueueCommandsDUnitTestListener");
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE, null);
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCH_SIZE, "1000");
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP, null);
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, "false");
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY, "1000");
gfshConnector.executeAndVerifyCommand(csb.getCommandString());
gfshConnector.executeAndVerifyCommand("destroy region --name=" + DESTROY_REGION);
gfshConnector.executeAndVerifyCommand("destroy index --name=" + INDEX2 + " --region=" + PARTITION_REGION);
gfshConnector.executeAndVerifyCommand("alter runtime --copy-on-read=true");
// Start a new member which receives the shared configuration
// Verify the config creation on this member
MemberVM server = lsRule.startServerVM(2, new Properties(), locator.getPort());
server.invoke(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
assertNotNull(cache);
assertTrue(cache.getCopyOnRead());
Region region1 = cache.getRegion(REPLICATE_REGION);
assertNotNull(region1);
Region region2 = cache.getRegion(PARTITION_REGION);
assertNotNull(region2);
Region region3 = cache.getRegion(DESTROY_REGION);
assertNull(region3);
// Index verification
Index index1 = cache.getQueryService().getIndex(region1, INDEX1);
assertNotNull(index1);
assertNull(cache.getQueryService().getIndex(region2, INDEX2));
// ASYNC-EVENT-QUEUE verification
AsyncEventQueue aeq = cache.getAsyncEventQueue(AsyncEventQueue1);
assertNotNull(aeq);
assertFalse(aeq.isPersistent());
assertTrue(aeq.getBatchSize() == 1000);
assertTrue(aeq.getMaximumQueueMemory() == 1000);
});
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class CacheXmlParser method endAsyncEventQueue.
private void endAsyncEventQueue() {
AsyncEventQueueCreation asyncEventChannelCreation = (AsyncEventQueueCreation) stack.peek();
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
factory.setParallel(asyncEventChannelCreation.isParallel());
factory.setBatchSize(asyncEventChannelCreation.getBatchSize());
factory.setBatchTimeInterval(asyncEventChannelCreation.getBatchTimeInterval());
factory.setBatchConflationEnabled(asyncEventChannelCreation.isBatchConflationEnabled());
factory.setPersistent(asyncEventChannelCreation.isPersistent());
factory.setDiskStoreName(asyncEventChannelCreation.getDiskStoreName());
factory.setDiskSynchronous(asyncEventChannelCreation.isDiskSynchronous());
factory.setMaximumQueueMemory(asyncEventChannelCreation.getMaximumQueueMemory());
factory.setDispatcherThreads(asyncEventChannelCreation.getDispatcherThreads());
factory.setOrderPolicy(asyncEventChannelCreation.getOrderPolicy());
factory.setForwardExpirationDestroy(asyncEventChannelCreation.isForwardExpirationDestroy());
List<GatewayEventFilter> gatewayEventFilters = asyncEventChannelCreation.getGatewayEventFilters();
for (GatewayEventFilter gatewayEventFilter : gatewayEventFilters) {
factory.addGatewayEventFilter(gatewayEventFilter);
}
factory.setGatewayEventSubstitutionListener(asyncEventChannelCreation.getGatewayEventSubstitutionFilter());
AsyncEventQueue asyncEventChannel = factory.create(asyncEventChannelCreation.getId(), asyncEventChannelCreation.getAsyncEventListener());
stack.pop();
}
Aggregations