@Test public void consistentNormalBatchesAfterFullBatchesGravitatesTowardsInitialPause() { sweepTwentyIterationsWithResult(SUCCESS_TOO_SLOW); sweepTwentyIterationsWithResult(SUCCESS); long nextPause = delay.getNextPause(SUCCESS); assertThat(nextPause).isGreaterThanOrEqualTo((long) (INITIAL_DELAY * 0.95)); assertThat(nextPause).isLessThanOrEqualTo((long) (INITIAL_DELAY * 1.05)); }
long getNextPause(SweepIterationResult result) { return SweepIterationResults.caseOf(result) .success(this::updateCurrentPauseAndGet) .unableToAcquireShard_(maxPauseMillis) .insufficientConsistency_(BACKOFF) .otherError_(maxPauseMillis) .disabled_(BACKOFF); }
SweepDelay { long getNextPause(SweepIterationResult result) { return SweepIterationResults.caseOf(result) .success(this::updateCurrentPauseAndGet) .unableToAcquireShard_(maxPauseMillis) .insufficientConsistency_(BACKOFF) .otherError_(maxPauseMillis) .disabled_(BACKOFF); } }
SweepDelay { long getNextPause(SweepIterationResult result) { return SweepIterationResults.caseOf(result) .success(this::updateCurrentPauseAndGet) .unableToAcquireShard_(maxPauseMillis) .insufficientConsistency_(BACKOFF) .otherError_(maxPauseMillis) .disabled_(BACKOFF); } SweepDelay(long configPause); }
SweepDelay { long getNextPause(SweepIterationResult result) { return SweepIterationResults.caseOf(result) .success(this::updateCurrentPauseAndGet) .unableToAcquireShard_(maxPauseMillis) .insufficientConsistency_(BACKOFF) .otherError_(maxPauseMillis) .disabled_(BACKOFF); } SweepDelay(long configPause);  }
SweepDelay { long getNextPause(SweepIterationResult result) { return SweepIterationResults.caseOf(result) .success(this::updateCurrentPauseAndGet) .unableToAcquireShard_(maxPauseMillis) .insufficientConsistency_(BACKOFF) .otherError_(maxPauseMillis) .disabled_(BACKOFF); } SweepDelay(long configPause);   }