Top Description Inners Fields Constructors Methods
org.apache.hc.client5.http.impl.nio

public Class PoolingAsyncClientConnectionManager

extends Object
implements AsyncClientConnectionManager, ConnPoolControl<HttpRoute>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.pool.ConnPoolControl, org.apache.hc.core5.pool.ConnPoolStats, org.apache.hc.client5.http.nio.AsyncClientConnectionManager, org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable
Annotations
@Contract
threading:SAFE_CONDITIONAL
Imports
java.net.InetSocketAddress, java.util.Set, java.util.concurrent.ExecutionException, .Future, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, org.apache.hc.client5.http.DnsResolver, .HttpRoute, .SchemePortResolver, org.apache.hc.client5.http.config.ConnectionConfig, .TlsConfig, org.apache.hc.client5.http.impl.ConnPoolSupport, .ConnectionShutdownException, .PrefixedIncrementingId, org.apache.hc.client5.http.nio.AsyncClientConnectionManager, .AsyncClientConnectionOperator, .AsyncConnectionEndpoint, .ManagedAsyncClientConnection, org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy, org.apache.hc.core5.annotation.Contract, .Internal, .ThreadingBehavior, org.apache.hc.core5.concurrent.BasicFuture, .CallbackContribution, .ComplexFuture, .FutureCallback, org.apache.hc.core5.function.Resolver, org.apache.hc.core5.http.HttpHost, .HttpVersion, .ProtocolVersion, .URIScheme, org.apache.hc.core5.http.config.Lookup, .RegistryBuilder, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler, .AsyncPushConsumer, .HandlerFactory, org.apache.hc.core5.http.nio.command.RequestExecutionCommand, org.apache.hc.core5.http.nio.ssl.TlsStrategy, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.http2.HttpVersionPolicy, org.apache.hc.core5.http2.nio.command.PingCommand, org.apache.hc.core5.http2.nio.support.BasicPingHandler, org.apache.hc.core5.http2.ssl.ApplicationProtocol, org.apache.hc.core5.io.CloseMode, org.apache.hc.core5.pool.ConnPoolControl, .LaxConnPool, .ManagedConnPool, .PoolConcurrencyPolicy, .PoolEntry, .PoolReusePolicy, .PoolStats, .StrictConnPool, org.apache.hc.core5.reactor.Command, .ConnectionInitiator, .ProtocolIOSession, org.apache.hc.core5.reactor.ssl.TlsDetails, org.apache.hc.core5.util.Args, .Deadline, .Identifiable, .TimeValue, .Timeout, org.slf4j.Logger, .LoggerFactory

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.

Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
private volatile Resolver<HttpRoute, ConnectionConfig>
private final AsyncClientConnectionOperator
public static final int
public static final int
private static final PrefixedIncrementingId
private static final Logger
private final ManagedConnPool<HttpRoute, ManagedAsyncClientConnection>
private volatile Resolver<HttpHost, TlsConfig>

Constructor Summary

AccessConstructor and Description
public
public
public
PoolingAsyncClientConnectionManager(final Lookup<TlsStrategy> tlsStrategyLookup, final PoolConcurrencyPolicy poolConcurrencyPolicy, final TimeValue timeToLive)

public
PoolingAsyncClientConnectionManager(final Lookup<TlsStrategy> tlsStrategyLookup, final PoolConcurrencyPolicy poolConcurrencyPolicy, final PoolReusePolicy poolReusePolicy, final TimeValue timeToLive)

public
PoolingAsyncClientConnectionManager(final Lookup<TlsStrategy> tlsStrategyLookup, final PoolConcurrencyPolicy poolConcurrencyPolicy, final PoolReusePolicy poolReusePolicy, final TimeValue timeToLive, final SchemePortResolver schemePortResolver, final DnsResolver dnsResolver)

protected
PoolingAsyncClientConnectionManager(final AsyncClientConnectionOperator connectionOperator, final PoolConcurrencyPolicy poolConcurrencyPolicy, final PoolReusePolicy poolReusePolicy, final TimeValue timeToLive)

protected

Method Summary

Modifier and TypeMethod and Description
private PoolingAsyncClientConnectionManager.InternalConnectionEndpoint
cast(final AsyncConnectionEndpoint endpoint)

public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public void
close(final CloseMode
How to close the receiver.
closeMode
)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it.
public void
public void
pack-priv void
public Future<AsyncConnectionEndpoint>
connect(final AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
final ConnectionInitiator connectionInitiator, final Timeout
connect timeout.
timeout
,
final Object
connect request attachment.
attachment
,
final HttpContext
the actual HTTP context.
context
,
final FutureCallback<AsyncConnectionEndpoint>
result callback.
callback
)

Implements org.apache.hc.client5.http.nio.AsyncClientConnectionManager.connect.

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).
public int
public int
public int
public Set<HttpRoute>
public PoolStats
public PoolStats
public TimeValue
pack-priv boolean

Returns:

true if the connection manager has been shut down and is closed, otherwise return false.
isClosed
()

Method that can be called to determine whether the connection manager has been shut down and is closed or not.

public Future<AsyncConnectionEndpoint>
lease(final String
unique operation ID or null.
id
,
final HttpRoute
HTTP route of the requested connection.
route
,
final Object
expected state of the connection or null if the connection is not expected to carry any state.
state
,
final Timeout
lease request timeout.
requestTimeout
,
final FutureCallback<AsyncConnectionEndpoint>
result callback.
callback
)

Implements org.apache.hc.client5.http.nio.AsyncClientConnectionManager.lease.

Returns a Future object which can be used to obtain an AsyncConnectionEndpoint or to cancel the request by calling Future#cancel(boolean).
public void
release(final AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
final Object
the new connection state of null if state-less.
state
,
final TimeValue
the duration of time this connection is valid for reuse.
keepAlive
)

Implements org.apache.hc.client5.http.nio.AsyncClientConnectionManager.release.

Releases the endpoint back to the manager making it potentially re-usable by other consumers.
private ConnectionConfig
private TlsConfig
resolveTlsConfig(final HttpHost host, final Object attachment)

public void
setConnectionConfigResolver(final Resolver<HttpRoute, ConnectionConfig> connectionConfigResolver)

Sets Resolver of ConnectionConfig on a per route basis.

public void
setDefaultConnectionConfig(final ConnectionConfig config)

Sets the same ConnectionConfig for all routes

public void
public void
setDefaultTlsConfig(final TlsConfig config)

Sets the same ConnectionConfig for all hosts

public void
public void
public void
setTlsConfigResolver(final Resolver<HttpHost, TlsConfig> tlsConfigResolver)

Sets Resolver of TlsConfig on a per host basis.

public void
setValidateAfterInactivity(final 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.
public void
upgrade(final AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
final Object
the attachment the upgrade attachment object.
attachment
,
final HttpContext
the actual HTTP context.
context
,
final FutureCallback<AsyncConnectionEndpoint>
result callback.
callback
)

Overrides default org.apache.hc.client5.http.nio.AsyncClientConnectionManager.upgrade.

Upgrades transport security of the given endpoint by using the TLS security protocol.
public void
upgrade(final AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
final Object
the attachment the upgrade attachment object.
attachment
,
final HttpContext
the actual HTTP context.
context
)

Implements org.apache.hc.client5.http.nio.AsyncClientConnectionManager.upgrade.

Upgrades transport security of the given endpoint by using the TLS security protocol.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait