@Test public void testNextBackoffNoJitterMultipleCalls() { BoundedExponentialBackoff backoff = new BoundedExponentialBackoff(INITIAL_BACKOFF_MS, MAX_BACKOFF_MS, 0); assertThat(backoff.nextBackoff()).isEqualTo(1); assertThat(backoff.nextBackoff()).isEqualTo(2); assertThat(backoff.nextBackoff()).isEqualTo(4); assertThat(backoff.nextBackoff()).isEqualTo(8); assertThat(backoff.nextBackoff()).isEqualTo(MAX_BACKOFF_MS); }
long nextBackoff() { int jitter = mJitterMillis == 0 ? 0 : mRandom.nextInt(mJitterMillis); long backoff = mCurrentBackoffDurationMillis + (long) jitter; mCurrentBackoffDurationMillis <<= 1; if (mCurrentBackoffDurationMillis > mMaxBackoffMillis) { mCurrentBackoffDurationMillis = mMaxBackoffMillis; } return backoff; }
BoundedExponentialBackoff { long nextBackoff() { int jitter = mJitterMillis == 0 ? 0 : mRandom.nextInt(mJitterMillis); long backoff = mCurrentBackoffDurationMillis + (long) jitter; mCurrentBackoffDurationMillis <<= 1; if (mCurrentBackoffDurationMillis > mMaxBackoffMillis) { mCurrentBackoffDurationMillis = mMaxBackoffMillis; } return backoff; } }
BoundedExponentialBackoff { long nextBackoff() { int jitter = mJitterMillis == 0 ? 0 : mRandom.nextInt(mJitterMillis); long backoff = mCurrentBackoffDurationMillis + (long) jitter; mCurrentBackoffDurationMillis <<= 1; if (mCurrentBackoffDurationMillis > mMaxBackoffMillis) { mCurrentBackoffDurationMillis = mMaxBackoffMillis; } return backoff; } BoundedExponentialBackoff(long initialBackoffMillis, long maxBackoffMillis, int jitterMillis); }
BoundedExponentialBackoff { long nextBackoff() { int jitter = mJitterMillis == 0 ? 0 : mRandom.nextInt(mJitterMillis); long backoff = mCurrentBackoffDurationMillis + (long) jitter; mCurrentBackoffDurationMillis <<= 1; if (mCurrentBackoffDurationMillis > mMaxBackoffMillis) { mCurrentBackoffDurationMillis = mMaxBackoffMillis; } return backoff; } BoundedExponentialBackoff(long initialBackoffMillis, long maxBackoffMillis, int jitterMillis);  }
BoundedExponentialBackoff { long nextBackoff() { int jitter = mJitterMillis == 0 ? 0 : mRandom.nextInt(mJitterMillis); long backoff = mCurrentBackoffDurationMillis + (long) jitter; mCurrentBackoffDurationMillis <<= 1; if (mCurrentBackoffDurationMillis > mMaxBackoffMillis) { mCurrentBackoffDurationMillis = mMaxBackoffMillis; } return backoff; } BoundedExponentialBackoff(long initialBackoffMillis, long maxBackoffMillis, int jitterMillis);   }