Class InternalH2AsyncExecRuntime
java.lang.Object
org.apache.hc.client5.http.impl.async.InternalH2AsyncExecRuntime
- All Implemented Interfaces:
AsyncExecRuntime
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InternalH2ConnPool
private final org.slf4j.Logger
private final org.apache.hc.core5.http.nio.HandlerFactory
<org.apache.hc.core5.http.nio.AsyncPushConsumer> private boolean
private final AtomicReference
<InternalH2AsyncExecRuntime.Endpoint> -
Constructor Summary
ConstructorsConstructorDescriptionInternalH2AsyncExecRuntime
(org.slf4j.Logger log, InternalH2ConnPool connPool, org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer> pushHandlerFactory) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.concurrent.Cancellable
acquireEndpoint
(String id, HttpRoute route, Object object, HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Initiates operation to acquire a connection endpoint.private void
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).void
Shuts down and discards the acquired endpoint.void
Disconnects the local endpoint from the initial hop in the connection route.(package private) InternalH2AsyncExecRuntime.Endpoint
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.fork()
Forks this runtime for parallel execution.boolean
Determines of a connection endpoint has been acquired.boolean
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).void
Marks the connection as non re-usable.void
markConnectionReusable
(Object newState, org.apache.hc.core5.util.TimeValue newValidDuration) 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.void
Releases the acquired endpoint potentially making it available for re-use.void
upgradeTls
(HttpClientContext context) Upgrades transport security of the active connection by using the TLS security protocol.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.boolean
Validates the connection making sure it can be used to execute requests.
-
Field Details
-
log
private final org.slf4j.Logger log -
connPool
-
pushHandlerFactory
private final org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer> pushHandlerFactory -
sessionRef
-
reusable
private volatile boolean reusable
-
-
Constructor Details
-
InternalH2AsyncExecRuntime
InternalH2AsyncExecRuntime(org.slf4j.Logger log, InternalH2ConnPool connPool, org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer> pushHandlerFactory)
-
-
Method Details
-
isEndpointAcquired
public boolean isEndpointAcquired()Description copied from interface:AsyncExecRuntime
Determines of a connection endpoint has been acquired.- Specified by:
isEndpointAcquired
in interfaceAsyncExecRuntime
- Returns:
true
if an endpoint has been acquired,false
otherwise.
-
acquireEndpoint
public org.apache.hc.core5.concurrent.Cancellable acquireEndpoint(String id, HttpRoute route, Object object, HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Description copied from interface:AsyncExecRuntime
Initiates operation to acquire a connection endpoint. Endpoints can leased from a pool or unconnected new endpoint can be created.- Specified by:
acquireEndpoint
in interfaceAsyncExecRuntime
- Parameters:
id
- unique operation ID ornull
.route
- the connection route.object
- the expected connection state. May benull
if 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.
-
closeEndpoint
-
releaseEndpoint
public void releaseEndpoint()Description copied from interface:AsyncExecRuntime
Releases the acquired endpoint potentially making it available for re-use.- Specified by:
releaseEndpoint
in interfaceAsyncExecRuntime
-
discardEndpoint
public void discardEndpoint()Description copied from interface:AsyncExecRuntime
Shuts down and discards the acquired endpoint.- Specified by:
discardEndpoint
in interfaceAsyncExecRuntime
-
validateConnection
public boolean validateConnection()Description copied from interface:AsyncExecRuntime
Validates the connection making sure it can be used to execute requests.- Specified by:
validateConnection
in interfaceAsyncExecRuntime
- Returns:
true
if the connection is valid,false
.
-
isEndpointConnected
public boolean isEndpointConnected()Description copied from interface:AsyncExecRuntime
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).- Specified by:
isEndpointConnected
in interfaceAsyncExecRuntime
- Returns:
true
if the endpoint is connected,false
otherwise.
-
ensureValid
InternalH2AsyncExecRuntime.Endpoint ensureValid() -
connectEndpoint
public org.apache.hc.core5.concurrent.Cancellable connectEndpoint(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Description copied from interface:AsyncExecRuntime
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).- Specified by:
connectEndpoint
in interfaceAsyncExecRuntime
- Parameters:
context
- the execution context.callback
- the result callback.- Returns:
- handle that can be used to cancel the operation.
-
disconnectEndpoint
public void disconnectEndpoint()Description copied from interface:AsyncExecRuntime
Disconnects the local endpoint from the initial hop in the connection route.- Specified by:
disconnectEndpoint
in interfaceAsyncExecRuntime
-
upgradeTls
Description copied from interface:AsyncExecRuntime
Upgrades transport security of the active connection by using the TLS security protocol.- Specified by:
upgradeTls
in interfaceAsyncExecRuntime
- Parameters:
context
- the execution context.
-
upgradeTls
public void upgradeTls(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback) Description copied from interface:AsyncExecRuntime
Upgrades transport security of the active connection by using the TLS security protocol.- Specified by:
upgradeTls
in interfaceAsyncExecRuntime
- Parameters:
context
- the execution context.
-
execute
public org.apache.hc.core5.concurrent.Cancellable execute(String id, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler exchangeHandler, HttpClientContext context) Description copied from interface:AsyncExecRuntime
Initiates a message exchange using the given handler.- Specified by:
execute
in interfaceAsyncExecRuntime
- Parameters:
id
- unique operation ID ornull
.exchangeHandler
- the client message handler.context
- the execution context.
-
markConnectionReusable
public void markConnectionReusable(Object newState, org.apache.hc.core5.util.TimeValue newValidDuration) Description copied from interface:AsyncExecRuntime
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.- Specified by:
markConnectionReusable
in interfaceAsyncExecRuntime
- Parameters:
newState
- the connection state representation ornull
if stateless.newValidDuration
- the period of time this connection is valid for.
-
markConnectionNonReusable
public void markConnectionNonReusable()Description copied from interface:AsyncExecRuntime
Marks the connection as non re-usable.- Specified by:
markConnectionNonReusable
in interfaceAsyncExecRuntime
-
fork
Description copied from interface:AsyncExecRuntime
Forks this runtime for parallel execution.- Specified by:
fork
in interfaceAsyncExecRuntime
- Returns:
- another runtime with the same configuration.
-