use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class PartitionedRegionDataStore method clearAllTempQueueForShadowPR.
protected void clearAllTempQueueForShadowPR(final int bucketId) {
List<PartitionedRegion> colocatedWithList = ColocationHelper.getColocatedChildRegions(partitionedRegion);
for (PartitionedRegion childRegion : colocatedWithList) {
if (childRegion.isShadowPR()) {
AbstractGatewaySender sender = childRegion.getParallelGatewaySender();
if (sender == null) {
return;
}
AbstractGatewaySenderEventProcessor eventProcessor = sender.getEventProcessor();
if (eventProcessor == null) {
return;
}
ConcurrentParallelGatewaySenderQueue queue = (ConcurrentParallelGatewaySenderQueue) eventProcessor.getQueue();
if (queue == null) {
return;
}
BlockingQueue<GatewaySenderEventImpl> tempQueue = queue.getBucketTmpQueue(bucketId);
if (tempQueue != null) {
synchronized (tempQueue) {
for (GatewaySenderEventImpl event : tempQueue) {
event.release();
}
tempQueue.clear();
}
}
}
}
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class ParallelAsyncEventQueueImpl 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();
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class AsyncEventQueueImpl method size.
@Override
public int size() {
AbstractGatewaySenderEventProcessor eventProcessor = ((AbstractGatewaySender) sender).getEventProcessor();
int size = 0;
if (eventProcessor instanceof ConcurrentSerialGatewaySenderEventProcessor) {
Set<RegionQueue> queues = ((ConcurrentSerialGatewaySenderEventProcessor) eventProcessor).getQueues();
Iterator<RegionQueue> itr = queues.iterator();
while (itr.hasNext()) {
size = size + itr.next().size();
}
} else {
size = eventProcessor.getQueue().size();
}
return size;
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor in project geode by apache.
the class PartitionedRegion method destroyParallelGatewaySenderRegion.
public void destroyParallelGatewaySenderRegion(Operation op, boolean cacheWrite, boolean lock, boolean callbackEvents) {
if (logger.isDebugEnabled()) {
logger.debug("Destoying parallel queue region for senders: {}", this.getParallelGatewaySenderIds());
}
boolean keepWaiting = true;
while (true) {
List<String> pausedSenders = new ArrayList<String>();
List<ConcurrentParallelGatewaySenderQueue> parallelQueues = new ArrayList<ConcurrentParallelGatewaySenderQueue>();
isDestroyedForParallelWAN = true;
int countOfQueueRegionsToBeDestroyed = 0;
for (String senderId : this.getParallelGatewaySenderIds()) {
AbstractGatewaySender sender = (AbstractGatewaySender) this.cache.getGatewaySender(senderId);
if (sender == null || sender.getEventProcessor() == null) {
continue;
}
if (cacheWrite) {
// resumed
if (sender.isPaused()) {
pausedSenders.add(senderId);
continue;
}
}
if (pausedSenders.isEmpty()) {
// if there are puase sender then only
// check for other pause senders instead
// of creating list of shadowPR
AbstractGatewaySenderEventProcessor ep = sender.getEventProcessor();
if (ep == null)
continue;
ConcurrentParallelGatewaySenderQueue parallelQueue = (ConcurrentParallelGatewaySenderQueue) ep.getQueue();
PartitionedRegion parallelQueueRegion = parallelQueue.getRegion(this.getFullPath());
// this may be removed in previous iteration
if (parallelQueueRegion == null || parallelQueueRegion.isDestroyed || parallelQueueRegion.isClosed) {
continue;
}
parallelQueues.add(parallelQueue);
countOfQueueRegionsToBeDestroyed++;
}
}
if (!pausedSenders.isEmpty()) {
String exception = null;
if (pausedSenders.size() == 1) {
exception = LocalizedStrings.PartitionedRegion_GATEWAYSENDER_0_IS_PAUSED_RESUME_IT_BEFORE_DESTROYING_USER_REGION_1.toLocalizedString(pausedSenders, this.getName());
} else {
exception = LocalizedStrings.PartitionedRegion_GATEWAYSENDERS_0_ARE_PAUSED_RESUME_THEM_BEFORE_DESTROYING_USER_REGION_1.toLocalizedString(pausedSenders, this.getName());
}
isDestroyedForParallelWAN = false;
throw new GatewaySenderException(exception);
}
if (countOfQueueRegionsToBeDestroyed == 0) {
break;
}
for (ConcurrentParallelGatewaySenderQueue parallelQueue : parallelQueues) {
PartitionedRegion parallelQueueRegion = parallelQueue.getRegion(this.getFullPath());
// keepWaiting : comes from the MAXIMUM_SHUTDOWN_WAIT_TIME case handled
if (cacheWrite && parallelQueueRegion.size() != 0 && keepWaiting) {
continue;
} else {
// In any case, destroy shadow PR locally. distributed destroy of
// userPR will take care of detsroying shadowPR locally on other
// nodes.
RegionEventImpl event = null;
if (op.isClose()) {
// In case of cache close operation, we want SPR's basic destroy to go
// through CACHE_CLOSE condition of postDestroyRegion not
// closePartitionedRegion code
event = new RegionEventImpl(parallelQueueRegion, op, null, false, getMyId(), generateEventID());
} else {
event = new RegionEventImpl(parallelQueueRegion, Operation.REGION_LOCAL_DESTROY, null, false, getMyId(), generateEventID());
}
parallelQueueRegion.basicDestroyRegion(event, false, lock, callbackEvents);
parallelQueue.removeShadowPR(this.getFullPath());
countOfQueueRegionsToBeDestroyed--;
continue;
}
}
if (countOfQueueRegionsToBeDestroyed == 0) {
break;
}
if (cacheWrite) {
if (AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME == -1) {
keepWaiting = true;
try {
Thread.sleep(5000);
} catch (InterruptedException ignore) {
// interrupted
}
} else {
try {
Thread.sleep(AbstractGatewaySender.MAXIMUM_SHUTDOWN_WAIT_TIME * 1000);
} catch (InterruptedException ignore) {
/* ignore */
// interrupted
}
keepWaiting = false;
}
}
}
}
Aggregations