@Contract(threading=SAFE) public class LinearBackoffManager extends AbstractBackoff
BackoffManager that uses a linear backoff strategy to adjust the maximum number
of connections per route in an PoolingHttpClientConnectionManager.
This class is designed to be thread-safe and can be used in multi-threaded environments.
The linear backoff strategy increases or decreases the maximum number of connections per route by a fixed increment when backing off or probing, respectively. The adjustments are made based on a cool-down period, during which no further adjustments will be made.
The LinearBackoffManager is intended to be used with a PoolingHttpClientConnectionManager,
which provides the ConnPoolControl interface. This class interacts with the PoolingHttpClientConnectionManager
to adjust the maximum number of connections per route.
Example usage:
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); LinearBackoffManager backoffManager = new LinearBackoffManager(connectionManager, 1); // Use the backoffManager with the connectionManager in your application
BackoffManager,
ConnPoolControl,
PoolingHttpClientConnectionManager| 构造器和说明 |
|---|
LinearBackoffManager(ConnPoolControl<HttpRoute> connPoolControl)
Constructs a new LinearBackoffManager with the specified connection pool control.
|
LinearBackoffManager(ConnPoolControl<HttpRoute> connPoolControl,
int increment)
Constructs a new LinearBackoffManager with the specified connection pool control and backoff increment.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
backOff(HttpRoute route)
Reduces the number of maximum allowed connections for the specified route based on the exponential backoff algorithm.
|
protected int |
getBackedOffPoolSize(int curr)
Returns the new pool size after applying the linear backoff algorithm.
|
void |
probe(HttpRoute route)
Adjusts the maximum number of connections for the specified route, decreasing it by the increment value.
|
void |
setBackoffFactor(double d)
This method is not used in LinearBackoffManager's implementation.
|
getBackoffFactor, getCap, getConnPerRoute, getCoolDown, getLastRouteBackoffs, getLastRouteProbes, getLastUpdate, getTimeInterval, setCoolDown, setPerHostConnectionCappublic LinearBackoffManager(ConnPoolControl<HttpRoute> connPoolControl)
1 by default.connPoolControl - the connection pool control to be used by this LinearBackoffManagerpublic LinearBackoffManager(ConnPoolControl<HttpRoute> connPoolControl, int increment)
connPoolControl - the connection pool control to be used by this LinearBackoffManagerincrement - the backoff increment to be used when adjusting connection pool sizesIllegalArgumentException - if connPoolControl is null or increment is not positivepublic void backOff(HttpRoute route)
AbstractBackoffbackOff 在接口中 BackoffManagerbackOff 在类中 AbstractBackoffroute - the HttpRoute for which the backoff needs to be appliedpublic void probe(HttpRoute route)
probe 在接口中 BackoffManagerprobe 在类中 AbstractBackoffroute - the HttpRoute for which the maximum number of connections will be decreasedprotected int getBackedOffPoolSize(int curr)
getBackedOffPoolSize 在类中 AbstractBackoffcurr - the current pool sizepublic void setBackoffFactor(double d)
d - the backoff factor, not used in the current implementationCopyright © 2023. All rights reserved.