Search in sources :

Example 71 with GatewaySender

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

the class SerialGatewaySenderEventListenerDUnitTest method validateReceivedEventsMapSizeListener1.

public static void validateReceivedEventsMapSizeListener1(final String senderId, final Map map) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    final List<AsyncEventListener> listeners = ((AbstractGatewaySender) sender).getAsyncEventListeners();
    if (listeners.size() == 1) {
        final AsyncEventListener l = listeners.get(0);
        WaitCriterion wc = new WaitCriterion() {

            Map listenerMap;

            public boolean done() {
                listenerMap = ((MyGatewaySenderEventListener) l).getEventsMap();
                boolean sizeCorrect = map.size() == listenerMap.size();
                boolean keySetCorrect = listenerMap.keySet().containsAll(map.keySet());
                boolean valuesCorrect = listenerMap.values().containsAll(map.values());
                return sizeCorrect && keySetCorrect && valuesCorrect;
            }

            public String description() {
                return "Waiting for all sites to get updated, the sizes are " + listenerMap.size() + " and " + map.size();
            }
        };
        Wait.waitForCriterion(wc, 60000, 500, true);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) HashMap(java.util.HashMap) Map(java.util.Map) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 72 with GatewaySender

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

the class SerialGatewaySenderOperationsDUnitTest method verifySenderResumedState.

public static void verifySenderResumedState(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    AbstractGatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = (AbstractGatewaySender) s;
            break;
        }
    }
    assertFalse(sender.isPaused());
    assertTrue(sender.isRunning());
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Example 73 with GatewaySender

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

the class SerialGatewaySenderOperationsDUnitTest method verifyGatewaySenderOperations.

public static void verifyGatewaySenderOperations(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    assertFalse(sender.isPaused());
    assertFalse(((AbstractGatewaySender) sender).isRunning());
    sender.pause();
    sender.resume();
    sender.stop();
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Example 74 with GatewaySender

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

the class SerialGatewaySenderOperationsDUnitTest method verifySenderStoppedState.

public static void verifySenderStoppedState(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    AbstractGatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = (AbstractGatewaySender) s;
            break;
        }
    }
    assertFalse(sender.isRunning());
    assertFalse(sender.isPaused());
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Example 75 with GatewaySender

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

the class ParallelWANPersistenceEnabledGatewaySenderDUnitTest method testPartitionedRegionWithGatewaySenderPersistenceEnabled.

@Test
public void testPartitionedRegionWithGatewaySenderPersistenceEnabled() throws IOException {
    try {
        Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
        Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
        createCache(lnPort);
        GatewaySenderFactory fact = cache.createGatewaySenderFactory();
        fact.setPersistenceEnabled(true);
        fact.setParallel(true);
        final IgnoredException ex = IgnoredException.addIgnoredException("Could not connect");
        try {
            GatewaySender sender1 = fact.create("NYSender", 2);
            AttributesFactory rFact = new AttributesFactory();
            rFact.addGatewaySenderId(sender1.getId());
            PartitionAttributesFactory pFact = new PartitionAttributesFactory();
            pFact.setTotalNumBuckets(100);
            pFact.setRedundantCopies(1);
            rFact.setPartitionAttributes(pFact.create());
            Region r = cache.createRegionFactory(rFact.create()).create("MyRegion");
            sender1.start();
        } finally {
            ex.remove();
        }
    } catch (Exception e) {
        fail("Unexpected Exception :" + e);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) IOException(java.io.IOException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

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