use of org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue 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.parallel.ConcurrentParallelGatewaySenderQueue in project geode by apache.
the class AbstractGatewaySender method destroy.
public void destroy(boolean initiator) {
try {
this.getLifeCycleLock().writeLock().lock();
// first, check if this sender is attached to any region. If so, throw
// GatewaySenderException
Set<LocalRegion> regions = this.cache.getApplicationRegions();
Iterator regionItr = regions.iterator();
while (regionItr.hasNext()) {
LocalRegion region = (LocalRegion) regionItr.next();
if (region.getAttributes().getGatewaySenderIds().contains(this.id)) {
throw new GatewaySenderException(LocalizedStrings.GatewaySender_COULD_NOT_DESTROY_SENDER_AS_IT_IS_STILL_IN_USE.toLocalizedString(this));
}
}
// close the GatewaySenderAdvisor
GatewaySenderAdvisor advisor = this.getSenderAdvisor();
if (advisor != null) {
if (logger.isDebugEnabled()) {
logger.debug("Stopping the GatewaySender advisor");
}
advisor.close();
}
// remove the sender from the cache
this.cache.removeGatewaySender(this);
// destroy the region underneath the sender's queue
if (initiator) {
Set<RegionQueue> regionQueues = getQueues();
if (regionQueues != null) {
for (RegionQueue regionQueue : regionQueues) {
try {
if (regionQueue instanceof ConcurrentParallelGatewaySenderQueue) {
Set<PartitionedRegion> queueRegions = ((ConcurrentParallelGatewaySenderQueue) regionQueue).getRegions();
for (PartitionedRegion queueRegion : queueRegions) {
queueRegion.destroyRegion();
}
} else {
// For SerialGatewaySenderQueue, do local destroy
regionQueue.getRegion().localDestroyRegion();
}
}// by several nodes simultaneously
catch (RegionDestroyedException e) {
// the region might have already been destroyed by other node. Just
// log
// the exception.
this.logger.info(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_REGION_0_UNDERLYING_GATEWAYSENDER_1_IS_ALREADY_DESTROYED, new Object[] { e.getRegionFullPath(), this }));
}
}
}
// END if (regionQueues != null)
}
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
}
use of org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue in project geode by apache.
the class CommonParallelGatewaySenderDUnitTest method validateParallelSenderQueueAllBucketsDrained.
public static void validateParallelSenderQueueAllBucketsDrained(final String senderId) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
ConcurrentParallelGatewaySenderQueue regionQueue = (ConcurrentParallelGatewaySenderQueue) ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
Set<PartitionedRegion> shadowPRs = (Set<PartitionedRegion>) regionQueue.getRegions();
for (PartitionedRegion shadowPR : shadowPRs) {
Set<BucketRegion> buckets = shadowPR.getDataStore().getAllLocalBucketRegions();
for (final BucketRegion bucket : buckets) {
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
if (bucket.keySet().size() == 0) {
LogWriterUtils.getLogWriter().info("Bucket " + bucket.getId() + " is empty");
return true;
}
return false;
}
public String description() {
return "Expected bucket entries for bucket: " + bucket.getId() + " is: 0 but actual entries: " + bucket.keySet().size() + " This bucket isPrimary: " + bucket.getBucketAdvisor().isPrimary() + " KEYSET: " + bucket.keySet();
}
};
Wait.waitForCriterion(wc, 180000, 50, true);
}
// for loop ends
}
}
use of org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue in project geode by apache.
the class PartitionedRegion method addGatewaySenderId.
public void addGatewaySenderId(String gatewaySenderId) {
super.addGatewaySenderId(gatewaySenderId);
new UpdateAttributesProcessor(this).distribute();
((PartitionedRegion) this).distributeUpdatedProfileOnSenderCreation();
GatewaySender sender = getCache().getGatewaySender(gatewaySenderId);
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.parallel.ConcurrentParallelGatewaySenderQueue 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();
}
}
}
}
}
Aggregations