Search in sources :

Example 1 with SerialGatewaySenderQueue

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

the class SerialAsyncEventQueueImpl method stop.

@Override
public void stop() {
    if (logger.isDebugEnabled()) {
        logger.debug("Stopping Gateway Sender : {}", this);
    }
    this.getLifeCycleLock().writeLock().lock();
    try {
        // 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();
        }
        logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
        clearTempEventsAfterSenderStopped();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
    if (this.isPrimary()) {
        try {
            DistributedLockService.destroy(getSenderAdvisor().getDLockServiceName());
        } catch (IllegalArgumentException e) {
        // service not found... ignore
        }
    }
    if (getQueues() != null && !getQueues().isEmpty()) {
        for (RegionQueue q : getQueues()) {
            ((SerialGatewaySenderQueue) q).cleanUp();
        }
    }
    this.setIsPrimary(false);
    try {
        new UpdateAttributesProcessor(this).distribute(false);
    } catch (CancelException e) {
    }
    Thread lockObtainingThread = getSenderAdvisor().getLockObtainingThread();
    if (lockObtainingThread != null && lockObtainingThread.isAlive()) {
        // wait a while for thread to terminate
        try {
            lockObtainingThread.join(3000);
        } catch (InterruptedException ex) {
            // we allowed our join to be canceled
            // reset interrupt bit so this thread knows it has been interrupted
            Thread.currentThread().interrupt();
        }
        if (lockObtainingThread.isAlive()) {
            logger.info(LocalizedMessage.create(LocalizedStrings.GatewaySender_COULD_NOT_STOP_LOCK_OBTAINING_THREAD_DURING_GATEWAY_SENDER_STOP));
        }
    }
    InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
    system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
}
Also used : SerialGatewaySenderQueue(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue) UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) CancelException(org.apache.geode.CancelException) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 2 with SerialGatewaySenderQueue

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

Aggregations

RegionQueue (org.apache.geode.internal.cache.RegionQueue)2 SerialGatewaySenderQueue (org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue)2 CancelException (org.apache.geode.CancelException)1 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)1 GatewaySender (org.apache.geode.cache.wan.GatewaySender)1 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)1 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)1 UpdateAttributesProcessor (org.apache.geode.internal.cache.UpdateAttributesProcessor)1 AbstractGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor)1 ConcurrentSerialGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1