Top Description Methods
org.apache.hc.client5.http.nio

public Interface AsyncClientConnectionManager

extends ModalCloseable
Known Direct Implementers
org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager
Annotations
@Contract
threading:SAFE
Imports
java.util.concurrent.Future, org.apache.hc.client5.http.HttpRoute, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.concurrent.FutureCallback, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.io.ModalCloseable, org.apache.hc.core5.reactor.ConnectionInitiator, org.apache.hc.core5.util.TimeValue, .Timeout

Represents a manager of persistent non-blocking client connections.

The purpose of an HTTP connection manager is to serve as a factory for new HTTP connections, manage persistent connections and synchronize access to persistent connections making sure that only one thread of execution can have access to a connection at a time.

Implementations of this interface must be thread-safe. Access to shared data must be synchronized as methods of this interface may be executed from multiple threads.

Since
5.0

Method Summary

Modifier and TypeMethod and Description
public Future<AsyncConnectionEndpoint>
connect(AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
ConnectionInitiator connectionInitiator, Timeout
connect timeout.
connectTimeout
,
Object
connect request attachment.
attachment
,
HttpContext
the actual HTTP context.
context
,
FutureCallback<AsyncConnectionEndpoint>
result callback.
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).

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

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(AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
Object
the new connection state of null if state-less.
newState
,
TimeValue
the duration of time this connection is valid for reuse.
validDuration
)

Releases the endpoint back to the manager making it potentially re-usable by other consumers.

public void
upgrade(AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
Object
the attachment the upgrade attachment object.
attachment
,
HttpContext
the actual HTTP context.
context
)

Upgrades transport security of the given endpoint by using the TLS security protocol.

public default void
upgrade(AsyncConnectionEndpoint
the managed endpoint.
endpoint
,
Object
the attachment the upgrade attachment object.
attachment
,
HttpContext
the actual HTTP context.
context
,
FutureCallback<AsyncConnectionEndpoint>
result callback.
callback
)

Upgrades transport security of the given endpoint by using the TLS security protocol.

Inherited from org.apache.hc.core5.io.ModalCloseable:
close

Method Detail

connectback to summary
public Future<AsyncConnectionEndpoint> connect(AsyncConnectionEndpoint endpoint, ConnectionInitiator connectionInitiator, Timeout connectTimeout, Object attachment, HttpContext context, FutureCallback<AsyncConnectionEndpoint> 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).

Parameters
endpoint:AsyncConnectionEndpoint

the managed endpoint.

connectTimeout:Timeout

connect timeout.

attachment:Object

connect request attachment.

context:HttpContext

the actual HTTP context.

callback:FutureCallback<AsyncConnectionEndpoint>

result callback.

leaseback to summary
public Future<AsyncConnectionEndpoint> lease(String id, HttpRoute route, Object state, Timeout requestTimeout, FutureCallback<AsyncConnectionEndpoint> callback)

Returns a Future 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 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.

Parameters
id:String

unique operation ID or null.

route:HttpRoute

HTTP route of the requested connection.

state:Object

expected state of the connection or null if the connection is not expected to carry any state.

requestTimeout:Timeout

lease request timeout.

callback:FutureCallback<AsyncConnectionEndpoint>

result callback.

releaseback to summary
public void release(AsyncConnectionEndpoint endpoint, Object newState, TimeValue validDuration)

Releases the endpoint back to the manager making it potentially re-usable by other consumers. Optionally, the maximum period of how long the manager should keep the connection alive can be defined using validDuration and timeUnit parameters.

Parameters
endpoint:AsyncConnectionEndpoint

the managed endpoint.

newState:Object

the new connection state of null if state-less.

validDuration:TimeValue

the duration of time this connection is valid for reuse.

upgradeback to summary
public void upgrade(AsyncConnectionEndpoint endpoint, Object attachment, HttpContext context)

Upgrades transport security of the given endpoint by using the TLS security protocol.

Parameters
endpoint:AsyncConnectionEndpoint

the managed endpoint.

attachment:Object

the attachment the upgrade attachment object.

context:HttpContext

the actual HTTP context.

upgradeback to summary
public default void upgrade(AsyncConnectionEndpoint endpoint, Object attachment, HttpContext context, FutureCallback<AsyncConnectionEndpoint> callback)

Upgrades transport security of the given endpoint by using the TLS security protocol.

Parameters
endpoint:AsyncConnectionEndpoint

the managed endpoint.

attachment:Object

the attachment the upgrade attachment object.

context:HttpContext

the actual HTTP context.

callback:FutureCallback<AsyncConnectionEndpoint>

result callback.

Since
5.2