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);
}
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();
}
}
Aggregations