Class InternalHttpAsyncExecRuntime
- java.lang.Object
-
- org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime
-
- All Implemented Interfaces:
AsyncExecRuntime
class InternalHttpAsyncExecRuntime extends java.lang.Object implements AsyncExecRuntime
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.hc.core5.reactor.ConnectionInitiatorconnectionInitiatorprivate java.util.concurrent.atomic.AtomicReference<AsyncConnectionEndpoint>endpointRefprivate org.slf4j.Loggerlogprivate AsyncClientConnectionManagermanagerprivate org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer>pushHandlerFactoryprivate booleanreusableprivate java.lang.Objectstateprivate TlsConfigtlsConfigDeprecated.TLS should be configured by the connection managerprivate org.apache.hc.core5.util.TimeValuevalidDuration
-
Constructor Summary
Constructors Constructor Description InternalHttpAsyncExecRuntime(org.slf4j.Logger log, AsyncClientConnectionManager manager, org.apache.hc.core5.reactor.ConnectionInitiator connectionInitiator, org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer> pushHandlerFactory, TlsConfig tlsConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.hc.core5.concurrent.CancellableacquireEndpoint(java.lang.String id, HttpRoute route, java.lang.Object object, 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).voiddiscardEndpoint()Shuts down and discards the acquired endpoint.private voiddiscardEndpoint(AsyncConnectionEndpoint endpoint)voiddisconnectEndpoint()Disconnects the local endpoint from the initial hop in the connection route.(package private) AsyncConnectionEndpointensureValid()org.apache.hc.core5.concurrent.Cancellableexecute(java.lang.String id, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler exchangeHandler, HttpClientContext context)Initiates a message exchange using the given handler.AsyncExecRuntimefork()Forks this runtime for parallel execution.booleanisEndpointAcquired()Determines of a connection endpoint has been acquired.booleanisEndpointConnected()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).voidmarkConnectionNonReusable()Marks the connection as non re-usable.voidmarkConnectionReusable(java.lang.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.voidreleaseEndpoint()Releases 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.voidupgradeTls(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback)Upgrades transport security of the active connection by using the TLS security protocol.booleanvalidateConnection()Validates the connection making sure it can be used to execute requests.
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
-
manager
private final AsyncClientConnectionManager manager
-
connectionInitiator
private final org.apache.hc.core5.reactor.ConnectionInitiator connectionInitiator
-
pushHandlerFactory
private final org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer> pushHandlerFactory
-
tlsConfig
@Deprecated private final TlsConfig tlsConfig
Deprecated.TLS should be configured by the connection manager
-
endpointRef
private final java.util.concurrent.atomic.AtomicReference<AsyncConnectionEndpoint> endpointRef
-
reusable
private volatile boolean reusable
-
state
private volatile java.lang.Object state
-
validDuration
private volatile org.apache.hc.core5.util.TimeValue validDuration
-
-
Constructor Detail
-
InternalHttpAsyncExecRuntime
InternalHttpAsyncExecRuntime(org.slf4j.Logger log, AsyncClientConnectionManager manager, org.apache.hc.core5.reactor.ConnectionInitiator connectionInitiator, org.apache.hc.core5.http.nio.HandlerFactory<org.apache.hc.core5.http.nio.AsyncPushConsumer> pushHandlerFactory, TlsConfig tlsConfig)
-
-
Method Detail
-
isEndpointAcquired
public boolean isEndpointAcquired()
Description copied from interface:AsyncExecRuntimeDetermines of a connection endpoint has been acquired.- Specified by:
isEndpointAcquiredin interfaceAsyncExecRuntime- Returns:
trueif an endpoint has been acquired,falseotherwise.
-
acquireEndpoint
public org.apache.hc.core5.concurrent.Cancellable acquireEndpoint(java.lang.String id, HttpRoute route, java.lang.Object object, HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback)Description copied from interface:AsyncExecRuntimeInitiates operation to acquire a connection endpoint. Endpoints can leased from a pool or unconnected new endpoint can be created.- Specified by:
acquireEndpointin interfaceAsyncExecRuntime- Parameters:
id- unique operation ID ornull.route- the connection route.object- 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.
-
discardEndpoint
private void discardEndpoint(AsyncConnectionEndpoint endpoint)
-
releaseEndpoint
public void releaseEndpoint()
Description copied from interface:AsyncExecRuntimeReleases the acquired endpoint potentially making it available for re-use.- Specified by:
releaseEndpointin interfaceAsyncExecRuntime
-
discardEndpoint
public void discardEndpoint()
Description copied from interface:AsyncExecRuntimeShuts down and discards the acquired endpoint.- Specified by:
discardEndpointin interfaceAsyncExecRuntime
-
validateConnection
public boolean validateConnection()
Description copied from interface:AsyncExecRuntimeValidates the connection making sure it can be used to execute requests.- Specified by:
validateConnectionin interfaceAsyncExecRuntime- Returns:
trueif the connection is valid,false.
-
ensureValid
AsyncConnectionEndpoint ensureValid()
-
isEndpointConnected
public boolean isEndpointConnected()
Description copied from interface:AsyncExecRuntimeDetermines 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:
isEndpointConnectedin interfaceAsyncExecRuntime- Returns:
trueif the endpoint is connected,falseotherwise.
-
connectEndpoint
public org.apache.hc.core5.concurrent.Cancellable connectEndpoint(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback)
Description copied from interface:AsyncExecRuntimeInitiates 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:
connectEndpointin 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:AsyncExecRuntimeDisconnects the local endpoint from the initial hop in the connection route.- Specified by:
disconnectEndpointin interfaceAsyncExecRuntime
-
upgradeTls
public void upgradeTls(HttpClientContext context)
Description copied from interface:AsyncExecRuntimeUpgrades transport security of the active connection by using the TLS security protocol.- Specified by:
upgradeTlsin interfaceAsyncExecRuntime- Parameters:
context- the execution context.
-
upgradeTls
public void upgradeTls(HttpClientContext context, org.apache.hc.core5.concurrent.FutureCallback<AsyncExecRuntime> callback)
Description copied from interface:AsyncExecRuntimeUpgrades transport security of the active connection by using the TLS security protocol.- Specified by:
upgradeTlsin interfaceAsyncExecRuntime- Parameters:
context- the execution context.
-
execute
public org.apache.hc.core5.concurrent.Cancellable execute(java.lang.String id, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler exchangeHandler, HttpClientContext context)Description copied from interface:AsyncExecRuntimeInitiates a message exchange using the given handler.- Specified by:
executein interfaceAsyncExecRuntime- Parameters:
id- unique operation ID ornull.exchangeHandler- the client message handler.context- the execution context.
-
markConnectionReusable
public void markConnectionReusable(java.lang.Object newState, org.apache.hc.core5.util.TimeValue newValidDuration)Description copied from interface:AsyncExecRuntimeMarks 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:
markConnectionReusablein interfaceAsyncExecRuntime- Parameters:
newState- the connection state representation ornullif stateless.newValidDuration- the period of time this connection is valid for.
-
markConnectionNonReusable
public void markConnectionNonReusable()
Description copied from interface:AsyncExecRuntimeMarks the connection as non re-usable.- Specified by:
markConnectionNonReusablein interfaceAsyncExecRuntime
-
fork
public AsyncExecRuntime fork()
Description copied from interface:AsyncExecRuntimeForks this runtime for parallel execution.- Specified by:
forkin interfaceAsyncExecRuntime- Returns:
- another runtime with the same configuration.
-
-