public static class ConnectionProvider.ConnectionPoolSpec<SPEC extends ConnectionProvider.ConnectionPoolSpec<SPEC>> extends Object implements java.util.function.Supplier<SPEC>
Modifier and Type | Method and Description |
---|---|
SPEC |
evictInBackground(java.time.Duration evictionInterval)
Set the options to use for configuring
ConnectionProvider background eviction. |
SPEC |
fifo()
Configure the pool so that if there are idle connections (i.e.
|
SPEC |
get() |
SPEC |
lifo()
Configure the pool so that if there are idle connections (i.e.
|
SPEC |
maxConnections(int maxConnections)
Set the options to use for configuring
ConnectionProvider maximum connections per connection pool. |
SPEC |
maxIdleTime(java.time.Duration maxIdleTime)
Set the options to use for configuring
ConnectionProvider max idle time (resolution: ms). |
SPEC |
maxLifeTime(java.time.Duration maxLifeTime)
Set the options to use for configuring
ConnectionProvider max life time (resolution: ms). |
SPEC |
metrics(boolean metricsEnabled)
Whether to enable metrics to be collected and registered in Micrometer's
globalRegistry
under the name Metrics.CONNECTION_PROVIDER_PREFIX . |
SPEC |
metrics(boolean metricsEnabled,
java.util.function.Supplier<? extends ConnectionProvider.MeterRegistrar> registrar)
Specifies whether the metrics are enabled on the
ConnectionProvider . |
SPEC |
pendingAcquireMaxCount(int pendingAcquireMaxCount)
Set the options to use for configuring
ConnectionProvider 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. |
SPEC |
pendingAcquireTimeout(java.time.Duration pendingAcquireTimeout)
Set the options to use for configuring
ConnectionProvider acquire timeout (resolution: ms). |
public final SPEC pendingAcquireTimeout(java.time.Duration pendingAcquireTimeout)
ConnectionProvider
acquire timeout (resolution: ms).
Default to ConnectionProvider.DEFAULT_POOL_ACQUIRE_TIMEOUT
.pendingAcquireTimeout
- the maximum time after which a pending acquire
must complete or the TimeoutException
will be thrown (resolution: ms)NullPointerException
- if pendingAcquireTimeout is nullpublic final SPEC maxConnections(int maxConnections)
ConnectionProvider
maximum connections per connection pool.
Default to ConnectionProvider.DEFAULT_POOL_MAX_CONNECTIONS
.maxConnections
- the maximum number of connections (per connection pool) before start pendingIllegalArgumentException
- if maxConnections is negativepublic final SPEC pendingAcquireMaxCount(int pendingAcquireMaxCount)
ConnectionProvider
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 to 2 * max connections
.pendingAcquireMaxCount
- the maximum number of registered requests for acquire to keep
in a pending queueIllegalArgumentException
- if pendingAcquireMaxCount is negativepublic final SPEC maxIdleTime(java.time.Duration maxIdleTime)
ConnectionProvider
max idle time (resolution: ms).
Default to ConnectionProvider.DEFAULT_POOL_MAX_IDLE_TIME
if specified otherwise - no max idle time.maxIdleTime
- the Duration
after which the channel will be closed when idle (resolution: ms)NullPointerException
- if maxIdleTime is nullpublic final SPEC maxLifeTime(java.time.Duration maxLifeTime)
ConnectionProvider
max life time (resolution: ms).
Default to ConnectionProvider.DEFAULT_POOL_MAX_LIFE_TIME
if specified otherwise - no max life time.maxLifeTime
- the Duration
after which the channel will be closed (resolution: ms)NullPointerException
- if maxLifeTime is nullpublic final SPEC metrics(boolean metricsEnabled)
globalRegistry
under the name Metrics.CONNECTION_PROVIDER_PREFIX
.
Applications can separately register their own
filters
associated with this name.
For example, to put an upper bound on the number of tags produced:
MeterFilter filter = ... ; Metrics.globalRegistry.config().meterFilter(MeterFilter.maximumAllowableTags(CONNECTION_PROVIDER_PREFIX, 100, filter));
By default this is not enabled.
metricsEnabled
- true enables metrics collection; false disables itpublic final SPEC metrics(boolean metricsEnabled, java.util.function.Supplier<? extends ConnectionProvider.MeterRegistrar> registrar)
ConnectionProvider
.
All generated metrics are provided to the specified registrar
which is only instantiated if metrics are being enabled.metricsEnabled
- true enables metrics collection; false disables itregistrar
- a supplier for the ConnectionProvider.MeterRegistrar
public final SPEC lifo()
public final SPEC fifo()
public final SPEC evictInBackground(java.time.Duration evictionInterval)
ConnectionProvider
background eviction.
When a background eviction is enabled, the connection pool is regularly checked for connections,
that are applicable for removal.
Default to EVICT_IN_BACKGROUND_DISABLED
- the background eviction is disabled.
Providing an evictionInterval
of zero
means the background eviction is disabled.evictionInterval
- specifies the interval to be used for checking the connection pool, (resolution: ns)public SPEC get()
get
in interface java.util.function.Supplier<SPEC extends ConnectionProvider.ConnectionPoolSpec<SPEC>>