DistributedEventTracker implements EventTracker { @Override public VersionTag findVersionTagForSequence(EventID eventID) { EventSequenceNumberHolder evh = getSequenceHolderForEvent(eventID); if (evh == null) { if (logger.isDebugEnabled()) { logger.debug("search for version tag failed as no event is recorded for {}", createThreadIDFromEvent(eventID).expensiveToString()); } return null; } synchronized (evh) { if (logger.isDebugEnabled()) { logger.debug("search for version tag located last event for {}: {}", createThreadIDFromEvent(eventID).expensiveToString(), evh); } if (evh.getLastSequenceNumber() != eventID.getSequenceID()) { return null; } if (logger.isTraceEnabled(LogMarker.DISTRIBUTION_BRIDGE_SERVER_VERBOSE) && evh.getVersionTag() == null) { logger.trace(LogMarker.DISTRIBUTION_BRIDGE_SERVER_VERBOSE, "Could not recover version tag. Found event holder with no version tag for {}", eventID); } return evh.getVersionTag(); } } DistributedEventTracker(InternalCache cache, CancelCriterion stopper, String regionName); @Override void start(); @Override void stop(); @Override void clear(); @Override Map<ThreadIdentifier, EventSequenceNumberHolder> getState(); @Override void recordState(InternalDistributedMember provider,
      Map<ThreadIdentifier, EventSequenceNumberHolder> state); @Override void setInitialized(); @Override void waitOnInitialization(); @Override void recordEvent(InternalCacheEvent event); @Override boolean hasSeenEvent(InternalCacheEvent event); @Override boolean hasSeenEvent(EventID eventID); @Override boolean hasSeenEvent(EventID eventID, InternalCacheEvent tagHolder); @Override VersionTag findVersionTagForSequence(EventID eventID); @Override VersionTag findVersionTagForBulkOp(EventID eventID); @Override String getName(); @Override void syncBulkOp(Runnable r, EventID eventID, boolean partOfTransaction); @Override void recordBulkOpStart(EventID eventID, ThreadIdentifier tid); @Override boolean isInitialized(); @Override boolean isInitialImageProvider(DistributedMember mbr); @Override ConcurrentMap<ThreadIdentifier, BulkOperationHolder> getRecordedBulkOpVersionTags(); @Override ConcurrentMap<ThreadIdentifier, EventSequenceNumberHolder> getRecordedEvents(); @Override String toString();  }
@Test public void returnsNoTagIfNoSequenceForEvent() { EventID eventID = new EventID(new byte[0], 0L, 1L); assertNull(eventTracker.findVersionTagForSequence(eventID)); }
@Test public void returnsNoTagIfSequencesDoNotMatchForEvent() { EventID eventID = new EventID(new byte[0], 0L, 1); recordSequence(eventID); assertNull(eventTracker.findVersionTagForSequence(eventID)); }
@Test public void returnsCorrectTagForEvent() { EventID eventID = new EventID(new byte[0], 0L, 0L); EventSequenceNumberHolder sequenceIdHolder = recordSequence(eventID); assertEquals(sequenceIdHolder.getVersionTag(), eventTracker.findVersionTagForSequence(eventID)); }