@Test void testInitializeTokensWhileAlreadyPresent() { assertThrows(UnableToClaimTokenException.class, () -> testSubject.fetchToken("test1", 1)); }
@Override public TrackingToken fetchToken(String processorName, int segment) { TrackingToken trackingToken = tokens.get(new ProcessAndSegment(processorName, segment)); if (trackingToken == null) { throw new UnableToClaimTokenException("No token was initialized for segment " + segment + " for processor " + processorName); } else if (NULL_TOKEN == trackingToken) { return null; } return trackingToken; }
InMemoryTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) { TrackingToken trackingToken = tokens.get(new ProcessAndSegment(processorName, segment)); if (trackingToken == null) { throw new UnableToClaimTokenException("No token was initialized for segment " + segment + " for processor " + processorName); } else if (NULL_TOKEN == trackingToken) { return null; } return trackingToken; } }
InMemoryTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) { TrackingToken trackingToken = tokens.get(new ProcessAndSegment(processorName, segment)); if (trackingToken == null) { throw new UnableToClaimTokenException("No token was initialized for segment " + segment + " for processor " + processorName); } else if (NULL_TOKEN == trackingToken) { return null; } return trackingToken; }  }
InMemoryTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) { TrackingToken trackingToken = tokens.get(new ProcessAndSegment(processorName, segment)); if (trackingToken == null) { throw new UnableToClaimTokenException("No token was initialized for segment " + segment + " for processor " + processorName); } else if (NULL_TOKEN == trackingToken) { return null; } return trackingToken; }  @Override void initializeTokenSegments(String processorName, int segmentCount); @Override void initializeTokenSegments(String processorName, int segmentCount, TrackingToken initialToken); @Override void storeToken(TrackingToken token, String processorName, int segment); @Override TrackingToken fetchToken(String processorName, int segment); @Override void releaseClaim(String processorName, int segment); @Override void deleteToken(String processorName, int segment); @Override void initializeSegment(TrackingToken token, String processorName, int segment); @Override boolean requiresExplicitSegmentInitialization(); @Override int[] fetchSegments(String processorName); @Override Optional<String> retrieveStorageIdentifier(); }
InMemoryTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) { TrackingToken trackingToken = tokens.get(new ProcessAndSegment(processorName, segment)); if (trackingToken == null) { throw new UnableToClaimTokenException("No token was initialized for segment " + segment + " for processor " + processorName); } else if (NULL_TOKEN == trackingToken) { return null; } return trackingToken; }  @Override void initializeTokenSegments(String processorName, int segmentCount); @Override void initializeTokenSegments(String processorName, int segmentCount, TrackingToken initialToken); @Override void storeToken(TrackingToken token, String processorName, int segment); @Override TrackingToken fetchToken(String processorName, int segment); @Override void releaseClaim(String processorName, int segment); @Override void deleteToken(String processorName, int segment); @Override void initializeSegment(TrackingToken token, String processorName, int segment); @Override boolean requiresExplicitSegmentInitialization(); @Override int[] fetchSegments(String processorName); @Override Optional<String> retrieveStorageIdentifier();  }