Search in sources :

Example 6 with AbstractGatewaySenderEventProcessor

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

the class PartitionedRegionDataStore method clearAllTempQueueForShadowPR.

protected void clearAllTempQueueForShadowPR(final int bucketId) {
    List<PartitionedRegion> colocatedWithList = ColocationHelper.getColocatedChildRegions(partitionedRegion);
    for (PartitionedRegion childRegion : colocatedWithList) {
        if (childRegion.isShadowPR()) {
            AbstractGatewaySender sender = childRegion.getParallelGatewaySender();
            if (sender == null) {
                return;
            }
            AbstractGatewaySenderEventProcessor eventProcessor = sender.getEventProcessor();
            if (eventProcessor == null) {
                return;
            }
            ConcurrentParallelGatewaySenderQueue queue = (ConcurrentParallelGatewaySenderQueue) eventProcessor.getQueue();
            if (queue == null) {
                return;
            }
            BlockingQueue<GatewaySenderEventImpl> tempQueue = queue.getBucketTmpQueue(bucketId);
            if (tempQueue != null) {
                synchronized (tempQueue) {
                    for (GatewaySenderEventImpl event : tempQueue) {
                        event.release();
                    }
                    tempQueue.clear();
                }
            }
        }
    }
}
Also used : ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor)

Example 7 with AbstractGatewaySenderEventProcessor

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

the class ParallelAsyncEventQueueImpl method stop.

@Override
public void stop() {
    this.getLifeCycleLock().writeLock().lock();
    try {
        if (!this.isRunning()) {
            return;
        }
        // Stop the dispatcher
        AbstractGatewaySenderEventProcessor ev = this.eventProcessor;
        if (ev != null && !ev.isStopped()) {
            ev.stopProcessing();
        }
        // Stop the proxy (after the dispatcher, so the socket is still
        // alive until after the dispatcher has stopped)
        stompProxyDead();
        // Close the listeners
        for (AsyncEventListener listener : this.listeners) {
            listener.close();
        }
        // stop the running threads, open sockets if any
        ((ConcurrentParallelGatewaySenderQueue) this.eventProcessor.getQueue()).cleanUp();
        logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
        InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
        system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
        clearTempEventsAfterSenderStopped();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
}
Also used : ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 8 with AbstractGatewaySenderEventProcessor

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

the class AsyncEventQueueImpl method size.

@Override
public int size() {
    AbstractGatewaySenderEventProcessor eventProcessor = ((AbstractGatewaySender) sender).getEventProcessor();
    int size = 0;
    if (eventProcessor instanceof ConcurrentSerialGatewaySenderEventProcessor) {
        Set<RegionQueue> queues = ((ConcurrentSerialGatewaySenderEventProcessor) eventProcessor).getQueues();
        Iterator<RegionQueue> itr = queues.iterator();
        while (itr.hasNext()) {
            size = size + itr.next().size();
        }
    } else {
        size = eventProcessor.getQueue().size();
    }
    return size;
}
Also used : AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) ConcurrentSerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 9 with AbstractGatewaySenderEventProcessor

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

the class PartitionedRegion method destroyParallelGatewaySenderRegion.

public void destroyParallelGatewaySenderRegion(Operation op, boolean cacheWrite, boolean lock, boolean callbackEvents) {
    if (logger.isDebugEnabled()) {
        logger.debug("Destoying parallel queue region for senders: {}", this.getParallelGatewaySenderIds());
    }
    boolean keepWaiting = true;
    while (true) {
        List<String> pausedSenders = new ArrayList<String>();
        List<ConcurrentParallelGatewaySenderQueue> parallelQueues = new ArrayList<ConcurrentParallelGatewaySenderQueue>();
        isDestroyedForParallelWAN = true;
        int countOfQueueRegionsToBeDestroyed = 0;
        for (String senderId : this.getParallelGatewaySenderIds()) {
            AbstractGatewaySender sender = (AbstractGatewaySender) this.cache.getGatewaySender(senderId);
            if (sender == null || sender.getEventProcessor() == null) {
                continue;
            }
            if (cacheWrite) {
                // resumed
                if (sender.isPaused()) {
                    pausedSenders.add(senderId);
                    continue;
                }
            }
            if (pausedSenders.isEmpty()) {
                // if there are puase sender then only
                // check for other pause senders instead
                // of creating list of shadowPR
                AbstractGatewaySenderEventProcessor ep = sender.getEventProcessor();
                if (ep == null)
                    continue;
                ConcurrentParallelGatewaySenderQueue parallelQueue = (ConcurrentParallelGatewaySenderQueue) ep.getQueue();
                PartitionedRegion parallelQueueRegion = parallelQueue.getRegion(this.getFullPath());
                // this may be removed in previous iteration
                if (parallelQueueRegion == null || parallelQueueRegion.isDestroyed || parallelQueueRegion.isClosed) {
                    continue;
                }
                parallelQueues.add(parallelQueue);
                countOfQueueRegionsToBeDestroyed++;
            }
        }
        if (!pausedSenders.isEmpty()) {
            String exception = null;
            if (pausedSenders.size() == 1) {
                exception = LocalizedStrings.PartitionedRegion_GATEWAYSENDER_0_IS_PAUSED_RESUME_IT_BEFORE_DESTROYING_USER_REGION_1.toLocalizedString(pausedSenders, this.getName());
            } else {
                exception = LocalizedStrings.PartitionedRegion_GATEWAYSENDERS_0_ARE_PAUSED_RESUME_THEM_BEFORE_DESTROYING_USER_REGION_1.toLocalizedString(pausedSenders, this.getName());
            }
            isDestroyedForParallelWAN = false;
            throw new GatewaySenderException(exception);
        }
        if (countOfQueueRegionsToBeDestroyed == 0) {
            break;
        }
        for (ConcurrentParallelGatewaySenderQueue parallelQueue : parallelQueues) {
            PartitionedRegion parallelQueueRegion = parallelQueue.getRegion(this.getFullPath());
            // keepWaiting : comes from the MAXIMUM_SHUTDOWN_WAIT_TIME case handled
            if (cacheWrite && parallelQueueRegion.size() != 0 && keepWaiting) {
                continue;
            } else {
                // In any case, destroy shadow PR locally. distributed destroy of
                // userPR will take care of detsroying shadowPR locally on other
                // nodes.
                RegionEventImpl event = null;
                if (op.isClose()) {
                    // In case of cache close operation, we want SPR's basic destroy to go
                    // through CACHE_CLOSE condition of postDestroyRegion not
                    // closePartitionedRegion code
                    event = new RegionEventImpl(parallelQueueRegion, op, null, false, getMyId(), generateEventID());
                } else {
                    event = new RegionEventImpl(parallelQueueRegion, Operation.REGION_LOCAL_DESTROY, null, false, getMyId(), generateEventID());
                }
                parallelQueueRegion.basicDestroyRegion(event, false, lock, callbackEvents);
                parallelQueue.removeShadowPR(this.getFullPath());
                countOfQueueRegionsToBeDestroyed--;
                continue;
            }
        }
        if (countOfQueueRegionsToBeDestroyed == 0) {
            break;
        }
        if (cacheWrite) {
            if (AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME == -1) {
                keepWaiting = true;
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException ignore) {
                // interrupted
                }
            } else {
                try {
                    Thread.sleep(AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME * 1000);
                } catch (InterruptedException ignore) {
                /* ignore */
                // interrupted
                }
                keepWaiting = false;
            }
        }
    }
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Aggregations

AbstractGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor)9 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)5 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)4 RegionQueue (org.apache.geode.internal.cache.RegionQueue)3 UpdateAttributesProcessor (org.apache.geode.internal.cache.UpdateAttributesProcessor)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 CancelException (org.apache.geode.CancelException)1 GatewaySenderEventImpl (org.apache.geode.internal.cache.wan.GatewaySenderEventImpl)1 GatewaySenderException (org.apache.geode.internal.cache.wan.GatewaySenderException)1 ConcurrentSerialGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor)1 SerialGatewaySenderQueue (org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue)1