use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor 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;
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class AbstractBucketRegionQueue method notifyEventProcessor.
protected void notifyEventProcessor() {
AbstractGatewaySender sender = getPartitionedRegion().getParallelGatewaySender();
if (sender != null) {
AbstractGatewaySenderEventProcessor ep = sender.getEventProcessor();
if (ep != null) {
ConcurrentParallelGatewaySenderQueue queue = (ConcurrentParallelGatewaySenderQueue) ep.getQueue();
if (logger.isDebugEnabled()) {
logger.debug("notifyEventProcessor : {} event processor {} queue {}", sender, ep, queue);
}
queue.notifyEventProcessorIfRequired(this.getId());
}
}
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor 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);
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class BucketRegionQueue method conflateOldEntry.
private void conflateOldEntry(Conflatable object, Long tailKey) {
PartitionedRegion region = this.getPartitionedRegion();
Conflatable conflatableObject = object;
if (region.isConflationEnabled() && conflatableObject.shouldBeConflated()) {
Object keyToConflate = conflatableObject.getKeyToConflate();
String rName = object.getRegionToConflate();
if (logger.isDebugEnabled()) {
logger.debug(" The region name is : {}", rName);
}
Map latestIndexesForRegion = (Map) this.indexes.get(rName);
if (latestIndexesForRegion == null) {
latestIndexesForRegion = new ConcurrentHashMap();
this.indexes.put(rName, latestIndexesForRegion);
}
Long previousTailKey = (Long) latestIndexesForRegion.put(keyToConflate, tailKey);
if (previousTailKey != null) {
if (logger.isDebugEnabled()) {
logger.debug("{}: Conflating {} at queue index={} and previousTailKey: ", this, object, tailKey, previousTailKey);
}
AbstractGatewaySenderEventProcessor ep = region.getParallelGatewaySender().getEventProcessor();
if (ep == null)
return;
ConcurrentParallelGatewaySenderQueue queue = (ConcurrentParallelGatewaySenderQueue) ep.getQueue();
// Give the actual conflation work to another thread.
// ParallelGatewaySenderQueue takes care of maintaining a thread pool.
queue.conflateEvent(conflatableObject, getId(), previousTailKey);
} else {
region.getParallelGatewaySender().getStatistics().incConflationIndexesMapSize();
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("{}: Not conflating {}", this, object);
}
}
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class ParallelGatewaySenderImpl 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();
// Keep the eventProcessor around so we can ask it for the regionQueues later.
// Tests expect to be able to do this.
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
}
Aggregations