Search in sources :

Example 1 with UpdateAttributesProcessor

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

the class SerialGatewaySenderImpl 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
        }
    }
    Set<RegionQueue> queues = getQueues();
    if (queues != null && !queues.isEmpty()) {
        for (RegionQueue q : queues) {
            ((SerialGatewaySenderQueue) q).cleanUp();
        }
    }
    this.setIsPrimary(false);
    new UpdateAttributesProcessor(this).distribute(false);
    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);
    this.eventProcessor = null;
}
Also used : UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) 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 UpdateAttributesProcessor

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

the class SerialGatewaySenderImpl method start.

@Override
public void start() {
    if (logger.isDebugEnabled()) {
        logger.debug("Starting gatewaySender : {}", this);
    }
    this.getLifeCycleLock().writeLock().lock();
    try {
        if (isRunning()) {
            logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_SENDER_0_IS_ALREADY_RUNNING, this.getId()));
            return;
        }
        if (this.remoteDSId != DEFAULT_DISTRIBUTED_SYSTEM_ID) {
            String locators = this.cache.getInternalDistributedSystem().getConfig().getLocators();
            if (locators.length() == 0) {
                throw new GatewaySenderConfigurationException(LocalizedStrings.AbstractGatewaySender_LOCATOR_SHOULD_BE_CONFIGURED_BEFORE_STARTING_GATEWAY_SENDER.toLocalizedString());
            }
        }
        getSenderAdvisor().initDLockService();
        if (!isPrimary()) {
            if (getSenderAdvisor().volunteerForPrimary()) {
                getSenderAdvisor().makePrimary();
            } else {
                getSenderAdvisor().makeSecondary();
            }
        }
        if (getDispatcherThreads() > 1) {
            eventProcessor = new RemoteConcurrentSerialGatewaySenderEventProcessor(SerialGatewaySenderImpl.this);
        } else {
            eventProcessor = new RemoteSerialGatewaySenderEventProcessor(SerialGatewaySenderImpl.this, getId());
        }
        eventProcessor.start();
        waitForRunningStatus();
        this.startTime = System.currentTimeMillis();
        // Only notify the type registry if this is a WAN gateway queue
        if (!isAsyncEventQueue()) {
            getCache().getPdxRegistry().gatewaySenderStarted(this);
        }
        new UpdateAttributesProcessor(this).distribute(false);
        InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
        system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_START, this);
        logger.info(LocalizedMessage.create(LocalizedStrings.SerialGatewaySenderImpl_STARTED__0, this));
        enqueueTempEvents();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
}
Also used : GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 3 with UpdateAttributesProcessor

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

the class DistributionAdvisor method exchangeProfiles.

/** exchange profiles to initialize this advisor */
private void exchangeProfiles() {
    // causes deadlock
    Assert.assertHoldsLock(this, false);
    Assert.assertHoldsLock(this.initializeLock, true);
    new UpdateAttributesProcessor(getAdvisee()).distribute(true);
    setInitialized();
}
Also used : UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor)

Example 4 with UpdateAttributesProcessor

use of org.apache.geode.internal.cache.UpdateAttributesProcessor 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 5 with UpdateAttributesProcessor

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

the class ResourceAdvisor method close.

@Override
public void close() {
    new UpdateAttributesProcessor(this.getAdvisee(), true).distribute(false);
    super.close();
}
Also used : UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor)

Aggregations

UpdateAttributesProcessor (org.apache.geode.internal.cache.UpdateAttributesProcessor)12 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)6 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)2 RegionQueue (org.apache.geode.internal.cache.RegionQueue)2 AbstractGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor)2 GatewaySenderConfigurationException (org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException)2 IOException (java.io.IOException)1 List (java.util.List)1 CancelException (org.apache.geode.CancelException)1 GemFireIOException (org.apache.geode.GemFireIOException)1 ServerConnectivityException (org.apache.geode.cache.client.ServerConnectivityException)1 Connection (org.apache.geode.cache.client.internal.Connection)1 ConnectionDestroyedException (org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException)1 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)1 ConcurrentParallelGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderEventProcessor)1 ConcurrentSerialGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor)1 SerialGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderEventProcessor)1 SerialGatewaySenderQueue (org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue)1 GemFireSecurityException (org.apache.geode.security.GemFireSecurityException)1