Search in sources :

Example 6 with RegionQueue

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

the class WANTestBase method getNumberOfEntriesOverflownToDisk.

public static Long getNumberOfEntriesOverflownToDisk(final String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    long numEntries = 0;
    if (sender.isParallel()) {
        RegionQueue regionQueue;
        regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
        numEntries = ((ConcurrentParallelGatewaySenderQueue) regionQueue).getNumEntriesOverflowOnDiskTestOnly();
    }
    return numEntries;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 7 with RegionQueue

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

the class WANTestBase method verifyQueueSize.

public static void verifyQueueSize(String senderId, int size) {
    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();
        }
        assertEquals("verifyQueueSize failed for sender " + senderId, size, queueSize);
    } else if (sender.isParallel()) {
        RegionQueue regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
        assertEquals("verifyQueueSize failed for sender " + senderId, size, regionQueue.size());
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 8 with RegionQueue

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

the class WANTestBase method getQueueContentSize.

public static Integer getQueueContentSize(final String senderId, boolean includeSecondary) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    if (!sender.isParallel()) {
        if (includeSecondary) {
            fail("Not implemented yet");
        }
        final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
        int size = 0;
        for (RegionQueue q : queues) {
            size += q.size();
        }
        return size;
    } else if (sender.isParallel()) {
        RegionQueue regionQueue = null;
        regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
        if (regionQueue instanceof ConcurrentParallelGatewaySenderQueue) {
            return ((ConcurrentParallelGatewaySenderQueue) regionQueue).localSize(includeSecondary);
        } else if (regionQueue instanceof ParallelGatewaySenderQueue) {
            return ((ParallelGatewaySenderQueue) regionQueue).localSize(includeSecondary);
        } else {
            if (includeSecondary) {
                fail("Not Implemented yet");
            }
            regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
            return regionQueue.getRegion().size();
        }
    }
    fail("Not yet implemented?");
    return 0;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) ParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueue) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 9 with RegionQueue

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

the class WANTestBase method stopSender.

public static void stopSender(String senderId) {
    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        Set<GatewaySender> senders = cache.getGatewaySenders();
        GatewaySender sender = null;
        for (GatewaySender s : senders) {
            if (s.getId().equals(senderId)) {
                sender = s;
                break;
            }
        }
        AbstractGatewaySenderEventProcessor eventProcessor = null;
        if (sender instanceof AbstractGatewaySender) {
            eventProcessor = ((AbstractGatewaySender) sender).getEventProcessor();
        }
        sender.stop();
        Set<RegionQueue> queues = null;
        if (eventProcessor instanceof ConcurrentSerialGatewaySenderEventProcessor) {
            queues = ((ConcurrentSerialGatewaySenderEventProcessor) eventProcessor).getQueues();
            for (RegionQueue queue : queues) {
                if (queue instanceof SerialGatewaySenderQueue) {
                    assertFalse(((SerialGatewaySenderQueue) queue).isRemovalThreadAlive());
                }
            }
        }
    } finally {
        exp.remove();
        exln.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) SerialGatewaySenderQueue(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConcurrentSerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 10 with RegionQueue

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

the class WANTestBase method getSenderStats.

public static List<Integer> getSenderStats(String senderId, final int expectedQueueSize) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    AbstractGatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = (AbstractGatewaySender) s;
            break;
        }
    }
    final GatewaySenderStats statistics = sender.getStatistics();
    if (expectedQueueSize != -1) {
        final RegionQueue regionQueue;
        regionQueue = sender.getQueues().toArray(new RegionQueue[1])[0];
        Awaitility.await().atMost(120, TimeUnit.SECONDS).until(() -> assertEquals("Expected queue entries: " + expectedQueueSize + " but actual entries: " + regionQueue.size(), expectedQueueSize, regionQueue.size()));
    }
    ArrayList<Integer> stats = new ArrayList<Integer>();
    stats.add(statistics.getEventQueueSize());
    stats.add(statistics.getEventsReceived());
    stats.add(statistics.getEventsQueued());
    stats.add(statistics.getEventsDistributed());
    stats.add(statistics.getBatchesDistributed());
    stats.add(statistics.getBatchesRedistributed());
    stats.add(statistics.getEventsFiltered());
    stats.add(statistics.getEventsNotQueuedConflated());
    stats.add(statistics.getEventsConflatedFromBatches());
    return stats;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) 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