Class InternalExecRuntime
- java.lang.Object
-
- org.apache.hc.client5.http.impl.classic.InternalExecRuntime
-
- All Implemented Interfaces:
ExecRuntime,org.apache.hc.core5.concurrent.Cancellable
class InternalExecRuntime extends java.lang.Object implements ExecRuntime, org.apache.hc.core5.concurrent.Cancellable
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.hc.core5.concurrent.CancellableDependencycancellableDependencyprivate java.util.concurrent.atomic.AtomicReference<ConnectionEndpoint>endpointRefprivate org.slf4j.Loggerlogprivate HttpClientConnectionManagermanagerprivate org.apache.hc.core5.http.impl.io.HttpRequestExecutorrequestExecutorprivate booleanreusableprivate java.lang.Objectstateprivate org.apache.hc.core5.util.TimeValuevalidDuration
-
Constructor Summary
Constructors Constructor Description InternalExecRuntime(org.slf4j.Logger log, HttpClientConnectionManager manager, org.apache.hc.core5.http.impl.io.HttpRequestExecutor requestExecutor, org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireEndpoint(java.lang.String id, HttpRoute route, java.lang.Object object, HttpClientContext context)Acquires a connection endpoint.booleancancel()private voidconnectEndpoint(ConnectionEndpoint endpoint, HttpClientContext context)voidconnectEndpoint(HttpClientContext context)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(ConnectionEndpoint endpoint)voiddisconnectEndpoint()Disconnects the local endpoint from the initial hop in the connection route.(package private) ConnectionEndpointensureValid()org.apache.hc.core5.http.ClassicHttpResponseexecute(java.lang.String id, org.apache.hc.core5.http.ClassicHttpRequest request, HttpClientContext context)Executes HTTP request using the given context.ExecRuntimefork(org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency)Forks this runtime for parallel execution.booleanisConnectionReusable()Determines of the connection is considered re-usable.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).booleanisExecutionAborted()Determines of the request execution has been aborted.voidmarkConnectionNonReusable()Marks the connection as non re-usable.voidmarkConnectionReusable(java.lang.Object state, org.apache.hc.core5.util.TimeValue validDuration)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.
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
-
manager
private final HttpClientConnectionManager manager
-
requestExecutor
private final org.apache.hc.core5.http.impl.io.HttpRequestExecutor requestExecutor
-
cancellableDependency
private final org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency
-
endpointRef
private final java.util.concurrent.atomic.AtomicReference<ConnectionEndpoint> 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
-
InternalExecRuntime
InternalExecRuntime(org.slf4j.Logger log, HttpClientConnectionManager manager, org.apache.hc.core5.http.impl.io.HttpRequestExecutor requestExecutor, org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency)
-
-
Method Detail
-
isExecutionAborted
public boolean isExecutionAborted()
Description copied from interface:ExecRuntimeDetermines of the request execution has been aborted.- Specified by:
isExecutionAbortedin interfaceExecRuntime- Returns:
trueif the request execution has been acquired,falseotherwise.
-
isEndpointAcquired
public boolean isEndpointAcquired()
Description copied from interface:ExecRuntimeDetermines of a connection endpoint has been acquired.- Specified by:
isEndpointAcquiredin interfaceExecRuntime- Returns:
trueif an endpoint has been acquired,falseotherwise.
-
acquireEndpoint
public void acquireEndpoint(java.lang.String id, HttpRoute route, java.lang.Object object, HttpClientContext context) throws java.io.IOExceptionDescription copied from interface:ExecRuntimeAcquires a connection endpoint. Endpoints can leased from a pool or unconnected new endpoint can be created.- Specified by:
acquireEndpointin interfaceExecRuntime- 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.- Throws:
java.io.IOException
-
ensureValid
ConnectionEndpoint ensureValid()
-
isEndpointConnected
public boolean isEndpointConnected()
Description copied from interface:ExecRuntimeDetermines 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 interfaceExecRuntime- Returns:
trueif the endpoint is connected,falseotherwise.
-
connectEndpoint
private void connectEndpoint(ConnectionEndpoint endpoint, HttpClientContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
connectEndpoint
public void connectEndpoint(HttpClientContext context) throws java.io.IOException
Description copied from interface:ExecRuntimeConnect 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 interfaceExecRuntime- Parameters:
context- the execution context.- Throws:
java.io.IOException
-
disconnectEndpoint
public void disconnectEndpoint() throws java.io.IOExceptionDescription copied from interface:ExecRuntimeDisconnects the local endpoint from the initial hop in the connection route.- Specified by:
disconnectEndpointin interfaceExecRuntime- Throws:
java.io.IOException
-
upgradeTls
public void upgradeTls(HttpClientContext context) throws java.io.IOException
Description copied from interface:ExecRuntimeUpgrades transport security of the active connection by using the TLS security protocol.- Specified by:
upgradeTlsin interfaceExecRuntime- Parameters:
context- the execution context.- Throws:
java.io.IOException
-
execute
public org.apache.hc.core5.http.ClassicHttpResponse execute(java.lang.String id, org.apache.hc.core5.http.ClassicHttpRequest request, HttpClientContext context) throws java.io.IOException, org.apache.hc.core5.http.HttpExceptionDescription copied from interface:ExecRuntimeExecutes HTTP request using the given context.- Specified by:
executein interfaceExecRuntime- Parameters:
id- unique operation ID ornull.request- the request message.context- the execution context.- Throws:
java.io.IOExceptionorg.apache.hc.core5.http.HttpException
-
isConnectionReusable
public boolean isConnectionReusable()
Description copied from interface:ExecRuntimeDetermines of the connection is considered re-usable.- Specified by:
isConnectionReusablein interfaceExecRuntime- Returns:
trueif the connection is re-usable,falseotherwise.
-
markConnectionReusable
public void markConnectionReusable(java.lang.Object state, org.apache.hc.core5.util.TimeValue validDuration)Description copied from interface:ExecRuntimeMarks 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 interfaceExecRuntime- Parameters:
state- the connection state representation ornullif stateless.validDuration- the period of time this connection is valid for.
-
markConnectionNonReusable
public void markConnectionNonReusable()
Description copied from interface:ExecRuntimeMarks the connection as non re-usable.- Specified by:
markConnectionNonReusablein interfaceExecRuntime
-
discardEndpoint
private void discardEndpoint(ConnectionEndpoint endpoint)
-
releaseEndpoint
public void releaseEndpoint()
Description copied from interface:ExecRuntimeReleases the acquired endpoint potentially making it available for re-use.- Specified by:
releaseEndpointin interfaceExecRuntime
-
discardEndpoint
public void discardEndpoint()
Description copied from interface:ExecRuntimeShuts down and discards the acquired endpoint.- Specified by:
discardEndpointin interfaceExecRuntime
-
cancel
public boolean cancel()
- Specified by:
cancelin interfaceorg.apache.hc.core5.concurrent.Cancellable
-
fork
public ExecRuntime fork(org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency)
Description copied from interface:ExecRuntimeForks this runtime for parallel execution.- Specified by:
forkin interfaceExecRuntime- Returns:
- another runtime with the same configuration.
-
-