Class ExponentialBackOffServiceUnavailableRetryStrategy
java.lang.Object
com.cloudbees.jenkins.plugins.bitbucket.impl.client.ExponentialBackOffServiceUnavailableRetryStrategy
- All Implemented Interfaces:
org.apache.http.client.ServiceUnavailableRetryStrategy
@Contract(threading=SAFE)
public class ExponentialBackOffServiceUnavailableRetryStrategy
extends Object
implements org.apache.http.client.ServiceUnavailableRetryStrategy
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 secs delay for one failed attempt (=The following equation is used to calculate the delay for a specific revalidation request:getInitialExpiryInMillis()
) 60 secs delay for two failed attempts 10 mins delay for three failed attempts 100 mins delay for four failed attempts ~16 hours delay for five failed attempts 24 hours delay for six or more failed attempts (=getMaxExpiryInMillis()
)
delay =The resulting delay won't exceedgetInitialExpiryInMillis()
* Math.pow(getBackOffRate()
,AsynchronousValidationRequest.getConsecutiveFailedAttempts()
- 1))
getMaxExpiryInMillis()
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
static final long
static final long
-
Constructor Summary
ConstructorDescriptionCreate a new strategy using a fixed pool of worker threads.ExponentialBackOffServiceUnavailableRetryStrategy
(long backOffRate, long initialExpiryInMillis, long maxExpiryInMillis) Create a new strategy by using a fixed pool of worker threads and the given parameters to calculated the delay. -
Method Summary
Modifier and TypeMethodDescriptionlong
long
long
long
boolean
retryRequest
(org.apache.http.HttpResponse response, int executionCount, org.apache.http.protocol.HttpContext context)
-
Field Details
-
DEFAULT_BACK_OFF_RATE
public static final long DEFAULT_BACK_OFF_RATE- See Also:
-
DEFAULT_INITIAL_EXPIRY_IN_MILLIS
public static final long DEFAULT_INITIAL_EXPIRY_IN_MILLIS -
DEFAULT_MAX_EXPIRY_IN_MILLIS
public static final long DEFAULT_MAX_EXPIRY_IN_MILLIS
-
-
Constructor Details
-
ExponentialBackOffServiceUnavailableRetryStrategy
public ExponentialBackOffServiceUnavailableRetryStrategy()Create a new strategy using a fixed pool of worker threads. -
ExponentialBackOffServiceUnavailableRetryStrategy
public ExponentialBackOffServiceUnavailableRetryStrategy(long backOffRate, long initialExpiryInMillis, long maxExpiryInMillis) Create a new strategy by using a fixed pool of worker threads and the given parameters to calculated the delay.- Parameters:
backOffRate
- the back off rate to be used; not negativeinitialExpiryInMillis
- the initial expiry in milli seconds; not negativemaxExpiryInMillis
- the upper limit of the delay in milli seconds; not negative
-
-
Method Details
-
getBackOffRate
public long getBackOffRate() -
getInitialExpiryInMillis
public long getInitialExpiryInMillis() -
getMaxExpiryInMillis
public long getMaxExpiryInMillis() -
retryRequest
public boolean retryRequest(org.apache.http.HttpResponse response, int executionCount, org.apache.http.protocol.HttpContext context) - Specified by:
retryRequest
in interfaceorg.apache.http.client.ServiceUnavailableRetryStrategy
-
getRetryInterval
public long getRetryInterval()- Specified by:
getRetryInterval
in interfaceorg.apache.http.client.ServiceUnavailableRetryStrategy
-