@Contract(threading=SAFE_CONDITIONAL) public class PoolingHttpClientConnectionManager extends Object implements HttpClientConnectionManager, ConnPoolControl<HttpRoute>
ClientConnectionPoolManager maintains a pool of
 ManagedHttpClientConnections 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 serviced by leasing
 a connection from the pool rather than creating a new connection.
 
 ClientConnectionPoolManager maintains a maximum limit of connection
 on a per route basis and in total. Connection limits, however, 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.
The handling of stale connections was changed in version 4.4. Previously, the code would check every connection by default before re-using it. The code now only checks the connection if the elapsed time since the last use of the connection exceeds the timeout that has been set. The default timeout is set to 5000ms.
| Modifier and Type | Field and Description | 
|---|---|
| static int | DEFAULT_MAX_CONNECTIONS_PER_ROUTE | 
| static int | DEFAULT_MAX_TOTAL_CONNECTIONS | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Closes this stream and releases any system resources associated with it. | 
| void | close(CloseMode closeMode)Closes this process or endpoint and releases any system resources associated
 with it. | 
| void | closeExpired() | 
| void | closeIdle(TimeValue idleTime) | 
| void | connect(ConnectionEndpoint endpoint,
       TimeValue connectTimeout,
       HttpContext context)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() | 
| SocketConfig | getDefaultSocketConfig() | 
| int | getMaxPerRoute(HttpRoute route) | 
| int | getMaxTotal() | 
| Set<HttpRoute> | getRoutes() | 
| PoolStats | getStats(HttpRoute route) | 
| PoolStats | getTotalStats() | 
| TimeValue | getValidateAfterInactivity() | 
| LeaseRequest | lease(String id,
     HttpRoute route,
     Object state) | 
| LeaseRequest | lease(String id,
     HttpRoute route,
     Timeout requestTimeout,
     Object state)Returns a  LeaseRequestobject which can be used to obtain
 aConnectionEndpointto cancel the request by callingCancellable.cancel(). | 
| void | release(ConnectionEndpoint endpoint,
       Object state,
       TimeValue keepAlive)Releases the endpoint back to the manager making it potentially
 re-usable by other consumers. | 
| void | setDefaultMaxPerRoute(int max) | 
| void | setDefaultSocketConfig(SocketConfig defaultSocketConfig) | 
| 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)leased} to the consumer. | 
| void | upgrade(ConnectionEndpoint endpoint,
       HttpContext context)Upgrades transport security of the given endpoint by using the TLS security protocol. | 
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS
public PoolingHttpClientConnectionManager()
@Internal protected PoolingHttpClientConnectionManager(HttpClientConnectionOperator httpClientConnectionOperator, ManagedConnPool<HttpRoute,ManagedHttpClientConnection> pool, HttpConnectionFactory<ManagedHttpClientConnection> connFactory)
@Internal protected PoolingHttpClientConnectionManager(HttpClientConnectionOperator httpClientConnectionOperator, PoolConcurrencyPolicy poolConcurrencyPolicy, PoolReusePolicy poolReusePolicy, TimeValue timeToLive, HttpConnectionFactory<ManagedHttpClientConnection> connFactory)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry, HttpConnectionFactory<ManagedHttpClientConnection> connFactory)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry, PoolConcurrencyPolicy poolConcurrencyPolicy, PoolReusePolicy poolReusePolicy, TimeValue timeToLive)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry, PoolConcurrencyPolicy poolConcurrencyPolicy, PoolReusePolicy poolReusePolicy, TimeValue timeToLive, HttpConnectionFactory<ManagedHttpClientConnection> connFactory)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry, PoolConcurrencyPolicy poolConcurrencyPolicy, PoolReusePolicy poolReusePolicy, TimeValue timeToLive, SchemePortResolver schemePortResolver, DnsResolver dnsResolver, HttpConnectionFactory<ManagedHttpClientConnection> connFactory)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry, PoolConcurrencyPolicy poolConcurrencyPolicy, TimeValue timeToLive, HttpConnectionFactory<ManagedHttpClientConnection> connFactory)
public void close()
Closeableclose in interface Closeableclose in interface AutoCloseablepublic void close(CloseMode closeMode)
ModalCloseableclose in interface ModalCloseablecloseMode - How to close the receiver.public void closeExpired()
closeExpired in interface ConnPoolControl<HttpRoute>public void closeIdle(TimeValue idleTime)
closeIdle in interface ConnPoolControl<HttpRoute>public void connect(ConnectionEndpoint endpoint, TimeValue connectTimeout, HttpContext context) throws IOException
HttpClientConnectionManagerconnect in interface HttpClientConnectionManagerendpoint - the managed endpoint.connectTimeout - connect timeout.context - the actual HTTP context.IOExceptionpublic int getDefaultMaxPerRoute()
getDefaultMaxPerRoute in interface ConnPoolControl<HttpRoute>public SocketConfig getDefaultSocketConfig()
public int getMaxPerRoute(HttpRoute route)
getMaxPerRoute in interface ConnPoolControl<HttpRoute>public int getMaxTotal()
getMaxTotal in interface ConnPoolControl<HttpRoute>public Set<HttpRoute> getRoutes()
getRoutes in interface ConnPoolControl<HttpRoute>public PoolStats getStats(HttpRoute route)
getStats in interface ConnPoolStats<HttpRoute>public PoolStats getTotalStats()
getTotalStats in interface ConnPoolStats<HttpRoute>public TimeValue getValidateAfterInactivity()
setValidateAfterInactivity(TimeValue)public LeaseRequest lease(String id, HttpRoute route, Object state)
public LeaseRequest lease(String id, HttpRoute route, Timeout requestTimeout, Object state)
HttpClientConnectionManagerLeaseRequest object which can be used to obtain
 a ConnectionEndpoint to cancel the request by calling
 Cancellable.cancel().
 
 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 HttpClientConnectionManager.connect(ConnectionEndpoint, TimeValue, HttpContext)
 in order to connect directly to the target or to the first proxy hop,
 and optionally calling HttpClientConnectionManager.upgrade(ConnectionEndpoint, 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 HttpClientConnectionManagerid - unique operation ID or null.route - HTTP route of the requested connection.requestTimeout - lease request timeout.state - expected state of the connection or null
              if the connection is not expected to carry any state.public void release(ConnectionEndpoint endpoint, Object state, TimeValue keepAlive)
HttpClientConnectionManagervalidDuration and timeUnit
 parameters.release in interface HttpClientConnectionManagerendpoint - 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 void setDefaultMaxPerRoute(int max)
setDefaultMaxPerRoute in interface ConnPoolControl<HttpRoute>public void setDefaultSocketConfig(SocketConfig defaultSocketConfig)
public void setMaxPerRoute(HttpRoute route, int max)
setMaxPerRoute in interface ConnPoolControl<HttpRoute>public void setMaxTotal(int max)
setMaxTotal in interface ConnPoolControl<HttpRoute>public void setValidateAfterInactivity(TimeValue validateAfterInactivity)
lease(String, HttpRoute, Object)  leased} to the consumer.
 Non-positive value passed to this method disables connection validation. This check helps
 detect connections that have become stale (half-closed) while kept inactive in the pool.public void upgrade(ConnectionEndpoint endpoint, HttpContext context) throws IOException
HttpClientConnectionManagerupgrade in interface HttpClientConnectionManagerendpoint - the managed endpoint.context - the actual HTTP context.IOException