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);
}
}
}
}
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);
}
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);
}
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;
}
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);
}
Aggregations