This class provides common functionality for maintaining the route-wise backoff and probe timestamps, as well as the cool-down period for each backoff attempt.
It also contains the basic structure of the backOff and probe methods, which use the route-wise timestamps to determine if the backoff or probe should be applied, and then call the specific algorithm implementation for calculating the new pool size.
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicReference | backoffFactor
The growth rate used in the exponential backoff algorithm. |
| private final AtomicInteger | cap
The per-host connection cap, as defined in RFC 2616 sec 8.1.4. |
| private final ConnPoolControl | connPerRoute
Connection pool control responsible for managing the maximum number of connections per HTTP route. |
| private final AtomicReference | coolDown
The cool-down period after which the backoff or probe process can be performed again. |
| private final Map | lastRouteBackoffs
A map that stores the last backoff timestamp for each HTTP route. |
| private final Map | lastRouteProbes
A map that stores the last probe timestamp for each HTTP route. |
| private static final Logger | |
| private final AtomicInteger | timeInterval
The number of time intervals used in the exponential backoff algorithm. |
| Access | Constructor and Description |
|---|---|
| public | AbstractBackoff(final ConnPoolControl<HttpRoute>
the connection pool control to be used for managing connections connPerRoute)Constructs a new ExponentialBackoffManager with the specified connection pool control. |
| Modifier and Type | Method and Description |
|---|---|
| public void | backOff(final HttpRoute
the HttpRoute for which the backoff needs to be applied route)Implements org. |
| protected abstract int | Returns: the new pool size after applying the backoffthe current pool size curr)Calculates the new pool size after applying the exponential backoff algorithm. |
| protected AtomicReference | Returns: the AtomicReference containing the backoff factorReturns the backoff factor as an AtomicReference of Double. |
| protected AtomicInteger | Returns: the AtomicInteger containing the cap valueReturns the cap on the maximum number of connections per route as an AtomicInteger. |
| protected ConnPoolControl | Returns: the connection pool control instanceReturns the connection pool control for managing the maximum number of connections per route. |
| protected AtomicReference | Returns: the AtomicReference containing the cool down periodReturns the cool down period between backoff and probe operations as an AtomicReference of TimeValue. |
| protected Map | Returns: the map of HttpRoute to Instant representing the last backoff timesReturns the map containing the last backoff times for each HttpRoute. |
| protected Map | Returns: the map of HttpRoute to Instant representing the last probe timesReturns the map containing the last probe times for each HttpRoute. |
| public long | Returns: the last update timestamp for the specified route or 0L if not present in the mapthe map containing update timestamps for HttpRoutes updates, final HttpRoute the HttpRoute for which the last update timestamp is needed route)Retrieves the last update timestamp for the specified route from the provided updates map. |
| protected AtomicInteger | Returns: the AtomicInteger containing the time intervalReturns the time interval between backoff and probe operations as an AtomicInteger. |
| public void | probe(final HttpRoute
the HttpRoute for which the probe needs to be applied route)Implements org. |
| pack-priv abstract void | setBackoffFactor(final double
the backoff factor to be set d)Sets the backoff factor for the backoff algorithm. |
| public void | setCoolDown(final TimeValue
the TimeValue representing the cool-down period between adjustments coolDown)Sets the cool-down time value for adjustments in pool sizes for a given host. |
| public void | setPerHostConnectionCap(final int
the per-host connection cap to be set cap)Sets the per-host connection cap. |
| backoffFactor | back to summary |
|---|---|
| private final AtomicReference<Double> backoffFactor The growth rate used in the exponential backoff algorithm. | |
| cap | back to summary |
|---|---|
| private final AtomicInteger cap The per-host connection cap, as defined in RFC 2616 sec 8.1.4. | |
| connPerRoute | back to summary |
|---|---|
| private final ConnPoolControl<HttpRoute> connPerRoute Connection pool control responsible for managing the maximum number of connections per HTTP route. | |
| coolDown | back to summary |
|---|---|
| private final AtomicReference<TimeValue> coolDown The cool-down period after which the backoff or probe process can be performed again. | |
| lastRouteBackoffs | back to summary |
|---|---|
| private final Map<HttpRoute, Instant> lastRouteBackoffs A map that stores the last backoff timestamp for each HTTP route. | |
| lastRouteProbes | back to summary |
|---|---|
| private final Map<HttpRoute, Instant> lastRouteProbes A map that stores the last probe timestamp for each HTTP route. | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| timeInterval | back to summary |
|---|---|
| private final AtomicInteger timeInterval The number of time intervals used in the exponential backoff algorithm. | |
| AbstractBackoff | back to summary |
|---|---|
| public AbstractBackoff(final ConnPoolControl<HttpRoute> connPerRoute) Constructs a new ExponentialBackoffManager with the specified connection pool control.
| |
| backOff | back to summary |
|---|---|
| public void backOff(final HttpRoute route) Implements org. Reduces the number of maximum allowed connections for the specified route based on the exponential backoff algorithm. | |
| getBackedOffPoolSize | back to summary |
|---|---|
| protected abstract 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.
| |
| getBackoffFactor | back to summary |
|---|---|
| protected AtomicReference Returns the backoff factor as an AtomicReference of Double.
| |
| getCap | back to summary |
|---|---|
| protected AtomicInteger getCap() Returns the cap on the maximum number of connections per route as an AtomicInteger.
| |
| getConnPerRoute | back to summary |
|---|---|
| protected ConnPoolControl Returns the connection pool control for managing the maximum number of connections per route.
| |
| getCoolDown | back to summary |
|---|---|
| protected AtomicReference Returns the cool down period between backoff and probe operations as an AtomicReference of TimeValue.
| |
| getLastRouteBackoffs | back to summary |
|---|---|
| protected Map Returns the map containing the last backoff times for each HttpRoute. | |
| getLastRouteProbes | back to summary |
|---|---|
| protected Map Returns the map containing the last probe times for each HttpRoute. | |
| getLastUpdate | back to summary |
|---|---|
| public long getLastUpdate(final Map<HttpRoute, Long> updates, final HttpRoute route) Retrieves the last update timestamp for the specified route from the provided updates map. | |
| getTimeInterval | back to summary |
|---|---|
| protected AtomicInteger getTimeInterval() Returns the time interval between backoff and probe operations as an AtomicInteger.
| |
| probe | back to summary |
|---|---|
| public void probe(final HttpRoute route) Implements org. Increases the number of maximum allowed connections for the specified route after a successful connection has been established. | |
| setBackoffFactor | back to summary |
|---|---|
| pack-priv abstract void setBackoffFactor(final double d) 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.
| |
| setCoolDown | back to summary |
|---|---|
| public void setCoolDown(final TimeValue coolDown) Sets the cool-down time value for adjustments in pool sizes for a given host. This time value allows enough time for the adjustments to take effect before further adjustments are made. The cool-down time value must be positive and not null.
| |
| setPerHostConnectionCap | back to summary |
|---|---|
| public void setPerHostConnectionCap(final int cap) Sets the per-host connection cap.
| |