- java.lang.Object
-
- io.rxmicro.config.Config
-
- io.rxmicro.http.HttpConfig
-
- io.rxmicro.rest.client.HttpClientConnectionPoolConfig
-
- Direct Known Subclasses:
RestClientConfig
public class HttpClientConnectionPoolConfig extends io.rxmicro.http.HttpConfigConfigures connection pool settings for http client.- Since:
- 0.8
- Author:
- nedis
-
-
Field Summary
Fields Modifier and Type Field Description static DurationDEFAULT_POOL_ACQUIRE_TIMEOUTDefault acquisition timeout (milliseconds) before error.static LeasingStrategyDEFAULT_POOL_LEASING_STRATEGYDefault leasing strategy.static intDEFAULT_POOL_MAX_CONNECTIONSDefault max connections.static DurationEVICT_IN_BACKGROUND_DISABLEDProviding anevictionIntervalofzeromeans the background eviction is disabled.
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpClientConnectionPoolConfig()This is basic class designed for extension only.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DurationgetEvictionInterval()Returns the options to use for configuring connection provider background eviction.LeasingStrategygetLeasingStrategy()Returns the configured leasing strategy.intgetMaxConnections()Returns the options to use for configuring connection provider maximum connections per connection pool.Optional<Duration>getMaxIdleTime()Returns the options to use for configuring connection provider max idle time (resolution: ms).Optional<Duration>getMaxLifeTime()Returns the options to use for configuring connection provider max life time (resolution: ms).OptionalIntgetPendingAcquireMaxCount()Returns the options to use for configuring connection provider the maximum number of registered requests for acquire to keep in a pending queue.DurationgetPendingAcquireTimeout()Returns the options to use for configuring connection provider acquire timeout (resolution: ms).HttpClientConnectionPoolConfigsetEvictionInterval(Duration evictionInterval)Set the options to use for configuring connection provider background eviction.HttpClientConnectionPoolConfigsetLeasingStrategy(LeasingStrategy leasingStrategy)Sets the custom leasing strategy.HttpClientConnectionPoolConfigsetMaxConnections(int maxConnections)Set the options to use for configuring connection provider maximum connections per connection pool.HttpClientConnectionPoolConfigsetMaxIdleTime(Duration maxIdleTime)Set the options to use for configuring connection provider max idle time (resolution: ms).HttpClientConnectionPoolConfigsetMaxLifeTime(Duration maxLifeTime)Set the options to use for configuring connection provider max life time (resolution: ms).HttpClientConnectionPoolConfigsetPendingAcquireMaxCount(int pendingAcquireMaxCount)Set the options to use for configuring connection provider the maximum number of registered requests for acquire to keep in a pending queue.HttpClientConnectionPoolConfigsetPendingAcquireTimeout(Duration pendingAcquireTimeout)Set the options to use for configuring connection provider acquire timeout (resolution: ms).StringtoString()-
Methods inherited from class io.rxmicro.http.HttpConfig
getConnectionString, getHost, getPort, getSchema, setConnectionString, setHost, setPort, setSchema
-
-
-
-
Field Detail
-
DEFAULT_POOL_MAX_CONNECTIONS
public static final int DEFAULT_POOL_MAX_CONNECTIONS
Default max connections. Fallback to available number of processors (but with a minimum value of 16)
-
DEFAULT_POOL_ACQUIRE_TIMEOUT
public static final Duration DEFAULT_POOL_ACQUIRE_TIMEOUT
Default acquisition timeout (milliseconds) before error. If -1 will never wait to acquire before opening a new connection in an unbounded fashion
-
EVICT_IN_BACKGROUND_DISABLED
public static final Duration EVICT_IN_BACKGROUND_DISABLED
Providing anevictionIntervalofzeromeans the background eviction is disabled.
-
DEFAULT_POOL_LEASING_STRATEGY
public static final LeasingStrategy DEFAULT_POOL_LEASING_STRATEGY
Default leasing strategy.
-
-
Method Detail
-
getEvictionInterval
public Duration getEvictionInterval()
Returns the options to use for configuring connection provider background eviction.- Returns:
- the options to use for configuring connection provider background eviction.
-
setEvictionInterval
public HttpClientConnectionPoolConfig setEvictionInterval(Duration evictionInterval)
Set the options to use for configuring connection provider background eviction. When a background eviction is enabled, the connection pool is regularly checked for connections, that are applicable for removal. Default toEVICT_IN_BACKGROUND_DISABLED- the background eviction is disabled. Providing anevictionIntervalofzeromeans the background eviction is disabled.- Parameters:
evictionInterval- specifies the interval to be used for checking the connection pool, (resolution: ns)- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
NullPointerException- if evictionInterval is null
-
getMaxConnections
public int getMaxConnections()
Returns the options to use for configuring connection provider maximum connections per connection pool.- Returns:
- the options to use for configuring connection provider maximum connections per connection pool.
-
setMaxConnections
public HttpClientConnectionPoolConfig setMaxConnections(int maxConnections)
Set the options to use for configuring connection provider maximum connections per connection pool. Default toDEFAULT_POOL_MAX_CONNECTIONS.- Parameters:
maxConnections- the maximum number of connections (per connection pool) before start pending- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
IllegalArgumentException- if maxConnections is negative
-
getPendingAcquireMaxCount
public OptionalInt getPendingAcquireMaxCount()
Returns the options to use for configuring connection provider the maximum number of registered requests for acquire to keep in a pending queue.- Returns:
- the options to use for configuring connection provider the maximum number of registered requests for acquire to keep in a pending queue.
-
setPendingAcquireMaxCount
public HttpClientConnectionPoolConfig setPendingAcquireMaxCount(int pendingAcquireMaxCount)
Set the options to use for configuring connection provider the maximum number of registered requests for acquire to keep in a pending queue. When invoked with -1 the pending queue will not have upper limit. Default to2 * max connections.- Parameters:
pendingAcquireMaxCount- the maximum number of registered requests for acquire to keep in a pending queue- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
IllegalArgumentException- if pendingAcquireMaxCount is negative
-
getPendingAcquireTimeout
public Duration getPendingAcquireTimeout()
Returns the options to use for configuring connection provider acquire timeout (resolution: ms).- Returns:
- the options to use for configuring connection provider acquire timeout (resolution: ms).
-
setPendingAcquireTimeout
public HttpClientConnectionPoolConfig setPendingAcquireTimeout(Duration pendingAcquireTimeout)
Set the options to use for configuring connection provider acquire timeout (resolution: ms). Default toDEFAULT_POOL_ACQUIRE_TIMEOUT.- Parameters:
pendingAcquireTimeout- the maximum time after which a pending acquire must complete or theTimeoutExceptionwill be thrown (resolution: ms)- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
NullPointerException- if pendingAcquireTimeout is null
-
getMaxIdleTime
public Optional<Duration> getMaxIdleTime()
Returns the options to use for configuring connection provider max idle time (resolution: ms).- Returns:
- the options to use for configuring connection provider max idle time (resolution: ms).
-
setMaxIdleTime
public HttpClientConnectionPoolConfig setMaxIdleTime(Duration maxIdleTime)
Set the options to use for configuring connection provider max idle time (resolution: ms).- Parameters:
maxIdleTime- theDurationafter which the channel will be closed when idle (resolution: ms)- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
NullPointerException- if maxIdleTime is null
-
getMaxLifeTime
public Optional<Duration> getMaxLifeTime()
Returns the options to use for configuring connection provider max life time (resolution: ms).- Returns:
- the options to use for configuring connection provider max life time (resolution: ms).
-
setMaxLifeTime
public HttpClientConnectionPoolConfig setMaxLifeTime(Duration maxLifeTime)
Set the options to use for configuring connection provider max life time (resolution: ms).- Parameters:
maxLifeTime- theDurationafter which the channel will be closed (resolution: ms)- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
NullPointerException- if maxLifeTime is null
-
getLeasingStrategy
public LeasingStrategy getLeasingStrategy()
Returns the configured leasing strategy.- Returns:
- the configured leasing strategy.
-
setLeasingStrategy
public HttpClientConnectionPoolConfig setLeasingStrategy(LeasingStrategy leasingStrategy)
Sets the custom leasing strategy.- Parameters:
leasingStrategy- the custom leasing strategy.- Returns:
- the reference to this
HttpClientConnectionPoolConfiginstance - Throws:
NullPointerException- if leasingStrategy is null
-
toString
public String toString()
- Overrides:
toStringin classio.rxmicro.http.HttpConfig
-
-