Search in sources :

Example 16 with GatewaySenderEventImpl

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;
}
Also used : GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion)

Example 17 with GatewaySenderEventImpl

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);
}
Also used : GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 18 with GatewaySenderEventImpl

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);
    }
}
Also used : GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 19 with GatewaySenderEventImpl

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();
                }
            }
        }
    }
}
Also used : ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor)

Example 20 with GatewaySenderEventImpl

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);
        }
    }
}
Also used : BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl)

Aggregations

GatewaySenderEventImpl (org.apache.geode.internal.cache.wan.GatewaySenderEventImpl)22 Region (org.apache.geode.cache.Region)5 AbstractBucketRegionQueue (org.apache.geode.internal.cache.AbstractBucketRegionQueue)5 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)5 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)5 ArrayList (java.util.ArrayList)4 BucketRegionQueue (org.apache.geode.internal.cache.BucketRegionQueue)4 LocalRegion (org.apache.geode.internal.cache.LocalRegion)4 UnitTest (org.apache.geode.test.junit.categories.UnitTest)4 Test (org.junit.Test)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Queue (java.util.Queue)3 EventID (org.apache.geode.internal.cache.EventID)3 GatewaySenderStats (org.apache.geode.internal.cache.wan.GatewaySenderStats)3 BucketRegion (org.apache.geode.internal.cache.BucketRegion)2 RegionQueue (org.apache.geode.internal.cache.RegionQueue)2 EventWrapper (org.apache.geode.internal.cache.wan.AbstractGatewaySender.EventWrapper)2 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)2 StoredObject (org.apache.geode.internal.offheap.StoredObject)2