Search in sources :

Example 26 with AbstractGatewaySender

use of org.apache.geode.internal.cache.wan.AbstractGatewaySender in project geode by apache.

the class SerialGatewaySenderEventListenerDUnitTest method validateReceivedEventsMapSizeListener2.

public static void validateReceivedEventsMapSizeListener2(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() == 2) {
        final AsyncEventListener l1 = listeners.get(0);
        final AsyncEventListener l2 = listeners.get(1);
        Awaitility.await().atMost(60000, TimeUnit.MILLISECONDS).until(() -> {
            Map listenerMap1 = ((MyGatewaySenderEventListener) l1).getEventsMap();
            Map listenerMap2 = ((MyGatewaySenderEventListener2) l2).getEventsMap();
            int listener1MapSize = listenerMap1.size();
            int listener2MapSize = listenerMap1.size();
            int expectedMapSize = map.size();
            boolean sizeCorrect = expectedMapSize == listener1MapSize;
            boolean keySetCorrect = listenerMap1.keySet().containsAll(map.keySet());
            boolean valuesCorrect = listenerMap1.values().containsAll(map.values());
            boolean sizeCorrect2 = expectedMapSize == listener2MapSize;
            boolean keySetCorrect2 = listenerMap2.keySet().containsAll(map.keySet());
            boolean valuesCorrect2 = listenerMap2.values().containsAll(map.values());
            assertEquals("Failed while waiting for all sites to get updated with the correct events. \nThe " + "size of listener 1's map = " + listener1MapSize + "\n The size of listener 2's map = " + "" + listener2MapSize + "\n The expected map size =" + expectedMapSize, true, sizeCorrect && keySetCorrect && valuesCorrect && sizeCorrect2 && keySetCorrect2 && valuesCorrect2);
        });
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) MyGatewaySenderEventListener(org.apache.geode.internal.cache.wan.MyGatewaySenderEventListener) MyGatewaySenderEventListener2(org.apache.geode.internal.cache.wan.MyGatewaySenderEventListener2) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) HashMap(java.util.HashMap) Map(java.util.Map) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 27 with AbstractGatewaySender

use of org.apache.geode.internal.cache.wan.AbstractGatewaySender in project geode by apache.

the class SerialGatewaySenderEventListenerDUnitTest method validateNoPoolCreation.

public static void validateNoPoolCreation(final String siteId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    for (GatewaySender sender : senders) {
        if (sender.getId().equals(siteId)) {
            AbstractGatewaySender sImpl = (AbstractGatewaySender) sender;
            assertNull(sImpl.getProxy());
        }
    }
}
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 28 with AbstractGatewaySender

use of org.apache.geode.internal.cache.wan.AbstractGatewaySender 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 29 with AbstractGatewaySender

use of org.apache.geode.internal.cache.wan.AbstractGatewaySender 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 30 with AbstractGatewaySender

use of org.apache.geode.internal.cache.wan.AbstractGatewaySender 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)

Aggregations

AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)40 GatewaySender (org.apache.geode.cache.wan.GatewaySender)23 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)6 IgnoredException (org.apache.geode.test.dunit.IgnoredException)6 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 Test (org.junit.Test)6 RegionQueue (org.apache.geode.internal.cache.RegionQueue)5 Properties (java.util.Properties)4 Set (java.util.Set)4 Region (org.apache.geode.cache.Region)4 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)4 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)4 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)4 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)4 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 AsyncEventQueueImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl)3 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)3