use of org.apache.geode.internal.cache.RegionQueue 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.RegionQueue in project geode by apache.
the class WANTestBase method validateQueueClosedForConcurrentSerialGatewaySender.
// Ensure that the sender's queue(s) have been closed.
public static void validateQueueClosedForConcurrentSerialGatewaySender(final String senderId) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
final Set<RegionQueue> regionQueue;
if (sender instanceof AbstractGatewaySender) {
regionQueue = ((AbstractGatewaySender) sender).getQueuesForConcurrentSerialGatewaySender();
} else {
regionQueue = null;
}
assertEquals(null, regionQueue);
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method validateQueueContents.
public static void validateQueueContents(final String senderId, final int regionSize) {
IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class.getName());
IgnoredException exp2 = IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
try {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
if (!sender.isParallel()) {
final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
Awaitility.await().atMost(120, TimeUnit.SECONDS).until(() -> {
int size = 0;
for (RegionQueue q : queues) {
size += q.size();
}
assertEquals("Expected queue entries: " + regionSize + " but actual entries: " + size, regionSize, size);
});
} else if (sender.isParallel()) {
final RegionQueue regionQueue;
regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
Awaitility.await().atMost(120, TimeUnit.SECONDS).until(() -> assertEquals("Expected queue entries: " + regionSize + " but actual entries: " + regionQueue.size(), regionSize, regionQueue.size()));
}
} finally {
exp1.remove();
exp2.remove();
}
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method getPRQLocalSize.
/**
* To be used only for ParallelGatewaySender.
*
* @param senderId Id of the ParallelGatewaySender
*/
public static int getPRQLocalSize(String senderId) {
GatewaySender sender = null;
for (GatewaySender s : cache.getGatewaySenders()) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
if (sender.isParallel()) {
int totalSize = 0;
Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
for (RegionQueue q : queues) {
ConcurrentParallelGatewaySenderQueue prQ = (ConcurrentParallelGatewaySenderQueue) q;
totalSize += prQ.localSize();
}
return totalSize;
}
return -1;
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method checkPRQLocalSize.
/**
* To be used only for ParallelGatewaySender.
*
* @param senderId Id of the ParallelGatewaySender
* @param numQueueEntries Expected number of ParallelGatewaySenderQueue entries
*/
public static void checkPRQLocalSize(String senderId, final int numQueueEntries) {
GatewaySender sender = null;
for (GatewaySender s : cache.getGatewaySenders()) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
if (sender.isParallel()) {
final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
Awaitility.await().atMost(120, TimeUnit.SECONDS).until(() -> {
int size = 0;
for (RegionQueue q : queues) {
ConcurrentParallelGatewaySenderQueue prQ = (ConcurrentParallelGatewaySenderQueue) q;
size += prQ.localSize();
}
assertEquals(" Expected local queue entries: " + numQueueEntries + " but actual entries: " + size, numQueueEntries, size);
});
}
}
Aggregations