Search in sources :

Example 61 with GatewaySender

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

the class WANTestBase method validateAfterAck.

public static Integer validateAfterAck(final String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    final MyGatewayEventFilter_AfterAck filter = (MyGatewayEventFilter_AfterAck) sender.getGatewayEventFilters().get(0);
    return filter.getAckList().size();
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender)

Example 62 with GatewaySender

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

the class WANTestBase method checkStats_Failover.

public static void checkStats_Failover(String senderId, final int eventsReceived) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    final GatewaySenderStats statistics = ((AbstractGatewaySender) sender).getStatistics();
    assertEquals(eventsReceived, statistics.getEventsReceived());
    assertEquals(eventsReceived, (statistics.getEventsQueued() + statistics.getUnprocessedTokensAddedByPrimary() + statistics.getUnprocessedEventsRemovedByPrimary()));
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender)

Example 63 with GatewaySender

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

the class WANTestBase method getSenderToReceiverConnectionInfo.

public static Map getSenderToReceiverConnectionInfo(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    Map connectionInfo = null;
    if (!sender.isParallel() && ((AbstractGatewaySender) sender).isPrimary()) {
        connectionInfo = new HashMap();
        GatewaySenderEventDispatcher dispatcher = ((AbstractGatewaySender) sender).getEventProcessor().getDispatcher();
        if (dispatcher instanceof GatewaySenderEventRemoteDispatcher) {
            ServerLocation serverLocation = ((GatewaySenderEventRemoteDispatcher) dispatcher).getConnection(false).getServer();
            connectionInfo.put("serverHost", serverLocation.getHostName());
            connectionInfo.put("serverPort", serverLocation.getPort());
        }
    }
    return connectionInfo;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) HashMap(java.util.HashMap) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 64 with GatewaySender

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

Example 65 with GatewaySender

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

the class MyGatewayEventSubstitutionFilter method unsetRemoveFromQueueOnException.

public static void unsetRemoveFromQueueOnException(String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    assertNotNull(sender);
    ((AbstractGatewaySender) sender).setRemoveFromQueueOnException(false);
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender)

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