use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.
the class SerialGatewaySenderQueue method put.
public synchronized boolean put(Object event) throws CacheException {
GatewaySenderEventImpl eventImpl = (GatewaySenderEventImpl) event;
final Region r = eventImpl.getRegion();
final boolean isPDXRegion = (r instanceof DistributedRegion && r.getName().equals(PeerTypeRegistration.REGION_NAME));
final boolean isWbcl = this.regionName.startsWith(AsyncEventQueueImpl.ASYNC_EVENT_QUEUE_PREFIX);
if (!(isPDXRegion && isWbcl)) {
putAndGetKey(event);
return true;
}
return false;
}
use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.
the class SerialSecondaryGatewayListener method afterCreate.
@Override
public void afterCreate(EntryEvent event) {
if (this.sender.isPrimary()) {
// being sent.
return;
}
// There is a small window where queue has not been created fully yet.
// The underlying region of the queue is created, and it receives afterDestroy callback
final Set<RegionQueue> queues = this.sender.getQueues();
if (queues != null && !queues.isEmpty()) {
this.sender.getStatistics().incQueueSize();
}
// fix bug 35730
// Send event to the event dispatcher
GatewaySenderEventImpl senderEvent = (GatewaySenderEventImpl) event.getNewValue();
this.processor.handlePrimaryEvent(senderEvent);
}
use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.
the class SerialSecondaryGatewayListener method afterDestroy.
@Override
public void afterDestroy(EntryEvent event) {
if (this.sender.isPrimary()) {
return;
}
// fix bug 37603
// There is a small window where queue has not been created fully yet. The region is created,
// and it receives afterDestroy callback.
final Set<RegionQueue> queues = this.sender.getQueues();
if (queues != null && !queues.isEmpty()) {
this.sender.getStatistics().decQueueSize();
}
// Send event to the event dispatcher
Object oldValue = event.getOldValue();
if (oldValue instanceof GatewaySenderEventImpl) {
GatewaySenderEventImpl senderEvent = (GatewaySenderEventImpl) oldValue;
if (logger.isDebugEnabled()) {
logger.debug("Received after Destroy for Secondary event {} the key was {}", senderEvent, event.getKey());
}
this.processor.handlePrimaryDestroy(senderEvent);
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl 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.GatewaySenderEventImpl in project geode by apache.
the class ParallelGatewaySenderQueue method addPeekedEvents.
private void addPeekedEvents(List<GatewaySenderEventImpl> batch, int batchSize) {
if (this.resetLastPeeked) {
// This will prevent repeatedly trying to dispatch non-primary events
for (Iterator<GatewaySenderEventImpl> iterator = peekedEvents.iterator(); iterator.hasNext(); ) {
GatewaySenderEventImpl event = iterator.next();
final int bucketId = event.getBucketId();
final PartitionedRegion region = (PartitionedRegion) event.getRegion();
if (!region.getRegionAdvisor().isPrimaryForBucket(bucketId)) {
iterator.remove();
BucketRegionQueue brq = getBucketRegionQueueByBucketId(getRandomShadowPR(), bucketId);
if (brq != null) {
brq.pushKeyIntoQueue(event.getShadowKey());
}
}
}
if (this.peekedEventsProcessingInProgress) {
// Peeked event processing is in progress. This means that the original peekedEvents
// contained > batch size events due to a reduction in the batch size. Create a batch
// from the peekedEventsProcessing queue.
addPreviouslyPeekedEvents(batch, batchSize);
} else if (peekedEvents.size() <= batchSize) {
// This is the normal case. The connection was lost while processing a batch.
// This recreates the batch from the current peekedEvents.
batch.addAll(peekedEvents);
this.resetLastPeeked = false;
} else {
// The peekedEvents queue is > batch size. This means that the previous batch size was
// reduced due to MessageTooLargeException. Create a batch from the peekedEventsProcessing
// queue.
this.peekedEventsProcessing.addAll(this.peekedEvents);
this.peekedEventsProcessingInProgress = true;
addPreviouslyPeekedEvents(batch, batchSize);
}
if (logger.isDebugEnabled()) {
StringBuffer buffer = new StringBuffer();
for (Object ge : batch) {
buffer.append("event :");
buffer.append(ge);
}
logger.debug("Adding already peeked events to the batch {}", buffer);
}
}
}
Aggregations