mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 23:16:33 +00:00
ExponentialBackOffSchedulingStrategy should use TimeValue internally
This commit is contained in:
parent
6c1e4676a1
commit
83bc2c497d
@ -91,7 +91,7 @@ public ExponentialBackOffSchedulingStrategy() {
|
||||
|
||||
@Override
|
||||
public TimeValue schedule(final int attemptNumber) {
|
||||
return TimeValue.ofMilliseconds(calculateDelayInMillis(attemptNumber));
|
||||
return calculateDelay(attemptNumber);
|
||||
}
|
||||
|
||||
public long getBackOffRate() {
|
||||
@ -106,12 +106,12 @@ public TimeValue getMaxExpiry() {
|
||||
return maxExpiry;
|
||||
}
|
||||
|
||||
protected long calculateDelayInMillis(final int consecutiveFailedAttempts) {
|
||||
protected TimeValue calculateDelay(final int consecutiveFailedAttempts) {
|
||||
if (consecutiveFailedAttempts > 0) {
|
||||
final long delay = (long) (initialExpiry.toMillis() * Math.pow(backOffRate, consecutiveFailedAttempts - 1));
|
||||
return Math.min(delay, maxExpiry.toMillis());
|
||||
return TimeValue.ofMilliseconds(Math.min(delay, maxExpiry.toMillis()));
|
||||
}
|
||||
return 0;
|
||||
return TimeValue.ZERO_MILLISECONDS;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user