Search in sources :

Example 11 with GatewaySenderStats

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

the class SerialGatewaySenderEventProcessor method queuePrimaryEvent.

private boolean queuePrimaryEvent(GatewaySenderEventImpl gatewayEvent) throws IOException, CacheException {
    // Queue the event
    GatewaySenderStats statistics = this.sender.getStatistics();
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Queueing event ({}): {}", sender.getId(), (statistics.getEventsQueued() + 1), gatewayEvent);
    }
    if (!sender.beforeEnqueue(gatewayEvent)) {
        if (logger.isDebugEnabled()) {
            logger.debug("Event {} is not added to queue.", gatewayEvent);
        }
        statistics.incEventsFiltered();
        return false;
    }
    long start = statistics.startTime();
    boolean putDone = false;
    try {
        putDone = this.queue.put(gatewayEvent);
    } catch (InterruptedException e) {
        // Asif Not expected from SingleWriteSingleReadRegionQueue as it does not
        // throw
        // InterruptedException. But since both HARegionQueue and
        // SingleReadSingleWriteRegionQueue
        // extend RegionQueue , it has to handle InterruptedException
        Thread.currentThread().interrupt();
        getSender().getCancelCriterion().checkCancelInProgress(e);
    }
    statistics.endPut(start);
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Queued event ({}): {}", sender.getId(), (statistics.getEventsQueued()), gatewayEvent);
    }
    // this._logger.warning(getGateway() + ": Queued event (" +
    // (statistics.getEventsQueued()) + "): " + gatewayEvent + " queue size: "
    // + this._eventQueue.size());
    /*
     * FAILOVER TESTING CODE System.out.println(getName() + ": Queued event (" +
     * (statistics.getEventsQueued()) + "): " + gatewayEvent.getId());
     */
    int queueSize = eventQueueSize();
    statistics.incQueueSize(1);
    if (!this.eventQueueSizeWarning && queueSize >= AbstractGatewaySender.QUEUE_SIZE_THRESHOLD) {
        logger.warn(LocalizedMessage.create(LocalizedStrings.GatewayImpl_0_THE_EVENT_QUEUE_SIZE_HAS_REACHED_THE_THRESHOLD_1, new Object[] { sender.getId(), Integer.valueOf(AbstractGatewaySender.QUEUE_SIZE_THRESHOLD) }));
        this.eventQueueSizeWarning = true;
    }
    return putDone;
}
Also used : GatewaySenderStats(org.apache.geode.internal.cache.wan.GatewaySenderStats)

Aggregations

GatewaySenderStats (org.apache.geode.internal.cache.wan.GatewaySenderStats)11 EventWrapper (org.apache.geode.internal.cache.wan.AbstractGatewaySender.EventWrapper)4 GatewaySenderEventImpl (org.apache.geode.internal.cache.wan.GatewaySenderEventImpl)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Queue (java.util.Queue)2 CacheException (org.apache.geode.cache.CacheException)2 AbstractBucketRegionQueue (org.apache.geode.internal.cache.AbstractBucketRegionQueue)2 BucketRegionQueue (org.apache.geode.internal.cache.BucketRegionQueue)2 GatewaySenderEventRemoteDispatcher (org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Test (org.junit.Test)2 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 CancelException (org.apache.geode.CancelException)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1