@Test public void returnsConsistentIfBoundIsBelowFreshTimestamp() { TimestampCorroborationConsistencyCheck check = createForTimestamps(10, 20); assertThat(check.apply(mock(TransactionManager.class))) .isEqualTo(ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.CONSISTENT) .build()); }
@Override public TransactionManagerConsistencyResult apply(TransactionManager transactionManager) { long lowerBound; long freshTimestamp; try { lowerBound = conservativeBound().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a lower bound on timestamps, so we don't know if our transaction manager" + " is consistent.", e); return indeterminateResultForException(e); } try { freshTimestamp = freshTimestampSource().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a fresh timestamp, so we don't know if our transaction manager is" + " consistent.", e); return indeterminateResultForException(e); } if (freshTimestamp <= lowerBound) { log.error("Your AtlasDB client believes that a strict lower bound for the timestamp was {} (typically by" + " reading the unreadable timestamp), but that's newer than a fresh timestamp of {}, which" + " implies clocks went back. If using TimeLock, this could be because timestamp bounds" + " were not migrated properly - which can happen if you've moved TimeLock Server without" + " moving its persistent state. For safety, AtlasDB will refuse to start.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.TERMINAL) .reasonForInconsistency(clocksWentBackwards(lowerBound, freshTimestamp)) .build(); } log.info("Passed timestamp corroboration consistency check; expected a strict lower bound of {}, which was" + " lower than a fresh timestamp of {}.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.CONSISTENT) .build(); }
TimestampCorroborationConsistencyCheck implements TransactionManagerConsistencyCheck { @Override public TransactionManagerConsistencyResult apply(TransactionManager transactionManager) { long lowerBound; long freshTimestamp; try { lowerBound = conservativeBound().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a lower bound on timestamps, so we don't know if our transaction manager" + " is consistent.", e); return indeterminateResultForException(e); } try { freshTimestamp = freshTimestampSource().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a fresh timestamp, so we don't know if our transaction manager is" + " consistent.", e); return indeterminateResultForException(e); } if (freshTimestamp <= lowerBound) { log.error("Your AtlasDB client believes that a strict lower bound for the timestamp was {} (typically by" + " reading the unreadable timestamp), but that's newer than a fresh timestamp of {}, which" + " implies clocks went back. If using TimeLock, this could be because timestamp bounds" + " were not migrated properly - which can happen if you've moved TimeLock Server without" + " moving its persistent state. For safety, AtlasDB will refuse to start.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.TERMINAL) .reasonForInconsistency(clocksWentBackwards(lowerBound, freshTimestamp)) .build(); } log.info("Passed timestamp corroboration consistency check; expected a strict lower bound of {}, which was" + " lower than a fresh timestamp of {}.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.CONSISTENT) .build(); } }
TimestampCorroborationConsistencyCheck implements TransactionManagerConsistencyCheck { @Override public TransactionManagerConsistencyResult apply(TransactionManager transactionManager) { long lowerBound; long freshTimestamp; try { lowerBound = conservativeBound().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a lower bound on timestamps, so we don't know if our transaction manager" + " is consistent.", e); return indeterminateResultForException(e); } try { freshTimestamp = freshTimestampSource().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a fresh timestamp, so we don't know if our transaction manager is" + " consistent.", e); return indeterminateResultForException(e); } if (freshTimestamp <= lowerBound) { log.error("Your AtlasDB client believes that a strict lower bound for the timestamp was {} (typically by" + " reading the unreadable timestamp), but that's newer than a fresh timestamp of {}, which" + " implies clocks went back. If using TimeLock, this could be because timestamp bounds" + " were not migrated properly - which can happen if you've moved TimeLock Server without" + " moving its persistent state. For safety, AtlasDB will refuse to start.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.TERMINAL) .reasonForInconsistency(clocksWentBackwards(lowerBound, freshTimestamp)) .build(); } log.info("Passed timestamp corroboration consistency check; expected a strict lower bound of {}, which was" + " lower than a fresh timestamp of {}.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.CONSISTENT) .build(); }  }
TimestampCorroborationConsistencyCheck implements TransactionManagerConsistencyCheck { @Override public TransactionManagerConsistencyResult apply(TransactionManager transactionManager) { long lowerBound; long freshTimestamp; try { lowerBound = conservativeBound().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a lower bound on timestamps, so we don't know if our transaction manager" + " is consistent.", e); return indeterminateResultForException(e); } try { freshTimestamp = freshTimestampSource().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a fresh timestamp, so we don't know if our transaction manager is" + " consistent.", e); return indeterminateResultForException(e); } if (freshTimestamp <= lowerBound) { log.error("Your AtlasDB client believes that a strict lower bound for the timestamp was {} (typically by" + " reading the unreadable timestamp), but that's newer than a fresh timestamp of {}, which" + " implies clocks went back. If using TimeLock, this could be because timestamp bounds" + " were not migrated properly - which can happen if you've moved TimeLock Server without" + " moving its persistent state. For safety, AtlasDB will refuse to start.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.TERMINAL) .reasonForInconsistency(clocksWentBackwards(lowerBound, freshTimestamp)) .build(); } log.info("Passed timestamp corroboration consistency check; expected a strict lower bound of {}, which was" + " lower than a fresh timestamp of {}.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.CONSISTENT) .build(); }  @Override TransactionManagerConsistencyResult apply(TransactionManager transactionManager); }
TimestampCorroborationConsistencyCheck implements TransactionManagerConsistencyCheck { @Override public TransactionManagerConsistencyResult apply(TransactionManager transactionManager) { long lowerBound; long freshTimestamp; try { lowerBound = conservativeBound().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a lower bound on timestamps, so we don't know if our transaction manager" + " is consistent.", e); return indeterminateResultForException(e); } try { freshTimestamp = freshTimestampSource().applyAsLong(transactionManager); } catch (Exception e) { log.warn("Could not obtain a fresh timestamp, so we don't know if our transaction manager is" + " consistent.", e); return indeterminateResultForException(e); } if (freshTimestamp <= lowerBound) { log.error("Your AtlasDB client believes that a strict lower bound for the timestamp was {} (typically by" + " reading the unreadable timestamp), but that's newer than a fresh timestamp of {}, which" + " implies clocks went back. If using TimeLock, this could be because timestamp bounds" + " were not migrated properly - which can happen if you've moved TimeLock Server without" + " moving its persistent state. For safety, AtlasDB will refuse to start.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.TERMINAL) .reasonForInconsistency(clocksWentBackwards(lowerBound, freshTimestamp)) .build(); } log.info("Passed timestamp corroboration consistency check; expected a strict lower bound of {}, which was" + " lower than a fresh timestamp of {}.", SafeArg.of("timestampLowerBound", lowerBound), SafeArg.of("freshTimestamp", freshTimestamp)); return ImmutableTransactionManagerConsistencyResult.builder() .consistencyState(TransactionManagerConsistencyResult.ConsistencyState.CONSISTENT) .build(); }  @Override TransactionManagerConsistencyResult apply(TransactionManager transactionManager);  }