ClientConnectionPoolManager maintains a pool of
HttpClientConnections 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 brand new connection.
ClientConnectionPoolManager maintains a maximum limit of connection
on a per route basis and in total. Per default this implementation will
create no more than than 2 concurrent connections per given route
and no more 20 connections in total. For many real-world applications
these limits may prove too constraining, especially if they use HTTP
as a transport protocol for their services. 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 2000ms
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final PoolingHttpClientConnectionManager. | |
| private final HttpClientConnectionOperator | |
| private final AtomicBoolean | |
| private final Log | |
| private final CPool |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. |
| public void | closeExpiredConnections()
Implements org. |
| public void | closeIdleConnections(final long
the idle time of connections to be closed idleTimeout, final TimeUnit the unit for the timeUnit)idletimeImplements org. |
| public void | connect(final HttpClientConnection
the managed connection. managedConn, final HttpRoute the route of the connection. route, final int connect timeout in milliseconds. connectTimeout, final HttpContext the actual HTTP context. context)Implements org. |
| protected void | |
| protected void | |
| protected void | finalize()
Overrides java. |
| private String | |
| private String | |
| private String | |
| public ConnectionConfig | |
| public ConnectionConfig | |
| public int | |
| private static Registry | |
| public SocketConfig | |
| public int | getMaxPerRoute(final HttpRoute route)
Implements org. |
| public int | |
| public Set | |
| public SocketConfig | |
| public PoolStats | |
| public PoolStats | |
| public int | |
| protected HttpClientConnection | |
| public void | releaseConnection(final HttpClientConnection
the managed connection to release. managedConn, final Object state, final long the duration of time this connection is valid for reuse. keepalive, final TimeUnit the time unit. timeUnit)Implements org. |
| public ConnectionRequest | requestConnection(final HttpRoute
HTTP route of the requested connection. route, final Object expected state of the connection or state)null
if the connection is not expected to carry any state.Implements org. ConnectionRequest, from which a
HttpClientConnection can be obtained or the request can be
aborted.
|
| private SocketConfig | |
| public void | routeComplete(final HttpClientConnection
the managed connection. managedConn, final HttpRoute the route of the connection. route, final HttpContext the actual HTTP context. context)Implements org. |
| public void | |
| public void | |
| public void | setDefaultMaxPerRoute(final int max)
Implements org. |
| public void | |
| public void | setMaxPerRoute(final HttpRoute route, final int max)
Implements org. |
| public void | |
| public void | |
| public void | setValidateAfterInactivity(final int ms)
Defines period of inactivity in milliseconds after which persistent connections must
be re-validated prior to being |
| public void | shutdown()
Implements org. |
| public void | upgrade(final HttpClientConnection
the managed connection. managedConn, final HttpRoute the route of the connection. route, final HttpContext the actual HTTP context. context)Implements org. CONNECT method to all
intermediate proxy hops
|