/** * Returns the async event queues for the current cache, or null if no async * event queues or cache exists. */ public static Set<AsyncEventQueue> getAsyncEventQueues() { Cache cache = CacheHelper.getCache(); if (cache == null) { return null; } else { Set<AsyncEventQueue> queues = cache.getAsyncEventQueues(); return (queues == null || queues.size() == 0) ? null : queues; } }
public static void startAsyncEventQueue(String senderId) { Set<AsyncEventQueue> queues = cache.getAsyncEventQueues(); AsyncEventQueue q = null; for (AsyncEventQueue s : queues) { if (s.getId().equals(senderId)) { q = s; break; } } q.start(); }
public static void resumeAsyncEventQueue(String asyncQueueId) { AsyncEventQueue theQueue = null; Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncChannel : asyncEventChannels) { if (asyncQueueId.equals(asyncChannel.getId())) { theQueue = asyncChannel; } } ((AsyncEventQueueImpl)theQueue).getSender().resume(); }
public static void pauseAsyncEventQueue(String asyncChannelId) { AsyncEventQueue theChannel = null; Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncChannel : asyncEventChannels) { if (asyncChannelId.equals(asyncChannel.getId())) { theChannel = asyncChannel; } } ((AsyncEventQueueImpl)theChannel).getSender().pause(); }
public static int getAsyncEventQueueSize(String asyncEventQueueId) { AsyncEventQueue theQueue = null; Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncQueue : asyncEventQueues) { if (asyncEventQueueId.equals(asyncQueue.getId())) { theQueue = asyncQueue; } } assertNotNull(theQueue); return theQueue.size(); }
public static void checkAsyncEventQueueConflatedStats( String asyncEventQueueId, final int eventsConflated) { Set<AsyncEventQueue> queues = cache.getAsyncEventQueues(); AsyncEventQueue queue = null; for (AsyncEventQueue q : queues) { if (q.getId().equals(asyncEventQueueId)) { queue = q; break; } } final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl)queue) .getStatistics(); assertEquals(eventsConflated, statistics.getEventsNotQueuedConflated()); }
public static int getAsyncEventListenerMapSize(String asyncEventQueueId) { AsyncEventListener theListener = null; Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncQueue : asyncEventQueues) { if (asyncEventQueueId.equals(asyncQueue.getId())) { theListener = asyncQueue.getAsyncEventListener(); } } final Map eventsMap = ((MyAsyncEventListener)theListener).getEventsMap(); assertNotNull(eventsMap); getLogWriter().info("The events map size is " + eventsMap.size()); return eventsMap.size(); }
public static void checkAsyncEventQueueBatchStats(String asyncQueueId, final int batches) { Set<AsyncEventQueue> queues = cache.getAsyncEventQueues(); AsyncEventQueue queue = null; for (AsyncEventQueue q : queues) { if (q.getId().equals(asyncQueueId)) { queue = q; break; } } final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl)queue) .getStatistics(); assert (statistics.getBatchesDistributed() >= batches); assertEquals(0, statistics.getBatchesRedistributed()); }
AsyncEventListener theListener = null; Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncQueue : asyncEventQueues) { if (asyncQueueId.equals(asyncQueue.getId())) {
public static void pauseAsyncEventQueueAndWaitForDispatcherToPause(String asyncChannelId) { AsyncEventQueue theChannel = null; Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncChannel : asyncEventChannels) { if (asyncChannelId.equals(asyncChannel.getId())) { theChannel = asyncChannel; break; } } ((AsyncEventQueueImpl)theChannel).getSender().pause(); ((AsyncEventQueueImpl)theChannel).getSender().getEventProcessor().waitForDispatcherToPause(); }
public static Boolean killAsyncEventQueue(String asyncQueueId){ Set<AsyncEventQueue> queues = cache.getAsyncEventQueues(); AsyncEventQueueImpl queue = null; for(AsyncEventQueue q : queues){ if(q.getId().equals(asyncQueueId)){ queue = (AsyncEventQueueImpl) q; break; } } if (queue.isPrimary()) { getLogWriter().info("AsyncEventQueue is killed by a test"); cache.getDistributedSystem().disconnect(); return Boolean.TRUE; } return Boolean.FALSE; }
public static void validateAsyncEventListener(String asyncQueueId, final int expectedSize) { AsyncEventListener theListener = null; Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncQueue : asyncEventQueues) { if (asyncQueueId.equals(asyncQueue.getId())) { theListener = asyncQueue.getAsyncEventListener(); } } final Map eventsMap = ((MyAsyncEventListener) theListener).getEventsMap(); assertNotNull(eventsMap); WaitCriterion wc = new WaitCriterion() { public boolean done() { if (eventsMap.size() == expectedSize) { return true; } return false; } public String description() { return "Expected map entries: " + expectedSize + " but actual entries: " + eventsMap.size(); } }; DistributedTestCase.waitForCriterion(wc, 60000, 500, true); //TODO:Yogs }
public static void verifyAsyncEventListenerForPossibleDuplicates( String asyncEventQueueId, Set<Integer> bucketIds, int batchSize) { AsyncEventListener theListener = null; Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues(); for (AsyncEventQueue asyncQueue : asyncEventQueues) { if (asyncEventQueueId.equals(asyncQueue.getId())) { theListener = asyncQueue.getAsyncEventListener(); } } final Map<Integer, List<GatewaySenderEventImpl>> bucketToEventsMap = ((MyAsyncEventListener2)theListener) .getBucketToEventsMap(); assertNotNull(bucketToEventsMap); assertTrue(bucketIds.size() > 1); for (int bucketId : bucketIds) { List<GatewaySenderEventImpl> eventsForBucket = bucketToEventsMap .get(bucketId); getLogWriter().info( "Events for bucket: " + bucketId + " is " + eventsForBucket); assertNotNull(eventsForBucket); for (int i = 0; i < batchSize; i++) { GatewaySenderEventImpl senderEvent = eventsForBucket.get(i); assertTrue(senderEvent.getPossibleDuplicate()); } } }
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 instanceof ParallelGatewaySenderImpl) { Set<RegionQueue> queues = ((ParallelGatewaySenderImpl)sender).getQueues(); assertEquals(numQueueEntries, queues.toArray(new RegionQueue[queues.size()])[0].getRegion().size()); } else { Set<RegionQueue> queues = ((SerialGatewaySenderImpl)sender).getQueues(); int size = 0; for (RegionQueue q : queues) { size += q.size(); } assertEquals(numQueueEntries, size); } }
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())); }
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())); }
public static void checkAsyncEventQueueStats(String queueId, final int queueSize, final int eventsReceived, final int eventsQueued, final int eventsDistributed) { Set<AsyncEventQueue> asyncQueues = cache.getAsyncEventQueues(); AsyncEventQueue queue = null; for (AsyncEventQueue q : asyncQueues) { if (q.getId().equals(queueId)) { queue = q; break; } } final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl)queue).getStatistics(); assertEquals(queueSize, statistics.getEventQueueSize()); assertEquals(eventsReceived, statistics.getEventsReceived()); assertEquals(eventsQueued, statistics.getEventsQueued()); assert(statistics.getEventsDistributed() >= eventsDistributed); }
/** * Validate whether all the attributes set on AsyncEventQueueFactory are set * on the sender underneath the AsyncEventQueue. */ public static void validateAsyncEventQueueAttributes(String asyncChannelId, int maxQueueMemory, int batchSize, int batchTimeInterval, boolean isPersistent, String diskStoreName, boolean isDiskSynchronous, boolean batchConflationEnabled) { 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()); }
assertNotNull(c); Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues(); assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
assertNotNull(c); Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues(); assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);