Class SharedHttpClientSessionManager
- All Implemented Interfaces:
HttpClientDependent,HttpClientSessionManager
HttpClient to manage HTTP connections.- Author:
- James Leigh
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHTTP connection request timeout in milliseconds for general use.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.http.connectionRequestTimeoutfor specifying the HTTP connection request timeout in milliseconds for general use.static final intHTTP connection timeout in milliseconds for general use.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.http.connectionTimeoutfor specifying the HTTP connection timeout in milliseconds for general use.static final intCore pool size for the executor service, as read from system properties or defaults.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.executors.corePoolSizefor specifying the background executor core thread pool size.static final intDefault HTTP connection request timeout in milliseconds for general use.static final intDefault HTTP connection timeout in milliseconds for general use.static final intDefault core pool size for the executor service.static final intDefault maximum number of connections per route (per host).static final intDefault maximum total number of connections.static final intDefault HTTP socket timeout in milliseconds for general use.static final intDefault HTTP connection request timeout in milliseconds for SPARQL SERVICE calls.static final intDefault HTTP connection timeout in milliseconds for SPARQL SERVICE calls.static final intDefault HTTP socket timeout in milliseconds for SPARQL SERVICE calls.static final intMaximum number of connections per route (per host), as read from system properties or defaults.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.http.maxConnPerRoutefor specifying the maximum number of connections per route (per host).static final intMaximum total number of connections, as read from system properties or defaults.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.http.maxConnTotalfor specifying the maximum total number of connections.static final intHTTP socket timeout in milliseconds for general use.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.http.socketTimeoutfor specifying the HTTP socket timeout in milliseconds for general use.static final intHTTP connection request timeout in milliseconds for SPARQL SERVICE calls.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.sparql.http.connectionRequestTimeoutfor specifying the HTTP connection request timeout in milliseconds when used in SPARQL SERVICE calls.static final intHTTP connection timeout in milliseconds for SPARQL SERVICE calls.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.sparql.http.connectionTimeoutfor specifying the HTTP connection timeout in milliseconds when used in SPARQL SERVICE calls.static final intHTTP socket timeout in milliseconds for SPARQL SERVICE calls.static final StringConfigurable system propertyorg.eclipse.rdf4j.client.sparql.http.socketTimeoutfor specifying the HTTP socket timeout in milliseconds when used in SPARQL SERVICE calls. -
Constructor Summary
ConstructorsConstructorDescriptionSharedHttpClientSessionManager(org.apache.http.impl.client.CloseableHttpClient dependentClient, ScheduledExecutorService dependentExecutorService) -
Method Summary
Modifier and TypeMethodDescriptioncreateRDF4JProtocolSession(String serverURL) Creates a new session to the remote RDF4J REST API.createSPARQLProtocolSession(String queryEndpointUrl, String updateEndpointUrl) Creates a new SPARQL Protocol session to the remote SPARQL endpoint.org.apache.http.client.config.RequestConfigReturns the defaultRequestConfigusing the currently set timeout values.protected final ExecutorServiceGet theExecutorServiceused by this session manager.org.apache.http.client.HttpClientHttpClientthat has been assigned or has been used by this object.voidDeprecated.Create a new instance instead of trying to reactivate an old instance.voidSwitches the current timeout settings to use the SPARQL-specific timeouts.voidResets the current timeout settings to the general timeouts.voidsetHttpClient(org.apache.http.client.HttpClient httpClient) Assign anHttpClientthat this object should use.voidsetHttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) Set an optionalHttpClientBuilderto create the innerhttpClient(if the latter is not provided externally as dependent client).voidshutDown()Closes any remaining connections and threads used by the sessions created by this object.
-
Field Details
-
CORE_POOL_SIZE_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.executors.corePoolSizefor specifying the background executor core thread pool size.- See Also:
-
MAX_CONN_PER_ROUTE_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.http.maxConnPerRoutefor specifying the maximum number of connections per route (per host). Default is 25.This property determines the maximum number of concurrent connections to a single host (route). Adjusting this value can improve performance when communicating with a server that supports multiple concurrent connections.
- See Also:
-
MAX_CONN_TOTAL_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.http.maxConnTotalfor specifying the maximum total number of connections. Default is 50.This property sets the maximum total number of concurrent connections that can be open at the same time. Increasing this value allows more simultaneous connections to different hosts, which can improve throughput in multi-threaded environments.
- See Also:
-
CONNECTION_TIMEOUT_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.http.connectionTimeoutfor specifying the HTTP connection timeout in milliseconds for general use. Default is 30 seconds.The connection timeout determines the maximum time the client will wait to establish a TCP connection to the server. A default of 30 seconds is set to allow for potential network delays without causing unnecessary timeouts.
- See Also:
-
CONNECTION_REQUEST_TIMEOUT_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.http.connectionRequestTimeoutfor specifying the HTTP connection request timeout in milliseconds for general use. Default is 1 hour.The connection request timeout defines how long the client will wait for a connection from the connection pool.
- See Also:
-
SOCKET_TIMEOUT_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.http.socketTimeoutfor specifying the HTTP socket timeout in milliseconds for general use. Default is 10 days.The socket timeout controls the maximum period of inactivity between data packets during data transfer. A longer timeout is appropriate for large data transfers, ensuring that operations are not interrupted prematurely.
- See Also:
-
SPARQL_CONNECTION_TIMEOUT_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.sparql.http.connectionTimeoutfor specifying the HTTP connection timeout in milliseconds when used in SPARQL SERVICE calls. Default is 5 seconds.A shorter connection timeout is set for SPARQL SERVICE calls to quickly detect unresponsive endpoints in federated queries, improving overall query performance by avoiding long waits for unreachable servers.
- See Also:
-
SPARQL_CONNECTION_REQUEST_TIMEOUT_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.sparql.http.connectionRequestTimeoutfor specifying the HTTP connection request timeout in milliseconds when used in SPARQL SERVICE calls. Default is 10 minutes.This timeout controls how long the client waits for a connection from the pool when making SPARQL SERVICE calls. A shorter timeout than general use ensures that queries fail fast if resources are constrained, maintaining responsiveness.
- See Also:
-
SPARQL_SOCKET_TIMEOUT_PROPERTY
Configurable system propertyorg.eclipse.rdf4j.client.sparql.http.socketTimeoutfor specifying the HTTP socket timeout in milliseconds when used in SPARQL SERVICE calls. Default is 1 hour.The socket timeout for SPARQL SERVICE calls is set to a shorter duration to detect unresponsive servers during data transfer, ensuring that the client does not wait indefinitely for data that may never arrive.
- See Also:
-
DEFAULT_CORE_POOL_SIZE
public static final int DEFAULT_CORE_POOL_SIZEDefault core pool size for the executor service. Set to 5.This value determines the number of threads to keep in the pool, even if they are idle. Adjusting this value can help manage resource utilization in high-load scenarios.
- See Also:
-
DEFAULT_MAX_CONN_PER_ROUTE
public static final int DEFAULT_MAX_CONN_PER_ROUTEDefault maximum number of connections per route (per host). Set to 25.This value limits the number of concurrent connections to a single host. Increasing it can improve performance when communicating with a server that can handle multiple connections.
- See Also:
-
DEFAULT_MAX_CONN_TOTAL
public static final int DEFAULT_MAX_CONN_TOTALDefault maximum total number of connections. Set to 50.This value limits the total number of concurrent connections that can be open at the same time. Increasing it allows for more simultaneous connections to different hosts.
- See Also:
-
DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUTDefault HTTP connection timeout in milliseconds for general use. Set to 30 seconds.The connection timeout determines the maximum time the client will wait to establish a TCP connection to the server.
- See Also:
-
DEFAULT_CONNECTION_REQUEST_TIMEOUT
public static final int DEFAULT_CONNECTION_REQUEST_TIMEOUTDefault HTTP connection request timeout in milliseconds for general use. Set to 1 hour.The connection request timeout defines how long the client will wait for a connection from the connection pool.
- See Also:
-
DEFAULT_SOCKET_TIMEOUT
public static final int DEFAULT_SOCKET_TIMEOUTDefault HTTP socket timeout in milliseconds for general use. Set to 10 days.The socket timeout controls the maximum period of inactivity between data packets during data transfer. A longer timeout is appropriate for large data transfers.
- See Also:
-
DEFAULT_SPARQL_CONNECTION_TIMEOUT
public static final int DEFAULT_SPARQL_CONNECTION_TIMEOUTDefault HTTP connection timeout in milliseconds for SPARQL SERVICE calls. Set to 5 seconds.A shorter connection timeout is set for SPARQL SERVICE calls to quickly detect unresponsive endpoints in federated queries.
- See Also:
-
DEFAULT_SPARQL_CONNECTION_REQUEST_TIMEOUT
public static final int DEFAULT_SPARQL_CONNECTION_REQUEST_TIMEOUTDefault HTTP connection request timeout in milliseconds for SPARQL SERVICE calls. Set to 10 minutes.This timeout controls how long the client waits for a connection from the pool when making SPARQL SERVICE calls.
- See Also:
-
DEFAULT_SPARQL_SOCKET_TIMEOUT
public static final int DEFAULT_SPARQL_SOCKET_TIMEOUTDefault HTTP socket timeout in milliseconds for SPARQL SERVICE calls. Set to 1 hour.The socket timeout for SPARQL SERVICE calls is set to a shorter duration to detect unresponsive servers during data transfer.
- See Also:
-
CORE_POOL_SIZE
public static final int CORE_POOL_SIZECore pool size for the executor service, as read from system properties or defaults. -
MAX_CONN_PER_ROUTE
public static final int MAX_CONN_PER_ROUTEMaximum number of connections per route (per host), as read from system properties or defaults. -
MAX_CONN_TOTAL
public static final int MAX_CONN_TOTALMaximum total number of connections, as read from system properties or defaults. -
CONNECTION_TIMEOUT
public static final int CONNECTION_TIMEOUTHTTP connection timeout in milliseconds for general use. -
CONNECTION_REQUEST_TIMEOUT
public static final int CONNECTION_REQUEST_TIMEOUTHTTP connection request timeout in milliseconds for general use. -
SOCKET_TIMEOUT
public static final int SOCKET_TIMEOUTHTTP socket timeout in milliseconds for general use. -
SPARQL_CONNECTION_TIMEOUT
public static final int SPARQL_CONNECTION_TIMEOUTHTTP connection timeout in milliseconds for SPARQL SERVICE calls. -
SPARQL_CONNECTION_REQUEST_TIMEOUT
public static final int SPARQL_CONNECTION_REQUEST_TIMEOUTHTTP connection request timeout in milliseconds for SPARQL SERVICE calls. -
SPARQL_SOCKET_TIMEOUT
public static final int SPARQL_SOCKET_TIMEOUTHTTP socket timeout in milliseconds for SPARQL SERVICE calls.
-
-
Constructor Details
-
SharedHttpClientSessionManager
public SharedHttpClientSessionManager() -
SharedHttpClientSessionManager
public SharedHttpClientSessionManager(org.apache.http.impl.client.CloseableHttpClient dependentClient, ScheduledExecutorService dependentExecutorService)
-
-
Method Details
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()Description copied from interface:HttpClientDependentHttpClientthat 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 whetherHttpClientwas passed to or created by this object respectively.- Specified by:
getHttpClientin interfaceHttpClientDependent- Specified by:
getHttpClientin interfaceHttpClientSessionManager- Returns:
- Returns the httpClient.
-
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient httpClient) Description copied from interface:HttpClientDependentAssign anHttpClientthat this object should use. The life cycle of the givenHttpClientis 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:
setHttpClientin interfaceHttpClientDependent- Parameters:
httpClient- The httpClient to use for remote/service calls.
-
setHttpClientBuilder
public void setHttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) Set an optionalHttpClientBuilderto create the innerhttpClient(if the latter is not provided externally as dependent client).- Parameters:
httpClientBuilder- the builder for the managed HttpClient- See Also:
-
createSPARQLProtocolSession
public SPARQLProtocolSession createSPARQLProtocolSession(String queryEndpointUrl, String updateEndpointUrl) Description copied from interface:HttpClientSessionManagerCreates a new SPARQL Protocol session to the remote SPARQL endpoint.- Specified by:
createSPARQLProtocolSessionin interfaceHttpClientSessionManager
-
createRDF4JProtocolSession
Description copied from interface:HttpClientSessionManagerCreates a new session to the remote RDF4J REST API.- Specified by:
createRDF4JProtocolSessionin interfaceHttpClientSessionManager
-
shutDown
public void shutDown()Description copied from interface:HttpClientSessionManagerCloses any remaining connections and threads used by the sessions created by this object.- Specified by:
shutDownin interfaceHttpClientSessionManager
-
initialize
Deprecated.Create a new instance instead of trying to reactivate an old instance.No-op -
getExecutorService
Get theExecutorServiceused by this session manager.- Returns:
- a
ExecutorServiceused by allSPARQLProtocolSessionandRDF4JProtocolSessioninstances created by this session manager.
-
getDefaultRequestConfig
public org.apache.http.client.config.RequestConfig getDefaultRequestConfig()Returns the defaultRequestConfigusing the currently set timeout values.- Returns:
- a configured
RequestConfigwith the current timeouts.
-
setDefaultSparqlServiceTimeouts
public void setDefaultSparqlServiceTimeouts()Switches the current timeout settings to use the SPARQL-specific timeouts. This method should be called when making SPARQL SERVICE calls to apply shorter timeout values.The SPARQL-specific timeouts are shorter to ensure that unresponsive or slow SPARQL endpoints do not cause long delays in federated query processing. Quick detection of such issues improves the responsiveness and reliability of SPARQL queries.
-
setDefaultTimeouts
public void setDefaultTimeouts()Resets the current timeout settings to the general timeouts. This method should be called to revert any changes made bysetDefaultSparqlServiceTimeouts()and apply the general timeout values.The general timeouts are longer to accommodate operations that may take more time, such as large data transfers or extensive processing, without causing premature timeouts.
-