Search in sources :

Example 21 with RegionQueue

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

the class WANTestBase method verifyRegionQueueNotEmpty.

public static void verifyRegionQueueNotEmpty(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    if (!sender.isParallel()) {
        final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        int queueSize = 0;
        for (RegionQueue q : queues) {
            queueSize += q.size();
        }
        assertTrue(queues.size() > 0);
        assertTrue(queueSize > 0);
    } else if (sender.isParallel()) {
        RegionQueue regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
        assertTrue(regionQueue.size() > 0);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 22 with RegionQueue

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

the class WANTestBase method addSecondCacheQueueListener.

private void addSecondCacheQueueListener(String senderId, boolean isParallel) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    listener2 = new QueueListener();
    if (!isParallel) {
        Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        for (RegionQueue q : queues) {
            q.addCacheListener(listener2);
        }
    } else {
        RegionQueue parallelQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
        parallelQueue.addCacheListener(listener2);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 23 with RegionQueue

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

the class WANTestBase method addCacheListenerOnQueueBucketRegion.

private void addCacheListenerOnQueueBucketRegion(String senderId, int numBuckets) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    RegionQueue parallelQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
    PartitionedRegion region = (PartitionedRegion) parallelQueue.getRegion();
    for (int i = 0; i < numBuckets; i++) {
        BucketRegion br = region.getBucketRegion(i);
        if (br != null) {
            AttributesMutator mutator = br.getAttributesMutator();
            CacheListener listener = new QueueListener();
            mutator.addCacheListener(listener);
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) BucketRegion(org.apache.geode.internal.cache.BucketRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RegionQueue(org.apache.geode.internal.cache.RegionQueue) CacheListener(org.apache.geode.cache.CacheListener) AttributesMutator(org.apache.geode.cache.AttributesMutator)

Example 24 with RegionQueue

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

the class WANTestBase method checkQueue_BR.

public static HashMap checkQueue_BR(String senderId, int numBuckets) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    RegionQueue parallelQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
    PartitionedRegion region = (PartitionedRegion) parallelQueue.getRegion();
    HashMap listenerAttrs = new HashMap();
    for (int i = 0; i < numBuckets; i++) {
        BucketRegion br = region.getBucketRegion(i);
        if (br != null) {
            QueueListener listener = (QueueListener) br.getCacheListener();
            if (listener != null) {
                listenerAttrs.put("Create" + i, listener.createList);
                listenerAttrs.put("Update" + i, listener.updateList);
                listenerAttrs.put("Destroy" + i, listener.destroyList);
            }
        }
    }
    return listenerAttrs;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) BucketRegion(org.apache.geode.internal.cache.BucketRegion) HashMap(java.util.HashMap) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 25 with RegionQueue

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

the class MyGatewayEventSubstitutionFilter 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();
        WaitCriterion wc = new WaitCriterion() {

            public boolean done() {
                int size = 0;
                for (RegionQueue q : queues) {
                    size += q.size();
                }
                if (size == 0) {
                    return true;
                }
                return false;
            }

            public String description() {
                int size = 0;
                for (RegionQueue q : queues) {
                    size += q.size();
                }
                return "Expected queue size to be : " + 0 + " but actual entries: " + size;
            }
        };
        Wait.waitForCriterion(wc, 60000, 500, true);
    } else {
        WaitCriterion wc = new WaitCriterion() {

            public boolean done() {
                Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
                int size = 0;
                for (RegionQueue q : queues) {
                    size += q.size();
                }
                if (size == 0) {
                    return true;
                }
                return false;
            }

            public String description() {
                Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
                int size = 0;
                for (RegionQueue q : queues) {
                    size += q.size();
                }
                return "Expected queue size to be : " + 0 + " but actual entries: " + size;
            }
        };
        Wait.waitForCriterion(wc, 60000, 500, true);
    }
}
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)

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