Search in sources :

Example 1 with AsyncEventQueueImpl

use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl in project geode by apache.

the class AsyncEventQueueEvictionAndExpirationJUnitTest method getEventsNotQueuedSize.

public int getEventsNotQueuedSize(String aeqId) {
    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
    AbstractGatewaySender sender = (AbstractGatewaySender) aeq.getSender();
    return sender.getStatistics().getEventsNotQueued();
}
Also used : AsyncEventQueueImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Example 2 with AsyncEventQueueImpl

use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl in project geode by apache.

the class MyGatewayEventSubstitutionFilter method waitForAsyncEventQueueSize.

/**
   * This method verifies the queue size of a ParallelGatewaySender. For ParallelGatewaySender
   * conflation happens in a separate thread, hence test code needs to wait for some time for
   * expected result
   * 
   * @param asyncQueueId Async Queue ID
   * @param numQueueEntries expected number of Queue entries
   * @throws Exception
   */
public static void waitForAsyncEventQueueSize(String asyncQueueId, final int numQueueEntries) throws Exception {
    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()) {
        final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        Wait.waitForCriterion(new WaitCriterion() {

            public String description() {
                return "Waiting for EventQueue size to be " + numQueueEntries;
            }

            public boolean done() {
                boolean done = numQueueEntries == queues.toArray(new RegionQueue[queues.size()])[0].getRegion().size();
                return done;
            }
        }, MAX_WAIT, 500, true);
    } else {
        throw new Exception("This method should be used for only ParallelGatewaySender,SerialGatewaySender should use checkAsyncEventQueueSize() method instead");
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) AsyncEventQueueImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl) RegionQueue(org.apache.geode.internal.cache.RegionQueue) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) IOException(java.io.IOException)

Example 3 with AsyncEventQueueImpl

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

Example 4 with AsyncEventQueueImpl

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

Example 5 with AsyncEventQueueImpl

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

Aggregations

AsyncEventQueueImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl)21 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)13 GatewaySender (org.apache.geode.cache.wan.GatewaySender)6 AsyncEventQueueStats (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueStats)5 RegionQueue (org.apache.geode.internal.cache.RegionQueue)4 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)3 Region (org.apache.geode.cache.Region)2 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)2 IOException (java.io.IOException)1 TimeUnit (java.util.concurrent.TimeUnit)1 Cache (org.apache.geode.cache.Cache)1 CacheClosedException (org.apache.geode.cache.CacheClosedException)1 RegionFunctionContext (org.apache.geode.cache.execute.RegionFunctionContext)1 LuceneService (org.apache.geode.cache.lucene.LuceneService)1 LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)1 PartitionOfflineException (org.apache.geode.cache.persistence.PartitionOfflineException)1 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1