Class ConnectionConfig.Builder
java.lang.Object
org.apache.hc.client5.http.config.ConnectionConfig.Builder
- Enclosing class:
ConnectionConfig
Builder for
ConnectionConfig.- Since:
- 5.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hc.core5.util.Timeoutprivate org.apache.hc.core5.util.Timeoutprivate org.apache.hc.core5.util.Timeoutprivate org.apache.hc.core5.util.TimeValueprivate org.apache.hc.core5.util.TimeValue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newConnectionConfiginstance based on the values provided to the setters methods.setConnectTimeout(long connectTimeout, TimeUnit timeUnit) Sets the timeout until a new connection is fully established.setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout) Sets the timeout until a new connection is fully established.setIdleTimeout(long idleTimeout, TimeUnit timeUnit) Sets the maximum period of idleness for a connection.setIdleTimeout(org.apache.hc.core5.util.Timeout idleTimeout) Determines the maximum period of idleness for a connection.setSocketTimeout(int soTimeout, TimeUnit timeUnit) Sets the default socket timeout value for I/O operations on connections created by this configuration.setSocketTimeout(org.apache.hc.core5.util.Timeout soTimeout) Sets the default socket timeout value for I/O operations on connections created by this configuration.setTimeToLive(long timeToLive, TimeUnit timeUnit) Sets the total span of time connections can be kept alive or execute requests.setTimeToLive(org.apache.hc.core5.util.TimeValue timeToLive) Defines the total span of time connections can be kept alive or execute requests.setValidateAfterInactivity(long validateAfterInactivity, TimeUnit timeUnit) Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer.setValidateAfterInactivity(org.apache.hc.core5.util.TimeValue validateAfterInactivity) Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer.
-
Field Details
-
socketTimeout
private org.apache.hc.core5.util.Timeout socketTimeout -
connectTimeout
private org.apache.hc.core5.util.Timeout connectTimeout -
idleTimeout
private org.apache.hc.core5.util.Timeout idleTimeout -
validateAfterInactivity
private org.apache.hc.core5.util.TimeValue validateAfterInactivity -
timeToLive
private org.apache.hc.core5.util.TimeValue timeToLive
-
-
Constructor Details
-
Builder
Builder()
-
-
Method Details
-
setSocketTimeout
Sets the default socket timeout value for I/O operations on connections created by this configuration.- Parameters:
soTimeout- The default socket timeout value for I/O operations.timeUnit- The time unit of the soTimeout parameter.- Returns:
- this instance.
- See Also:
-
setSocketTimeout
Sets the default socket timeout value for I/O operations on connections created by this configuration. A timeout value of zero is interpreted as an infinite timeout.This value acts as a baseline at the connection management layer. This parameter overrides the socket timeout setting applied at the I/O layer and in its tuen can overridden by settings applied at the protocol layer for the duration of a message exchange.
Default:
null(undefined)- Parameters:
soTimeout- The default socket timeout value for I/O operations.- Returns:
- this instance.
-
setConnectTimeout
Sets the timeout until a new connection is fully established.A timeout value of zero is interpreted as an infinite timeout.
Default: 3 minutes
- Parameters:
connectTimeout- The timeout until a new connection is fully established.- Returns:
- this instance.
-
setConnectTimeout
Sets the timeout until a new connection is fully established.- Parameters:
connectTimeout- The timeout until a new connection is fully established.timeUnit- The time unit of the timeout parameter.- Returns:
- this instance.
- See Also:
-
setIdleTimeout
Determines the maximum period of idleness for a connection. Connections that are idle for longer thanidleTimeoutare no longer eligible for reuse.A timeout value of zero is interpreted as an infinite timeout.
Default:
null(undefined)- Parameters:
idleTimeout- The maximum period of idleness for a connection.- Returns:
- this instance.
- Since:
- 5.6
-
setIdleTimeout
Sets the maximum period of idleness for a connection.Connections that are idle for longer than
idleTimeoutare no longer eligible for reuse.- Parameters:
idleTimeout- The maximum period of idleness for a connection.timeUnit-- Returns:
- this instance.
- See Also:
-
setValidateAfterInactivity
public ConnectionConfig.Builder setValidateAfterInactivity(org.apache.hc.core5.util.TimeValue validateAfterInactivity) Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer. Negative values passed to this method disable connection validation.Default:
null(undefined)- Parameters:
validateAfterInactivity- The period of inactivity after which persistent connections must be re-validated.- Returns:
- this instance.
-
setValidateAfterInactivity
public ConnectionConfig.Builder setValidateAfterInactivity(long validateAfterInactivity, TimeUnit timeUnit) Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer.- Parameters:
validateAfterInactivity- The period of inactivity after which persistent connections must be re-validated.timeUnit- The time unit of the validateAfterInactivity parameter.- Returns:
- this instance.
- See Also:
-
setTimeToLive
Defines the total span of time connections can be kept alive or execute requests.Default:
null(undefined)- Parameters:
timeToLive- The total span of time connections can be kept alive or execute requests.- Returns:
- this instance.
-
setTimeToLive
Sets the total span of time connections can be kept alive or execute requests.- Parameters:
timeToLive- The total span of time connections can be kept alive or execute requests.timeUnit- The time unit of the timeToLive parameter.- Returns:
- this instance.
- See Also:
-
build
Builds a newConnectionConfiginstance based on the values provided to the setters methods.- Returns:
- a new
ConnectionConfiginstance.
-