Class ConnectionConfig.Builder
- java.lang.Object
-
- org.apache.hc.client5.http.config.ConnectionConfig.Builder
-
- Enclosing class:
- ConnectionConfig
public static class ConnectionConfig.Builder extends java.lang.ObjectBuilder forConnectionConfig.
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.hc.core5.util.TimeoutconnectTimeoutprivate org.apache.hc.core5.util.TimeoutidleTimeoutprivate org.apache.hc.core5.util.TimeoutsocketTimeoutprivate org.apache.hc.core5.util.TimeValuetimeToLiveprivate org.apache.hc.core5.util.TimeValuevalidateAfterInactivity
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectionConfigbuild()Builds a newConnectionConfiginstance based on the values provided to the setters methods.ConnectionConfig.BuildersetConnectTimeout(long connectTimeout, java.util.concurrent.TimeUnit timeUnit)Sets the timeout until a new connection is fully established.ConnectionConfig.BuildersetConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)Sets the timeout until a new connection is fully established.ConnectionConfig.BuildersetIdleTimeout(long idleTimeout, java.util.concurrent.TimeUnit timeUnit)Sets the maximum period of idleness for a connection.ConnectionConfig.BuildersetIdleTimeout(org.apache.hc.core5.util.Timeout idleTimeout)Determines the maximum period of idleness for a connection.ConnectionConfig.BuildersetSocketTimeout(int soTimeout, java.util.concurrent.TimeUnit timeUnit)Sets the default socket timeout value for I/O operations on connections created by this configuration.ConnectionConfig.BuildersetSocketTimeout(org.apache.hc.core5.util.Timeout soTimeout)Sets the default socket timeout value for I/O operations on connections created by this configuration.ConnectionConfig.BuildersetTimeToLive(long timeToLive, java.util.concurrent.TimeUnit timeUnit)Sets the total span of time connections can be kept alive or execute requests.ConnectionConfig.BuildersetTimeToLive(org.apache.hc.core5.util.TimeValue timeToLive)Defines the total span of time connections can be kept alive or execute requests.ConnectionConfig.BuildersetValidateAfterInactivity(long validateAfterInactivity, java.util.concurrent.TimeUnit timeUnit)Sets the period of inactivity after which persistent connections must be re-validated prior to being leased to the consumer.ConnectionConfig.BuildersetValidateAfterInactivity(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 Detail
-
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
-
-
Method Detail
-
setSocketTimeout
public ConnectionConfig.Builder setSocketTimeout(int soTimeout, java.util.concurrent.TimeUnit timeUnit)
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(Timeout)
-
setSocketTimeout
public ConnectionConfig.Builder setSocketTimeout(org.apache.hc.core5.util.Timeout soTimeout)
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
public ConnectionConfig.Builder setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)
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
public ConnectionConfig.Builder setConnectTimeout(long connectTimeout, java.util.concurrent.TimeUnit timeUnit)
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:
setConnectTimeout(Timeout)
-
setIdleTimeout
public ConnectionConfig.Builder setIdleTimeout(org.apache.hc.core5.util.Timeout idleTimeout)
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
public ConnectionConfig.Builder setIdleTimeout(long idleTimeout, java.util.concurrent.TimeUnit timeUnit)
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:
setIdleTimeout(Timeout)
-
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, java.util.concurrent.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:
setValidateAfterInactivity(TimeValue)
-
setTimeToLive
public ConnectionConfig.Builder setTimeToLive(org.apache.hc.core5.util.TimeValue timeToLive)
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
public ConnectionConfig.Builder setTimeToLive(long timeToLive, java.util.concurrent.TimeUnit timeUnit)
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:
setTimeToLive(TimeValue)
-
build
public ConnectionConfig build()
Builds a newConnectionConfiginstance based on the values provided to the setters methods.- Returns:
- a new
ConnectionConfiginstance.
-
-