You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.8 KiB
Java
53 lines
1.8 KiB
Java
2 years ago
|
//package com.xinyingpower.microphoto.request;
|
||
|
//
|
||
|
//import java.util.Random;
|
||
|
//
|
||
|
///**
|
||
|
// * <p>Retry policy that retries a set number of times with increasing sleep time between retries</p>
|
||
|
// */
|
||
|
//public class ExponentialBackOffRetry implements RetryPolicy {
|
||
|
//
|
||
|
// private static final int MAX_RETRIES_LIMIT = 29;
|
||
|
// private static final int DEFAULT_MAX_SLEEP_MS = Integer.MAX_VALUE;
|
||
|
//
|
||
|
// private final Random random = new Random();
|
||
|
// private final long baseSleepTimeMs;
|
||
|
// private final int maxRetries;
|
||
|
// private final int maxSleepMs;
|
||
|
//
|
||
|
// public ExponentialBackOffRetry(int baseSleepTimeMs, int maxRetries) {
|
||
|
// this(baseSleepTimeMs, maxRetries, DEFAULT_MAX_SLEEP_MS);
|
||
|
// }
|
||
|
//
|
||
|
// public ExponentialBackOffRetry(int baseSleepTimeMs, int maxRetries, int maxSleepMs) {
|
||
|
// this.maxRetries = maxRetries;
|
||
|
// this.baseSleepTimeMs = baseSleepTimeMs;
|
||
|
// this.maxSleepMs = maxSleepMs;
|
||
|
// }
|
||
|
//
|
||
|
// @Override
|
||
|
// public boolean allowRetry(int retryCount) {
|
||
|
// if (retryCount < maxRetries) {
|
||
|
// return true;
|
||
|
// }
|
||
|
// return false;
|
||
|
// }
|
||
|
//
|
||
|
// @Override
|
||
|
// public long getSleepTimeMs(int retryCount) {
|
||
|
// if (retryCount < 0) {
|
||
|
// throw new IllegalArgumentException("retries count must greater than 0.");
|
||
|
// }
|
||
|
// if (retryCount > MAX_RETRIES_LIMIT) {
|
||
|
//// LogUtil.e(String.format("maxRetries too large (%d). Pinning to %d", maxRetries, MAX_RETRIES_LIMIT));
|
||
|
// retryCount = MAX_RETRIES_LIMIT;
|
||
|
// }
|
||
|
// long sleepMs = baseSleepTimeMs * Math.max(1, random.nextInt(1 << retryCount));
|
||
|
// if (sleepMs > maxSleepMs) {
|
||
|
//// LogUtil.e(String.format("Sleep extension too large (%d). Pinning to %d", sleepMs, maxSleepMs));
|
||
|
// sleepMs = maxSleepMs;
|
||
|
// }
|
||
|
// return sleepMs;
|
||
|
// }
|
||
|
//}
|