Class ExponentialBackOffSchedulingStrategy
- java.lang.Object
-
- org.apache.hc.client5.http.impl.schedule.ExponentialBackOffSchedulingStrategy
-
- All Implemented Interfaces:
SchedulingStrategy
@Contract(threading=STATELESS) public class ExponentialBackOffSchedulingStrategy extends java.lang.Object implements SchedulingStrategy
An implementation that backs off exponentially based on the number of consecutive failed attempts. It uses the following defaults:no delay in case it was never tried or didn't fail so far 6 s delay for one failed attempt (=The following equation is used to calculate the delay for a specific pending operation:getInitialExpiry()) 60 s delay for two failed attempts 10 min delay for three failed attempts 100 min delay for four failed attempts ~16 h delay for five failed attempts 24 h delay for six or more failed attempts (=getMaxExpiry())delay =The resulting delay won't exceedgetInitialExpiry()* Math.pow(getBackOffRate(),consecutiveFailedAttempts- 1))getMaxExpiry().- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private longbackOffRatestatic longDEFAULT_BACK_OFF_RATEstatic org.apache.hc.core5.util.TimeValueDEFAULT_INITIAL_EXPIRYstatic org.apache.hc.core5.util.TimeValueDEFAULT_MAX_EXPIRYprivate org.apache.hc.core5.util.TimeValueinitialExpiryprivate org.apache.hc.core5.util.TimeValuemaxExpiry
-
Constructor Summary
Constructors Constructor Description ExponentialBackOffSchedulingStrategy()ExponentialBackOffSchedulingStrategy(long backOffRate)ExponentialBackOffSchedulingStrategy(long backOffRate, org.apache.hc.core5.util.TimeValue initialExpiry)ExponentialBackOffSchedulingStrategy(long backOffRate, org.apache.hc.core5.util.TimeValue initialExpiry, org.apache.hc.core5.util.TimeValue maxExpiry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.hc.core5.util.TimeValuecalculateDelay(int consecutiveFailedAttempts)longgetBackOffRate()org.apache.hc.core5.util.TimeValuegetInitialExpiry()org.apache.hc.core5.util.TimeValuegetMaxExpiry()org.apache.hc.core5.util.TimeValueschedule(int attemptNumber)Schedules execution time for an operation.
-
-
-
Field Detail
-
DEFAULT_BACK_OFF_RATE
public static final long DEFAULT_BACK_OFF_RATE
- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_EXPIRY
public static final org.apache.hc.core5.util.TimeValue DEFAULT_INITIAL_EXPIRY
-
DEFAULT_MAX_EXPIRY
public static final org.apache.hc.core5.util.TimeValue DEFAULT_MAX_EXPIRY
-
backOffRate
private final long backOffRate
-
initialExpiry
private final org.apache.hc.core5.util.TimeValue initialExpiry
-
maxExpiry
private final org.apache.hc.core5.util.TimeValue maxExpiry
-
-
Constructor Detail
-
ExponentialBackOffSchedulingStrategy
public ExponentialBackOffSchedulingStrategy(long backOffRate, org.apache.hc.core5.util.TimeValue initialExpiry, org.apache.hc.core5.util.TimeValue maxExpiry)
-
ExponentialBackOffSchedulingStrategy
public ExponentialBackOffSchedulingStrategy(long backOffRate, org.apache.hc.core5.util.TimeValue initialExpiry)
-
ExponentialBackOffSchedulingStrategy
public ExponentialBackOffSchedulingStrategy(long backOffRate)
-
ExponentialBackOffSchedulingStrategy
public ExponentialBackOffSchedulingStrategy()
-
-
Method Detail
-
schedule
public org.apache.hc.core5.util.TimeValue schedule(int attemptNumber)
Description copied from interface:SchedulingStrategySchedules execution time for an operation.- Specified by:
schedulein interfaceSchedulingStrategy
-
getBackOffRate
public long getBackOffRate()
-
getInitialExpiry
public org.apache.hc.core5.util.TimeValue getInitialExpiry()
-
getMaxExpiry
public org.apache.hc.core5.util.TimeValue getMaxExpiry()
-
calculateDelay
protected org.apache.hc.core5.util.TimeValue calculateDelay(int consecutiveFailedAttempts)
-
-