Package org.apache.hc.client5.http.async
Interface AsyncExecRuntime
- All Known Implementing Classes:
InternalH2AsyncExecRuntime,InternalHttpAsyncExecRuntime
@Internal
public interface AsyncExecRuntime
Execution runtime that provides access to the underlying connection endpoint and helps
manager its life cycle.
This interface is considered internal and generally ought not be used or accessed by custom request exec handlers.
- Since:
- 5.0
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.concurrent.CancellableacquireEndpoint(String id, HttpRoute route, Object state, HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Initiates operation to acquire a connection endpoint.org.apache.hc.core5.concurrent.CancellableconnectEndpoint(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Initiates operation to connect the local 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).voidShuts down and discards the acquired endpoint.voidDisconnects the local endpoint from the initial hop in the connection route.org.apache.hc.core5.concurrent.Cancellableexecute(String id, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler exchangeHandler, HttpClientContext context) Initiates a message exchange using the given handler.fork()Forks this runtime for parallel execution.booleanDetermines of a connection endpoint has been acquired.booleanDetermines of there the endpoint is connected 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).voidMarks the connection as non re-usable.voidmarkConnectionReusable(Object state, org.apache.hc.core5.util.TimeValue validityTime) Marks the connection as potentially re-usable for the given period of time and also marks it as stateful if the state representation is given.voidReleases the acquired endpoint potentially making it available for re-use.voidupgradeTls(HttpClientContext context) Upgrades transport security of the active connection by using the TLS security protocol.default voidupgradeTls(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Upgrades transport security of the active connection by using the TLS security protocol.booleanValidates the connection making sure it can be used to execute requests.
-
Method Details
-
isEndpointAcquired
boolean isEndpointAcquired()Determines of a connection endpoint has been acquired.- Returns:
trueif an endpoint has been acquired,falseotherwise.
-
acquireEndpoint
org.apache.hc.core5.concurrent.Cancellable acquireEndpoint(String id, HttpRoute route, Object state, HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Initiates operation to acquire a connection endpoint. Endpoints can leased from a pool or unconnected new endpoint can be created.- Parameters:
id- unique operation ID ornull.route- the connection route.state- the expected connection state. May benullif connection can be state-less or its state is irrelevant.context- the execution context.callback- the result callback.- Returns:
- handle that can be used to cancel the operation.
-
releaseEndpoint
void releaseEndpoint()Releases the acquired endpoint potentially making it available for re-use. -
discardEndpoint
void discardEndpoint()Shuts down and discards the acquired endpoint. -
isEndpointConnected
boolean isEndpointConnected()Determines of there the endpoint is connected 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).- Returns:
trueif the endpoint is connected,falseotherwise.
-
connectEndpoint
org.apache.hc.core5.concurrent.Cancellable connectEndpoint(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Initiates operation to connect the local 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:
context- the execution context.callback- the result callback.- Returns:
- handle that can be used to cancel the operation.
-
disconnectEndpoint
void disconnectEndpoint()Disconnects the local endpoint from the initial hop in the connection route. -
upgradeTls
Upgrades transport security of the active connection by using the TLS security protocol.- Parameters:
context- the execution context.
-
upgradeTls
default void upgradeTls(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Upgrades transport security of the active connection by using the TLS security protocol.- Parameters:
context- the execution context.- Since:
- 5.2
-
validateConnection
boolean validateConnection()Validates the connection making sure it can be used to execute requests.- Returns:
trueif the connection is valid,false.
-
execute
org.apache.hc.core5.concurrent.Cancellable execute(String id, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler exchangeHandler, HttpClientContext context) Initiates a message exchange using the given handler.- Parameters:
id- unique operation ID ornull.exchangeHandler- the client message handler.context- the execution context.
-
markConnectionReusable
Marks the connection as potentially re-usable for the given period of time and also marks it as stateful if the state representation is given.- Parameters:
state- the connection state representation ornullif stateless.validityTime- the period of time this connection is valid for.
-
markConnectionNonReusable
void markConnectionNonReusable()Marks the connection as non re-usable. -
fork
AsyncExecRuntime fork()Forks this runtime for parallel execution.- Returns:
- another runtime with the same configuration.
-