AbstractRegionEntry implements HashRegionEntry<Object, Object> { public void processVersionTag(EntryEvent cacheEvent) { processVersionTag(cacheEvent, true); } protected  AbstractRegionEntry(RegionEntryContext context,
      @Retained(ABSTRACT_REGION_ENTRY_PREPARE_VALUE_FOR_CACHE) Object value); @Override @SuppressWarnings("IMSE_DONT_CATCH_IMSE") boolean dispatchListenerEvents(final EntryEventImpl event); @Override long getLastAccessed(); @Override long getHitCount(); @Override long getMissCount(); void setLastModified(long lastModified); @Override void txDidDestroy(long currentTime); @Override void updateStatsForPut(long lastModifiedTime, long lastAccessedTime); @Override void setRecentlyUsed(RegionEntryContext context); @Override void updateStatsForGet(boolean hit, long time); @Override void resetCounts(); @Override void removePhase1(InternalRegion region, boolean clear); @Override void removePhase2(); @Override void makeTombstone(InternalRegion region, VersionTag version); @Override void setValueWithTombstoneCheck(@Unretained Object v, EntryEvent e); @Override boolean isRemoved(); @Override boolean isDestroyedOrRemoved(); @Override boolean isDestroyedOrRemovedButNotTombstone(); @Override boolean isTombstone(); @Override boolean isRemovedPhase2(); @Override boolean fillInValue(InternalRegion region,
      @Retained(ABSTRACT_REGION_ENTRY_FILL_IN_VALUE) Entry entry, ByteArrayDataInput in,
      DistributionManager mgr, final KnownVersion version); @Override boolean isOverflowedToDisk(InternalRegion region,
      DistributedRegion.DiskPosition diskPosition); @Override Object getValue(RegionEntryContext context); @Override @Retained Object getValueRetain(RegionEntryContext context); @Override @Released void setValue(RegionEntryContext context, @Unretained Object value); @Override void setValue(RegionEntryContext context, Object value, EntryEventImpl event); @Override Object getValueInVM(RegionEntryContext context); @Override Object getValueInVMOrDiskWithoutFaultIn(InternalRegion region); @Override @Retained Object getValueOffHeapOrDiskWithoutFaultIn(InternalRegion region); @Override Object getValueOnDisk(InternalRegion region); @Override Object getSerializedValueOnDisk(final InternalRegion region); @Override Object getValueOnDiskOrBuffer(InternalRegion region); @Override boolean initialImagePut(final InternalRegion region, final long lastModified,
      Object newValue, boolean wasRecovered, boolean acceptedVersionTag); @Override boolean initialImageInit(final InternalRegion region, final long lastModified,
      final Object newValue, final boolean create, final boolean wasRecovered,
      final boolean acceptedVersionTag); @Override @Released boolean destroy(InternalRegion region, EntryEventImpl event, boolean inTokenMode,
      boolean cacheWrite, @Unretained Object expectedOldValue, boolean forceDestroy,
      boolean removeRecoveredEntry); static boolean checkExpectedOldValue(@Unretained Object expectedOldValue,
      @Unretained Object actualValue, InternalRegion region); @Override abstract Object getKey(); @Override boolean isKeyEqual(Object k); @Override long getLastModified(); @Override @Retained(ABSTRACT_REGION_ENTRY_PREPARE_VALUE_FOR_CACHE) Object prepareValueForCache(RegionEntryContext r,
      @Retained(ABSTRACT_REGION_ENTRY_PREPARE_VALUE_FOR_CACHE) Object val, boolean isEntryUpdate); @Override @Retained(ABSTRACT_REGION_ENTRY_PREPARE_VALUE_FOR_CACHE) Object prepareValueForCache(RegionEntryContext r,
      @Retained(ABSTRACT_REGION_ENTRY_PREPARE_VALUE_FOR_CACHE) Object val, EntryEventImpl event,
      boolean isEntryUpdate); @Override @Unretained Object getValue(); @Override boolean isUpdateInProgress(); @Override void setUpdateInProgress(final boolean underUpdate); @Override boolean isCacheListenerInvocationInProgress(); @Override void setCacheListenerInvocationInProgress(final boolean isListenerInvoked); @Override synchronized boolean isInUseByTransaction(); @Override synchronized void incRefCount(); @Override synchronized void decRefCount(EvictionList evictionList, InternalRegion region); @Override synchronized void resetRefCount(EvictionList evictionList); @Override Token getValueAsToken(); @Override @Retained Object getTransformedValue(); @Override boolean getValueWasResultOfSearch(); @Override void setValueResultOfSearch(boolean v); boolean hasValidVersion(); @Override boolean hasStats(); @Override Object getMapValue(); @Override void setMapValue(final Object newValue); @Override String toString(); @Override VersionTag generateVersionTag(VersionSource member, boolean withDelta,
      InternalRegion region, EntryEventImpl event); void processVersionTag(EntryEvent cacheEvent); @Override VersionStamp getVersionStamp(); @Override boolean isValueNull(); @Override boolean isInvalid(); @Override boolean isDestroyed(); @Override void setValueToNull(); @Override boolean isInvalidOrRemoved(); @Override @Retained Object getValueRetain(RegionEntryContext context, boolean decompress); @Override void returnToPool(); @Override boolean isEvicted();  }
@Test public void applyingGatewayEventsFromDifferentDSShouldAcceptBiggerTimestamp() { GemFireCacheImpl cache = mock(GemFireCacheImpl.class); LocalRegion lr = mock(LocalRegion.class); String value = "value"; AbstractRegionEntry re = new TestableRegionEntry(lr, value); InternalDistributedMember member1 = mock(InternalDistributedMember.class); EntryEventImpl entryEvent1 = new EntryEventImpl(); entryEvent1.setRegion(lr); when(lr.getCache()).thenReturn(cache); when(cache.getGatewayConflictResolver()).thenReturn(null); VersionTag tag1 = VersionTag.create(member1); tag1.setVersionTimeStamp(2); tag1.setDistributedSystemId(1); tag1.setIsGatewayTag(true); VersionTag tag2 = VersionTag.create(member1); tag2.setVersionTimeStamp(1); tag2.setDistributedSystemId(2); tag2.setIsGatewayTag(true); ((TestableRegionEntry) re).setVersions(tag2); assertEquals(2, ((TestableRegionEntry) re).getDistributedSystemId()); entryEvent1.setVersionTag(tag1); re.processVersionTag(entryEvent1); }
@Test public void applyingGatewayEventsFromSmallerDSWithSameTimestampShouldThrowCMEIfNoResolver() { GemFireCacheImpl cache = mock(GemFireCacheImpl.class); LocalRegion lr = mock(LocalRegion.class); String value = "value"; AbstractRegionEntry re = new TestableRegionEntry(lr, value); InternalDistributedMember member1 = mock(InternalDistributedMember.class); EntryEventImpl entryEvent1 = new EntryEventImpl(); entryEvent1.setRegion(lr); when(lr.getCache()).thenReturn(cache); when(cache.getGatewayConflictResolver()).thenReturn(null); VersionTag tag1 = VersionTag.create(member1); tag1.setVersionTimeStamp(1); tag1.setDistributedSystemId(1); tag1.setIsGatewayTag(true); VersionTag tag2 = VersionTag.create(member1); tag2.setVersionTimeStamp(1); tag2.setDistributedSystemId(2); tag2.setIsGatewayTag(true); ((TestableRegionEntry) re).setVersions(tag2); assertEquals(2, ((TestableRegionEntry) re).getDistributedSystemId()); entryEvent1.setVersionTag(tag1); expectedException.expect(ConcurrentCacheModificationException.class); expectedException.expectMessage("conflicting WAN event detected"); re.processVersionTag(entryEvent1); }
@Test public void resolverShouldHandleConflictEventsFromDifferentDS() { GemFireCacheImpl cache = mock(GemFireCacheImpl.class); LocalRegion lr = mock(LocalRegion.class); String value = "value"; AbstractRegionEntry re = new TestableRegionEntry(lr, value); InternalDistributedMember member1 = mock(InternalDistributedMember.class); EntryEventImpl entryEvent1 = new EntryEventImpl(); entryEvent1 = Mockito.spy(entryEvent1); entryEvent1.setRegion(lr); when(lr.getCache()).thenReturn(cache); GatewayConflictResolver resolver = mock(GatewayConflictResolver.class); when(cache.getGatewayConflictResolver()).thenReturn(resolver); doNothing().when(resolver).onEvent(any(), any()); TimestampedEntryEventImpl timestampedEvent = mock(TimestampedEntryEventImpl.class); doReturn(timestampedEvent).when(entryEvent1).getTimestampedEvent(anyInt(), anyInt(), anyLong(), anyLong()); when(timestampedEvent.hasOldValue()).thenReturn(true); VersionTag tag1 = VersionTag.create(member1); tag1.setVersionTimeStamp(1); tag1.setDistributedSystemId(1); tag1.setIsGatewayTag(true); VersionTag tag2 = VersionTag.create(member1); tag2.setVersionTimeStamp(1); tag2.setDistributedSystemId(2); tag2.setIsGatewayTag(true); ((TestableRegionEntry) re).setVersions(tag2); assertEquals(2, ((TestableRegionEntry) re).getDistributedSystemId()); entryEvent1.setVersionTag(tag1); re.processVersionTag(entryEvent1); verify(resolver, Mockito.times(1)).onEvent(any(), any()); }