Search in sources :

Example 56 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender 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 57 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender 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 58 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender 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 59 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender 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 60 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.

the class WANTestBase method startSender.

public static void startSender(String senderId) {
    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class.getName());
    try {
        Set<GatewaySender> senders = cache.getGatewaySenders();
        GatewaySender sender = null;
        for (GatewaySender s : senders) {
            if (s.getId().equals(senderId)) {
                sender = s;
                break;
            }
        }
        sender.start();
    } finally {
        exp.remove();
        exp1.remove();
        exln.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Aggregations

GatewaySender (org.apache.geode.cache.wan.GatewaySender)116 RegionQueue (org.apache.geode.internal.cache.RegionQueue)28 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)28 Test (org.junit.Test)17 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 Region (org.apache.geode.cache.Region)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)9 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)9 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)9 DiskStore (org.apache.geode.cache.DiskStore)8 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)8 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)8 Expectations (org.jmock.Expectations)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)7 UnitTest (org.apache.geode.test.junit.categories.UnitTest)7 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5