@Test public void testFirstIntervalEqualsRoundTripTime() { long first = ExponentialBackoff.calculateExpiry(0, ONE_HOUR, 0); assertEquals(2 * ONE_HOUR, first); }
static long calculateExpiry(long now, int maxLatency, int txCount) { if (now < 0) throw new IllegalArgumentException(); if (maxLatency <= 0) throw new IllegalArgumentException(); if (txCount < 0) throw new IllegalArgumentException(); long roundTrip = maxLatency * 2L; for (int i = 0; i < txCount; i++) { roundTrip <<= 1; if (roundTrip < 0) return Long.MAX_VALUE; } long expiry = now + roundTrip; return expiry < 0 ? Long.MAX_VALUE : expiry; }
ExponentialBackoff { static long calculateExpiry(long now, int maxLatency, int txCount) { if (now < 0) throw new IllegalArgumentException(); if (maxLatency <= 0) throw new IllegalArgumentException(); if (txCount < 0) throw new IllegalArgumentException(); long roundTrip = maxLatency * 2L; for (int i = 0; i < txCount; i++) { roundTrip <<= 1; if (roundTrip < 0) return Long.MAX_VALUE; } long expiry = now + roundTrip; return expiry < 0 ? Long.MAX_VALUE : expiry; } }
ExponentialBackoff { static long calculateExpiry(long now, int maxLatency, int txCount) { if (now < 0) throw new IllegalArgumentException(); if (maxLatency <= 0) throw new IllegalArgumentException(); if (txCount < 0) throw new IllegalArgumentException(); long roundTrip = maxLatency * 2L; for (int i = 0; i < txCount; i++) { roundTrip <<= 1; if (roundTrip < 0) return Long.MAX_VALUE; } long expiry = now + roundTrip; return expiry < 0 ? Long.MAX_VALUE : expiry; }  }
ExponentialBackoff { static long calculateExpiry(long now, int maxLatency, int txCount) { if (now < 0) throw new IllegalArgumentException(); if (maxLatency <= 0) throw new IllegalArgumentException(); if (txCount < 0) throw new IllegalArgumentException(); long roundTrip = maxLatency * 2L; for (int i = 0; i < txCount; i++) { roundTrip <<= 1; if (roundTrip < 0) return Long.MAX_VALUE; } long expiry = now + roundTrip; return expiry < 0 ? Long.MAX_VALUE : expiry; }   }
ExponentialBackoff { static long calculateExpiry(long now, int maxLatency, int txCount) { if (now < 0) throw new IllegalArgumentException(); if (maxLatency <= 0) throw new IllegalArgumentException(); if (txCount < 0) throw new IllegalArgumentException(); long roundTrip = maxLatency * 2L; for (int i = 0; i < txCount; i++) { roundTrip <<= 1; if (roundTrip < 0) return Long.MAX_VALUE; } long expiry = now + roundTrip; return expiry < 0 ? Long.MAX_VALUE : expiry; }    }