Class ExponentialBackoffManager
java.lang.Object
org.apache.hc.client5.http.impl.classic.AbstractBackoff
org.apache.hc.client5.http.impl.classic.ExponentialBackoffManager
- All Implemented Interfaces:
BackoffManager
A backoff manager implementation that uses an exponential backoff algorithm to adjust the maximum
number of connections per HTTP route. The algorithm reduces the number of connections in response
to adverse events, such as connection failures, and gradually increases the number of connections
when the route is operating without issues.
This implementation is specifically designed for managing connections in an HTTP route context and provides methods for probing and backing off connections based on the performance of the route.
The exponential backoff algorithm is primarily implemented in the getBackedOffPoolSize
method, which calculates the new connection pool size based on the current pool size, growth rate,
and the number of time intervals.
- Since:
- 5.3
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExponentialBackoffManager
(org.apache.hc.core5.pool.ConnPoolControl<HttpRoute> connPerRoute) Constructs a new ExponentialBackoffManager with the specified connection pool control. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
getBackedOffPoolSize
(int curr) Calculates the new pool size after applying the exponential backoff algorithm.void
setBackoffFactor
(double rate) Sets the backoff factor for the backoff algorithm.Methods inherited from class org.apache.hc.client5.http.impl.classic.AbstractBackoff
backOff, getBackoffFactor, getCap, getConnPerRoute, getCoolDown, getLastRouteBackoffs, getLastRouteProbes, getLastUpdate, getTimeInterval, probe, setCoolDown, setPerHostConnectionCap
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Details
-
ExponentialBackoffManager
Constructs a new ExponentialBackoffManager with the specified connection pool control.- Parameters:
connPerRoute
- the connection pool control to be used for managing connections- Throws:
IllegalArgumentException
- if connPerRoute is null
-
-
Method Details
-
getBackedOffPoolSize
protected int getBackedOffPoolSize(int curr) Calculates the new pool size after applying the exponential backoff algorithm. The new pool size is calculated using the formula: floor(curr / (1 + growthRate) ^ t), where curr is the current pool size, growthRate is the exponential growth rate, and t is the time interval.- Specified by:
getBackedOffPoolSize
in classAbstractBackoff
- Parameters:
curr
- the current pool size- Returns:
- the new pool size after applying the backoff
-
setBackoffFactor
public void setBackoffFactor(double rate) Description copied from class:AbstractBackoff
Sets the backoff factor for the backoff algorithm. The backoff factor should be a value between 0.0 and 1.0. The specific implementation of how the backoff factor is used should be provided by subclasses.- Specified by:
setBackoffFactor
in classAbstractBackoff
- Parameters:
rate
- the backoff factor to be set
-