Search in sources :

Example 36 with RegionQueue

use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.

the class WANTestBase method waitForAsyncQueueToGetEmpty.

public static void waitForAsyncQueueToGetEmpty(String asyncQueueId) {
    AsyncEventQueue theAsyncEventQueue = null;
    Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
    for (AsyncEventQueue asyncChannel : asyncEventChannels) {
        if (asyncQueueId.equals(asyncChannel.getId())) {
            theAsyncEventQueue = asyncChannel;
        }
    }
    final GatewaySender sender = ((AsyncEventQueueImpl) theAsyncEventQueue).getSender();
    if (sender.isParallel()) {
        final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
            int size = 0;
            for (RegionQueue q : queues) {
                size += q.size();
            }
            assertEquals("Expected queue size to be : " + 0 + " but actual entries: " + size, 0, size);
        });
    } else {
        Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
            Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
            int size = 0;
            for (RegionQueue q : queues) {
                size += q.size();
            }
            assertEquals("Expected queue size to be : " + 0 + " but actual entries: " + size, 0, 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)

Example 37 with RegionQueue

use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.

the class WANTestBase method validateParallelSenderQueueBucketSize.

public static void validateParallelSenderQueueBucketSize(final String senderId, final int bucketSize) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    RegionQueue regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
    Set<BucketRegion> buckets = ((PartitionedRegion) regionQueue.getRegion()).getDataStore().getAllLocalPrimaryBucketRegions();
    for (BucketRegion bucket : buckets) {
        assertEquals("Expected bucket entries for bucket " + bucket.getId() + " is different than actual.", bucketSize, bucket.keySet().size());
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) BucketRegion(org.apache.geode.internal.cache.BucketRegion) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 38 with RegionQueue

use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.

the class WANTestBase method waitForConcurrentSerialSenderQueueToDrain.

public static void waitForConcurrentSerialSenderQueueToDrain(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = senders.stream().filter(s -> s.getId().equals(senderId)).findFirst().get();
    Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> {
        Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueuesForConcurrentSerialGatewaySender();
        for (RegionQueue q : queues) {
            assertEquals(0, q.size());
        }
    });
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 39 with RegionQueue

use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.

the class WANTestBase method testQueueSize.

public static void testQueueSize(String senderId, int numQueueEntries) {
    GatewaySender sender = null;
    for (GatewaySender s : cache.getGatewaySenders()) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    if (sender.isParallel()) {
        int totalSize = 0;
        Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        for (RegionQueue q : queues) {
            ConcurrentParallelGatewaySenderQueue prQ = (ConcurrentParallelGatewaySenderQueue) q;
            totalSize += prQ.size();
        }
        assertEquals(numQueueEntries, totalSize);
    } 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) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Aggregations

RegionQueue (org.apache.geode.internal.cache.RegionQueue)39 GatewaySender (org.apache.geode.cache.wan.GatewaySender)28 IgnoredException (org.apache.geode.test.dunit.IgnoredException)8 Properties (java.util.Properties)7 AttributesFactory (org.apache.geode.cache.AttributesFactory)7 Test (org.junit.Test)7 Region (org.apache.geode.cache.Region)6 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)6 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 CacheListener (org.apache.geode.cache.CacheListener)4 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)4 AsyncEventQueueImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl)4 BucketRegion (org.apache.geode.internal.cache.BucketRegion)4 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)4 RegionAttributes (org.apache.geode.cache.RegionAttributes)3 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)3 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)3 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)3