Search in sources :

Example 16 with DistributedRegion

use of org.apache.geode.internal.cache.DistributedRegion in project geode by apache.

the class ParallelGatewaySenderQueue method remove.

@Override
public void remove() throws CacheException {
    if (!this.peekedEvents.isEmpty()) {
        GatewaySenderEventImpl event = this.peekedEvents.remove();
        try {
            PartitionedRegion prQ = null;
            int bucketId = -1;
            Object key = null;
            if (event.getRegion() != null) {
                if (isDREvent(event)) {
                    prQ = this.userRegionNameToshadowPRMap.get(event.getRegion().getFullPath());
                    bucketId = event.getEventId().getBucketID();
                    key = event.getEventId();
                } else {
                    prQ = this.userRegionNameToshadowPRMap.get(ColocationHelper.getLeaderRegion((PartitionedRegion) event.getRegion()).getFullPath());
                    bucketId = event.getBucketId();
                    key = event.getShadowKey();
                }
            } else {
                String regionPath = event.getRegionPath();
                InternalCache cache = this.sender.getCache();
                Region region = (PartitionedRegion) cache.getRegion(regionPath);
                if (region != null && !region.isDestroyed()) {
                    // TODO: We have to get colocated parent region for this region
                    if (region instanceof DistributedRegion) {
                        prQ = this.userRegionNameToshadowPRMap.get(region.getFullPath());
                        event.getBucketId();
                        key = event.getEventId();
                    } else {
                        prQ = this.userRegionNameToshadowPRMap.get(ColocationHelper.getLeaderRegion((PartitionedRegion) region).getFullPath());
                        event.getBucketId();
                        key = event.getShadowKey();
                    }
                }
            }
            if (prQ != null) {
                destroyEventFromQueue(prQ, bucketId, key);
            }
        } finally {
            try {
                event.release();
            } catch (IllegalStateException e) {
                logger.error("Exception caught and logged.  The thread will continue running", e);
            }
        }
    }
}
Also used : PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) InternalCache(org.apache.geode.internal.cache.InternalCache) LocalRegion(org.apache.geode.internal.cache.LocalRegion) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion)

Example 17 with DistributedRegion

use of org.apache.geode.internal.cache.DistributedRegion in project geode by apache.

the class ParallelGatewaySenderImpl method setModifiedEventId.

@Override
protected void setModifiedEventId(EntryEventImpl clonedEvent) {
    int bucketId = -1;
    // merged from 42004
    if (clonedEvent.getRegion() instanceof DistributedRegion) {
        bucketId = PartitionedRegionHelper.getHashKey(clonedEvent.getKey(), getMaxParallelismForReplicatedRegion());
    } else {
        bucketId = PartitionedRegionHelper.getHashKey((EntryOperation) clonedEvent);
    }
    EventID originalEventId = clonedEvent.getEventId();
    long originatingThreadId = ThreadIdentifier.getRealThreadID(originalEventId.getThreadID());
    long newThreadId = ThreadIdentifier.createFakeThreadIDForParallelGSPrimaryBucket(bucketId, originatingThreadId, getEventIdIndex());
    // In case of parallel as all events go through primary buckets
    // we don't need to generate different threadId for secondary buckets
    // as they will be rejected if seen at PR level itself
    EventID newEventId = new EventID(originalEventId.getMembershipID(), newThreadId, originalEventId.getSequenceID(), bucketId);
    if (logger.isDebugEnabled()) {
        logger.debug("{}: Generated event id for event with key={}, bucketId={}, original event id={}, threadId={}, new event id={}, newThreadId={}", this, clonedEvent.getKey(), bucketId, originalEventId, originatingThreadId, newEventId, newThreadId);
    }
    clonedEvent.setEventId(newEventId);
}
Also used : EventID(org.apache.geode.internal.cache.EventID) EntryOperation(org.apache.geode.cache.EntryOperation) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion)

Example 18 with DistributedRegion

use of org.apache.geode.internal.cache.DistributedRegion in project geode by apache.

the class DestroyMessageTest method shouldBeMockable.

@Test
public void shouldBeMockable() throws Exception {
    DestroyMessage mockDestroyMessageX = mock(DestroyMessage.class);
    InternalCacheEvent mockInternalCacheEvent = mock(InternalCacheEvent.class);
    DistributedRegion mockDistributedRegion = mock(DistributedRegion.class);
    when(mockDestroyMessageX.createEvent(eq(mockDistributedRegion))).thenReturn(mockInternalCacheEvent);
    assertThat(mockDestroyMessageX.createEvent(mockDistributedRegion)).isSameAs(mockInternalCacheEvent);
}
Also used : DestroyMessage(org.apache.geode.internal.cache.wan.serial.BatchDestroyOperation.DestroyMessage) InternalCacheEvent(org.apache.geode.internal.cache.InternalCacheEvent) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 19 with DistributedRegion

use of org.apache.geode.internal.cache.DistributedRegion 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 20 with DistributedRegion

use of org.apache.geode.internal.cache.DistributedRegion in project geode by apache.

the class DistributedNoAckRegionDUnitTest method flushIfNecessary.

@Override
protected void flushIfNecessary(Region r) {
    DistributedRegion dr = (DistributedRegion) r;
    Set<InternalDistributedMember> targets = dr.getDistributionAdvisor().adviseCacheOp();
    StateFlushOperation.flushTo(targets, dr);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion)

Aggregations

DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)36 Region (org.apache.geode.cache.Region)25 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)16 LocalRegion (org.apache.geode.internal.cache.LocalRegion)14 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)9 VM (org.apache.geode.test.dunit.VM)9 Test (org.junit.Test)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)8 Cache (org.apache.geode.cache.Cache)7 Host (org.apache.geode.test.dunit.Host)7 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)7 FunctionException (org.apache.geode.cache.execute.FunctionException)6 IOException (java.io.IOException)5 AttributesFactory (org.apache.geode.cache.AttributesFactory)5 CacheException (org.apache.geode.cache.CacheException)5 IgnoredException (org.apache.geode.test.dunit.IgnoredException)5 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)5 Set (java.util.Set)4 CancelException (org.apache.geode.CancelException)4 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)4