@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = super.getBackoffTime(config, attempts); return config.getMaxSleepTime() > 0 ? Math.min(backoffTime, config.getMaxSleepTime()) : backoffTime; } }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = super.getBackoffTime(config, attempts); return config.getMaxSleepTime() > 0 ? Math.min(backoffTime, config.getMaxSleepTime()) : backoffTime; } }
@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = super.getBackoffTime(config, attempts); return config.getMaxSleepTime() > 0 ? Math.min(backoffTime, config.getMaxSleepTime()) : backoffTime; } }
@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = super.getBackoffTime(config, attempts); return config.getMaxSleepTime() > 0 ? Math.min(backoffTime, config.getMaxSleepTime()) : backoffTime; } }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
/** * Get an exponential backoff retry counter. The base unit is 100 milliseconds, and the max * backoff time is 30 seconds. */ public static RetryCounter getRetryCounter() { return new RetryCounterFactory( new RetryCounter.RetryConfig().setBackoffPolicy(new RetryCounter.ExponentialBackoffPolicy()) .setSleepInterval(100).setMaxSleepTime(30000).setMaxAttempts(Integer.MAX_VALUE) .setTimeUnit(TimeUnit.MILLISECONDS).setJitter(0.01f)).create(); } }