public class PoolingAsyncClientConnectionManager extends java.lang.Object implements AsyncClientConnectionManager
PoolingAsyncClientConnectionManager maintains a pool of non-blocking
org.apache.hc.core5.http.HttpConnections and is able to service
connection requests from multiple execution threads. Connections are pooled
on a per route basis. A request for a route which already the manager has
persistent connections for available in the pool will be services by leasing
a connection from the pool rather than creating a new connection.
PoolingAsyncClientConnectionManager maintains a maximum limit
of connection on a per route basis and in total. Connection limits
can be adjusted using ConnPoolControl methods.
Total time to live (TTL) set at construction time defines maximum life span of persistent connections regardless of their expiration setting. No persistent connection will be re-used past its TTL value.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_CONNECTIONS_PER_ROUTE |
static int |
DEFAULT_MAX_TOTAL_CONNECTIONS |
| Modifier | Constructor and Description |
|---|---|
|
PoolingAsyncClientConnectionManager() |
|
PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup) |
protected |
PoolingAsyncClientConnectionManager(<any> pool,
AsyncClientConnectionOperator connectionOperator) |
|
PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup,
PoolConcurrencyPolicy poolConcurrencyPolicy,
PoolReusePolicy poolReusePolicy,
TimeValue timeToLive) |
|
PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup,
PoolConcurrencyPolicy poolConcurrencyPolicy,
PoolReusePolicy poolReusePolicy,
TimeValue timeToLive,
SchemePortResolver schemePortResolver,
DnsResolver dnsResolver) |
|
PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup,
PoolConcurrencyPolicy poolConcurrencyPolicy,
TimeValue timeToLive) |
protected |
PoolingAsyncClientConnectionManager(AsyncClientConnectionOperator connectionOperator,
PoolConcurrencyPolicy poolConcurrencyPolicy,
PoolReusePolicy poolReusePolicy,
TimeValue timeToLive) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
close(CloseMode closeMode) |
void |
closeExpired() |
void |
closeIdle(TimeValue idletime) |
java.util.concurrent.Future<AsyncConnectionEndpoint> |
connect(AsyncConnectionEndpoint endpoint,
ConnectionInitiator connectionInitiator,
Timeout connectTimeout,
java.lang.Object attachment,
HttpContext context,
<any> callback)
Connects the endpoint to the initial hop (connection target in case
of a direct route or to the first proxy hop in case of a route via a proxy
or multiple proxies).
|
int |
getDefaultMaxPerRoute() |
int |
getMaxPerRoute(HttpRoute route) |
int |
getMaxTotal() |
java.util.Set<HttpRoute> |
getRoutes() |
PoolStats |
getStats(HttpRoute route) |
PoolStats |
getTotalStats() |
TimeValue |
getValidateAfterInactivity() |
java.util.concurrent.Future<AsyncConnectionEndpoint> |
lease(java.lang.String id,
HttpRoute route,
java.lang.Object state,
Timeout requestTimeout,
<any> callback)
Returns a
Future object which can be used to obtain
an AsyncConnectionEndpoint or to cancel the request by calling
Future.cancel(boolean). |
void |
release(AsyncConnectionEndpoint endpoint,
java.lang.Object state,
TimeValue keepAlive)
Releases the endpoint back to the manager making it potentially
re-usable by other consumers.
|
void |
setDefaultMaxPerRoute(int max) |
void |
setMaxPerRoute(HttpRoute route,
int max) |
void |
setMaxTotal(int max) |
void |
setValidateAfterInactivity(TimeValue validateAfterInactivity)
Defines period of inactivity after which persistent connections must
be re-validated prior to being
#lease(String, HttpRoute, Object, Timeout,
FutureCallback) leased} to the consumer. |
void |
upgrade(AsyncConnectionEndpoint endpoint,
java.lang.Object attachment,
HttpContext context)
Upgrades transport security of the given endpoint by using the TLS security protocol.
|
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE
public PoolingAsyncClientConnectionManager()
public PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup)
public PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup,
PoolConcurrencyPolicy poolConcurrencyPolicy,
TimeValue timeToLive)
public PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup,
PoolConcurrencyPolicy poolConcurrencyPolicy,
PoolReusePolicy poolReusePolicy,
TimeValue timeToLive)
public PoolingAsyncClientConnectionManager(<any> tlsStrategyLookup,
PoolConcurrencyPolicy poolConcurrencyPolicy,
PoolReusePolicy poolReusePolicy,
TimeValue timeToLive,
SchemePortResolver schemePortResolver,
DnsResolver dnsResolver)
protected PoolingAsyncClientConnectionManager(AsyncClientConnectionOperator connectionOperator, PoolConcurrencyPolicy poolConcurrencyPolicy, PoolReusePolicy poolReusePolicy, TimeValue timeToLive)
protected PoolingAsyncClientConnectionManager(<any> pool,
AsyncClientConnectionOperator connectionOperator)
public void close()
public void close(CloseMode closeMode)
public java.util.concurrent.Future<AsyncConnectionEndpoint> lease(java.lang.String id, HttpRoute route, java.lang.Object state, Timeout requestTimeout, <any> callback)
AsyncClientConnectionManagerFuture object which can be used to obtain
an AsyncConnectionEndpoint or to cancel the request by calling
Future.cancel(boolean).
Please note that newly allocated endpoints can be leased
disconnected. The consumer
of the endpoint is responsible for fully establishing the route to
the endpoint target by calling #connect(AsyncConnectionEndpoint,
ConnectionInitiator, Timeout, Object, HttpContext, FutureCallback)
in order to connect directly to the target or to the first proxy hop,
and optionally calling AsyncClientConnectionManager.upgrade(AsyncConnectionEndpoint, Object, HttpContext)
method to upgrade the underlying transport to Transport Layer Security
after having executed a CONNECT method to all intermediate
proxy hops.
lease in interface AsyncClientConnectionManagerid - unique operation ID or null.route - HTTP route of the requested connection.state - expected state of the connection or null
if the connection is not expected to carry any state.requestTimeout - lease request timeout.callback - result callback.public void release(AsyncConnectionEndpoint endpoint, java.lang.Object state, TimeValue keepAlive)
AsyncClientConnectionManagervalidDuration and timeUnit
parameters.release in interface AsyncClientConnectionManagerendpoint - the managed endpoint.state - the new connection state of null if state-less.keepAlive - the duration of time this connection is valid for reuse.public java.util.concurrent.Future<AsyncConnectionEndpoint> connect(AsyncConnectionEndpoint endpoint, ConnectionInitiator connectionInitiator, Timeout connectTimeout, java.lang.Object attachment, HttpContext context, <any> callback)
AsyncClientConnectionManagerconnect in interface AsyncClientConnectionManagerendpoint - the managed endpoint.connectTimeout - connect timeout.attachment - connect request attachment.context - the actual HTTP context.callback - result callback.public void upgrade(AsyncConnectionEndpoint endpoint, java.lang.Object attachment, HttpContext context)
AsyncClientConnectionManagerupgrade in interface AsyncClientConnectionManagerendpoint - the managed endpoint.attachment - the attachment the upgrade attachment object.context - the actual HTTP context.public java.util.Set<HttpRoute> getRoutes()
public void setMaxTotal(int max)
public int getMaxTotal()
public void setDefaultMaxPerRoute(int max)
public int getDefaultMaxPerRoute()
public void setMaxPerRoute(HttpRoute route, int max)
public int getMaxPerRoute(HttpRoute route)
public void closeIdle(TimeValue idletime)
public void closeExpired()
public PoolStats getTotalStats()
public PoolStats getStats(HttpRoute route)
public TimeValue getValidateAfterInactivity()
public void setValidateAfterInactivity(TimeValue validateAfterInactivity)
#lease(String, HttpRoute, Object, Timeout,
FutureCallback) leased} to the consumer. Negative values passed
to this method disable connection validation. This check helps detect connections
that have become stale (half-closed) while kept inactive in the pool.