Class SharedHttpClientSessionManager

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CORE_POOL_SIZE_PROPERTY
      Configurable system property org.eclipse.rdf4j.client.executors.corePoolSize for specifying the background executor core thread pool size.
      private org.apache.http.impl.client.CloseableHttpClient dependentClient
      dependent life cycle
      private java.util.concurrent.ExecutorService executor  
      private org.apache.http.client.HttpClient httpClient
      independent life cycle
      private org.apache.http.impl.client.HttpClientBuilder httpClientBuilder
      Optional HttpClientBuilder to create the inner httpClient (if not provided externally)
      private org.slf4j.Logger logger  
      private java.util.Map<SPARQLProtocolSession,​java.lang.Boolean> openSessions  
      private static org.apache.http.client.HttpRequestRetryHandler retryHandlerStale  
      private static org.apache.http.client.ServiceUnavailableRetryStrategy serviceUnavailableRetryHandler  
      private static java.util.concurrent.atomic.AtomicLong threadCount  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      private org.apache.http.impl.client.CloseableHttpClient createHttpClient()  
      RDF4JProtocolSession createRDF4JProtocolSession​(java.lang.String serverURL)
      Creates a new session to the remote RDF4J REST API.
      SPARQLProtocolSession createSPARQLProtocolSession​(java.lang.String queryEndpointUrl, java.lang.String updateEndpointUrl)
      Creates a new SPARQL Protocol session to the remote SPARQL endpoint.
      protected java.util.concurrent.ExecutorService getExecutorService()
      Get the ExecutorService used by this session manager.
      org.apache.http.client.HttpClient getHttpClient()
      HttpClient that has been assigned or has been used by this object.
      void initialize()
      Deprecated.
      Create a new instance instead of trying to reactivate an old instance.
      void setHttpClient​(org.apache.http.client.HttpClient httpClient)
      Assign an HttpClient that this object should use.
      void setHttpClientBuilder​(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder)
      Set an optional HttpClientBuilder to create the inner httpClient (if the latter is not provided externally as dependent client).
      void shutDown()
      Closes any remaining connections and threads used by the sessions created by this object.
      • Methods inherited from class java.lang.Object

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

      • CORE_POOL_SIZE_PROPERTY

        public static final java.lang.String CORE_POOL_SIZE_PROPERTY
        Configurable system property org.eclipse.rdf4j.client.executors.corePoolSize for specifying the background executor core thread pool size.
        See Also:
        Constant Field Values
      • threadCount

        private static final java.util.concurrent.atomic.AtomicLong threadCount
      • logger

        private final org.slf4j.Logger logger
      • httpClient

        private volatile org.apache.http.client.HttpClient httpClient
        independent life cycle
      • dependentClient

        private volatile org.apache.http.impl.client.CloseableHttpClient dependentClient
        dependent life cycle
      • executor

        private final java.util.concurrent.ExecutorService executor
      • httpClientBuilder

        private volatile org.apache.http.impl.client.HttpClientBuilder httpClientBuilder
        Optional HttpClientBuilder to create the inner httpClient (if not provided externally)
      • retryHandlerStale

        private static final org.apache.http.client.HttpRequestRetryHandler retryHandlerStale
      • serviceUnavailableRetryHandler

        private static final org.apache.http.client.ServiceUnavailableRetryStrategy serviceUnavailableRetryHandler
    • Constructor Detail

      • SharedHttpClientSessionManager

        public SharedHttpClientSessionManager()
      • SharedHttpClientSessionManager

        public SharedHttpClientSessionManager​(org.apache.http.impl.client.CloseableHttpClient dependentClient,
                                              java.util.concurrent.ScheduledExecutorService dependentExecutorService)
    • Method Detail

      • getHttpClient

        public org.apache.http.client.HttpClient getHttpClient()
        Description copied from interface: HttpClientDependent
        HttpClient that has been assigned or has been used by this object. The life cycle might not be or might be tied to this object, depending on whether HttpClient was passed to or created by this object respectively.
        Specified by:
        getHttpClient in interface HttpClientDependent
        Specified by:
        getHttpClient in interface HttpClientSessionManager
        Returns:
        Returns the httpClient.
      • setHttpClient

        public void setHttpClient​(org.apache.http.client.HttpClient httpClient)
        Description copied from interface: HttpClientDependent
        Assign an HttpClient that this object should use. The life cycle of the given HttpClient is independent of this object. Closing or shutting down this object does not have any impact on the given client. Callers must ensure that the given client is properly closed elsewhere.
        Specified by:
        setHttpClient in interface HttpClientDependent
        Parameters:
        httpClient - The httpClient to use for remote/service calls.
      • setHttpClientBuilder

        public void setHttpClientBuilder​(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder)
        Set an optional HttpClientBuilder to create the inner httpClient (if the latter is not provided externally as dependent client).
        Parameters:
        httpClientBuilder - the builder for the managed HttpClient
        See Also:
        HttpClientBuilders
      • initialize

        @Deprecated
        public void initialize()
        Deprecated.
        Create a new instance instead of trying to reactivate an old instance.
        No-op
      • getExecutorService

        protected final java.util.concurrent.ExecutorService getExecutorService()
        Get the ExecutorService used by this session manager.
        Returns:
        a ExecutorService used by all SPARQLProtocolSession and RDF4JProtocolSession instances created by this session manager.
      • createHttpClient

        private org.apache.http.impl.client.CloseableHttpClient createHttpClient()