use of org.apache.geode.internal.cache.wan.AbstractGatewaySender 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.AbstractGatewaySender in project geode by apache.
the class AsyncEventQueueImpl method destroy.
public void destroy(boolean initiator) {
InternalCache cache = ((AbstractGatewaySender) this.sender).getCache();
((AbstractGatewaySender) this.sender).destroy(initiator);
cache.removeAsyncEventQueue(this);
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySender 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;
}
}
}
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySender in project geode by apache.
the class PartitionedRegion method addAsyncEventQueueId.
public void addAsyncEventQueueId(String asyncEventQueueId) {
super.addAsyncEventQueueId(asyncEventQueueId);
new UpdateAttributesProcessor(this).distribute();
((PartitionedRegion) this).distributeUpdatedProfileOnSenderCreation();
GatewaySender sender = getCache().getGatewaySender(AsyncEventQueueImpl.getSenderIdFromAsyncEventQueueId(asyncEventQueueId));
if (sender != null && sender.isParallel() && sender.isRunning()) {
AbstractGatewaySender senderImpl = (AbstractGatewaySender) sender;
((ConcurrentParallelGatewaySenderQueue) senderImpl.getQueues().toArray(new RegionQueue[1])[0]).addShadowPartitionedRegionForUserPR(this);
}
}
use of org.apache.geode.internal.cache.wan.AbstractGatewaySender in project geode by apache.
the class LocalRegion method notifyGatewaySender.
protected void notifyGatewaySender(EnumListenerEvent operation, EntryEventImpl event) {
if (isPdxTypesRegion() || event.isConcurrencyConflict()) {
// isConcurrencyConflict is usually a concurrent cache modification problem
return;
}
// Return if the inhibit all notifications flag is set
if (event.inhibitAllNotifications()) {
if (logger.isDebugEnabled()) {
logger.debug("Notification inhibited for key {}", event);
}
return;
}
checkSameSenderIdsAvailableOnAllNodes();
Set<String> allGatewaySenderIds;
if (event.getOperation() == Operation.UPDATE_VERSION_STAMP) {
allGatewaySenderIds = getGatewaySenderIds();
} else {
allGatewaySenderIds = getAllGatewaySenderIds();
}
List<Integer> allRemoteDSIds = getRemoteDsIds(allGatewaySenderIds);
if (allRemoteDSIds != null) {
for (GatewaySender sender : getCache().getAllGatewaySenders()) {
if (allGatewaySenderIds.contains(sender.getId())) {
// TODO: This is a BUG. Why return and not continue?
if (!this.getDataPolicy().withStorage() && sender.isParallel()) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Notifying the GatewaySender : {}", sender.getId());
}
((AbstractGatewaySender) sender).distribute(operation, event, allRemoteDSIds);
}
}
}
}
Aggregations