@Transactional @Test void testInitializeTokensWhileAlreadyPresent() { assertThrows(UnableToClaimTokenException.class, () -> tokenStore.fetchToken("test1", 1)); }
@Override public TrackingToken fetchToken(String processorName, int segment) throws UnableToClaimTokenException { Connection connection = getConnection(); try { return executeQuery(connection, c -> selectForUpdate(c, processorName, segment), resultSet -> loadToken(connection, resultSet, processorName, segment), e -> new JdbcException( format("Could not load token for processor [%s] and segment [%d]", processorName, segment), e)); } finally { closeQuietly(connection); } }
JdbcTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) throws UnableToClaimTokenException { Connection connection = getConnection(); try { return executeQuery(connection, c -> selectForUpdate(c, processorName, segment), resultSet -> loadToken(connection, resultSet, processorName, segment), e -> new JdbcException( format("Could not load token for processor [%s] and segment [%d]", processorName, segment), e)); } finally { closeQuietly(connection); } } }
JdbcTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) throws UnableToClaimTokenException { Connection connection = getConnection(); try { return executeQuery(connection, c -> selectForUpdate(c, processorName, segment), resultSet -> loadToken(connection, resultSet, processorName, segment), e -> new JdbcException( format("Could not load token for processor [%s] and segment [%d]", processorName, segment), e)); } finally { closeQuietly(connection); } } protected  JdbcTokenStore(Builder builder); }
JdbcTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) throws UnableToClaimTokenException { Connection connection = getConnection(); try { return executeQuery(connection, c -> selectForUpdate(c, processorName, segment), resultSet -> loadToken(connection, resultSet, processorName, segment), e -> new JdbcException( format("Could not load token for processor [%s] and segment [%d]", processorName, segment), e)); } finally { closeQuietly(connection); } } protected  JdbcTokenStore(Builder builder); static Builder builder(); void createSchema(TokenTableFactory schemaFactory); @Override void initializeTokenSegments(String processorName, int segmentCount); @Override void initializeTokenSegments(String processorName, int segmentCount, TrackingToken initialToken); @Override void initializeSegment(TrackingToken token, String processorName, int segment); @Override boolean requiresExplicitSegmentInitialization(); @Override Optional<String> retrieveStorageIdentifier(); Serializer serializer(); @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 int[] fetchSegments(String processorName); }
JdbcTokenStore implements TokenStore { @Override public TrackingToken fetchToken(String processorName, int segment) throws UnableToClaimTokenException { Connection connection = getConnection(); try { return executeQuery(connection, c -> selectForUpdate(c, processorName, segment), resultSet -> loadToken(connection, resultSet, processorName, segment), e -> new JdbcException( format("Could not load token for processor [%s] and segment [%d]", processorName, segment), e)); } finally { closeQuietly(connection); } } protected  JdbcTokenStore(Builder builder); static Builder builder(); void createSchema(TokenTableFactory schemaFactory); @Override void initializeTokenSegments(String processorName, int segmentCount); @Override void initializeTokenSegments(String processorName, int segmentCount, TrackingToken initialToken); @Override void initializeSegment(TrackingToken token, String processorName, int segment); @Override boolean requiresExplicitSegmentInitialization(); @Override Optional<String> retrieveStorageIdentifier(); Serializer serializer(); @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 int[] fetchSegments(String processorName);  }