Class 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
    • 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
      void acquireEndpoint​(java.lang.String id, HttpRoute route, java.lang.Object object, HttpClientContext context)
      Acquires a connection endpoint.
      boolean cancel()  
      private void connectEndpoint​(ConnectionEndpoint endpoint, HttpClientContext context)  
      void connectEndpoint​(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).
      void discardEndpoint()
      Shuts down and discards the acquired endpoint.
      private void discardEndpoint​(ConnectionEndpoint endpoint)  
      void disconnectEndpoint()
      Disconnects the local endpoint from the initial hop in the connection route.
      (package private) ConnectionEndpoint ensureValid()  
      org.apache.hc.core5.http.ClassicHttpResponse execute​(java.lang.String id, org.apache.hc.core5.http.ClassicHttpRequest request, HttpClientContext context)
      Executes HTTP request using the given context.
      ExecRuntime fork​(org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency)
      Forks this runtime for parallel execution.
      boolean isConnectionReusable()
      Determines of the connection is considered re-usable.
      boolean isEndpointAcquired()
      Determines of a connection endpoint has been acquired.
      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).
      boolean isExecutionAborted()
      Determines of the request execution has been aborted.
      void markConnectionNonReusable()
      Marks the connection as non re-usable.
      void markConnectionReusable​(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.
      void releaseEndpoint()
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        private final org.slf4j.Logger log
      • 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: ExecRuntime
        Determines of the request execution has been aborted.
        Specified by:
        isExecutionAborted in interface ExecRuntime
        Returns:
        true if the request execution has been acquired, false otherwise.
      • isEndpointAcquired

        public boolean isEndpointAcquired()
        Description copied from interface: ExecRuntime
        Determines of a connection endpoint has been acquired.
        Specified by:
        isEndpointAcquired in interface ExecRuntime
        Returns:
        true if an endpoint has been acquired, false otherwise.
      • acquireEndpoint

        public void acquireEndpoint​(java.lang.String id,
                                    HttpRoute route,
                                    java.lang.Object object,
                                    HttpClientContext context)
                             throws java.io.IOException
        Description copied from interface: ExecRuntime
        Acquires a connection endpoint. Endpoints can leased from a pool or unconnected new endpoint can be created.
        Specified by:
        acquireEndpoint in interface ExecRuntime
        Parameters:
        id - unique operation ID or null.
        route - the connection route.
        object - the expected connection state. May be null if connection can be state-less or its state is irrelevant.
        context - the execution context.
        Throws:
        java.io.IOException
      • isEndpointConnected

        public boolean isEndpointConnected()
        Description copied from interface: ExecRuntime
        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 interface ExecRuntime
        Returns:
        true if the endpoint is connected, false otherwise.
      • connectEndpoint

        public void connectEndpoint​(HttpClientContext context)
                             throws java.io.IOException
        Description copied from interface: ExecRuntime
        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 interface ExecRuntime
        Parameters:
        context - the execution context.
        Throws:
        java.io.IOException
      • disconnectEndpoint

        public void disconnectEndpoint()
                                throws java.io.IOException
        Description copied from interface: ExecRuntime
        Disconnects the local endpoint from the initial hop in the connection route.
        Specified by:
        disconnectEndpoint in interface ExecRuntime
        Throws:
        java.io.IOException
      • upgradeTls

        public void upgradeTls​(HttpClientContext context)
                        throws java.io.IOException
        Description copied from interface: ExecRuntime
        Upgrades transport security of the active connection by using the TLS security protocol.
        Specified by:
        upgradeTls in interface ExecRuntime
        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.HttpException
        Description copied from interface: ExecRuntime
        Executes HTTP request using the given context.
        Specified by:
        execute in interface ExecRuntime
        Parameters:
        id - unique operation ID or null.
        request - the request message.
        context - the execution context.
        Throws:
        java.io.IOException
        org.apache.hc.core5.http.HttpException
      • isConnectionReusable

        public boolean isConnectionReusable()
        Description copied from interface: ExecRuntime
        Determines of the connection is considered re-usable.
        Specified by:
        isConnectionReusable in interface ExecRuntime
        Returns:
        true if the connection is re-usable, false otherwise.
      • markConnectionReusable

        public void markConnectionReusable​(java.lang.Object state,
                                           org.apache.hc.core5.util.TimeValue validDuration)
        Description copied from interface: ExecRuntime
        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 interface ExecRuntime
        Parameters:
        state - the connection state representation or null if stateless.
        validDuration - the period of time this connection is valid for.
      • releaseEndpoint

        public void releaseEndpoint()
        Description copied from interface: ExecRuntime
        Releases the acquired endpoint potentially making it available for re-use.
        Specified by:
        releaseEndpoint in interface ExecRuntime
      • discardEndpoint

        public void discardEndpoint()
        Description copied from interface: ExecRuntime
        Shuts down and discards the acquired endpoint.
        Specified by:
        discardEndpoint in interface ExecRuntime
      • cancel

        public boolean cancel()
        Specified by:
        cancel in interface org.apache.hc.core5.concurrent.Cancellable
      • fork

        public ExecRuntime fork​(org.apache.hc.core5.concurrent.CancellableDependency cancellableDependency)
        Description copied from interface: ExecRuntime
        Forks this runtime for parallel execution.
        Specified by:
        fork in interface ExecRuntime
        Returns:
        another runtime with the same configuration.