@Test public void testInQueue() { PriorityQueue<ExponentialBackoff> queue = new PriorityQueue<>(); ExponentialBackoff backoff1 = new ExponentialBackoff(params); backoff.trackFailure(); backoff.trackFailure(); backoff1.trackFailure(); backoff1.trackFailure(); backoff1.trackFailure(); queue.offer(backoff); queue.offer(backoff1); assertEquals(queue.poll(), backoff); assertEquals(queue.peek(), backoff1); queue.offer(backoff); assertEquals(queue.poll(), backoff); }
public void trackFailure() { retryTime = Utils.currentTimeMillis() + (long)backoff; backoff = Math.min(backoff * params.multiplier, params.maximum); }
ExponentialBackoff implements Comparable<ExponentialBackoff> { public void trackFailure() { retryTime = Utils.currentTimeMillis() + (long)backoff; backoff = Math.min(backoff * params.multiplier, params.maximum); } }
ExponentialBackoff implements Comparable<ExponentialBackoff> { public void trackFailure() { retryTime = Utils.currentTimeMillis() + (long)backoff; backoff = Math.min(backoff * params.multiplier, params.maximum); } ExponentialBackoff(Params params); }
ExponentialBackoff implements Comparable<ExponentialBackoff> { public void trackFailure() { retryTime = Utils.currentTimeMillis() + (long)backoff; backoff = Math.min(backoff * params.multiplier, params.maximum); } ExponentialBackoff(Params params); final void trackSuccess(); void trackFailure(); long getRetryTime(); @Override int compareTo(ExponentialBackoff other); @Override String toString(); }
ExponentialBackoff implements Comparable<ExponentialBackoff> { public void trackFailure() { retryTime = Utils.currentTimeMillis() + (long)backoff; backoff = Math.min(backoff * params.multiplier, params.maximum); } ExponentialBackoff(Params params); final void trackSuccess(); void trackFailure(); long getRetryTime(); @Override int compareTo(ExponentialBackoff other); @Override String toString(); static final int DEFAULT_INITIAL_MILLIS; static final float DEFAULT_MULTIPLIER; static final int DEFAULT_MAXIMUM_MILLIS; }