public static RetryWithBackoff withExpBackoff(long initialMillis, int multiplier, int attempts, long maxDelay) { Preconditions.checkArgument(initialMillis >= 1, "InitialMillis must be a positive integer."); Preconditions.checkArgument(multiplier >= 1, "multiplier must be a positive integer."); Preconditions.checkArgument(attempts >= 1, "attempts must be a positive integer."); Preconditions.checkArgument(maxDelay >= 1, "maxDelay must be a positive integer."); return new RetryWithBackoff(initialMillis, multiplier, attempts, maxDelay); }
public static RetryUnconditionally indefinitelyWithExpBackoff(long initialMillis, int multiplier, long maxDelay, Consumer<Throwable> consumer) { Preconditions.checkArgument(initialMillis >= 1, "InitialMillis must be a positive integer."); Preconditions.checkArgument(multiplier >= 1, "multiplier must be a positive integer."); Preconditions.checkArgument(maxDelay >= 1, "maxDelay must be a positive integer."); RetryWithBackoff params = new RetryWithBackoff(initialMillis, multiplier, Integer.MAX_VALUE, maxDelay); return new RetryUnconditionally(consumer, params); }
public static RetryUnconditionally indefinitelyWithExpBackoff(String failureMessage) { Exceptions.checkNotNullOrEmpty(failureMessage, "failureMessage"); RetryWithBackoff params = new RetryWithBackoff(DEFAULT_RETRY_INIT_DELAY, DEFAULT_RETRY_MULTIPLIER, Integer.MAX_VALUE, DEFAULT_RETRY_MAX_DELAY); Consumer<Throwable> consumer = e -> { if (log.isDebugEnabled()) { log.debug(failureMessage); } else { log.warn(failureMessage); } }; return new RetryUnconditionally(consumer, params); }