Interface InstrumentedPool.PoolMetrics
- All Known Implementing Classes:
SimpleDequePool
- Enclosing interface:
InstrumentedPool<POOLABLE>
Pool, suitable
for gauge metrics.
getXxx methods are configuration accessors, ie values that won't change over time, whereas other methods can be used as gauges to introspect the current state of the pool.
-
Method Summary
Modifier and TypeMethodDescriptionintMeasure the current number of resources that have been successfullyacquiredand are in active use, outside of the control of the pool until they're released back to it.intMeasure the current number of allocated resources in thePool, acquired or idle.intGet the maximum number of live resources thisPoolwill allow.intGet the maximum number ofPool.acquire()thisPoolcan queue in a pending state when no available resource is immediately handy (and thePoolcannot allocate more resources).intidleSize()Measure the current number of idle resources in thePool.default booleanisInactiveForMoreThan(Duration duration) A convenience way to check the pool is inactive, in the sense thatacquiredSize(),idleSize(),pendingAcquireSize()andallocatedSize()are all at zero and that the last recorded interaction with the pool (secondsSinceLastInteraction()) was more than or exactlydurationago.intMeasure the current number of "pending"acquire Monosin thePool.default longMeasure the duration in seconds since the pool was last interacted with in a meaningful way.
-
Method Details
-
acquiredSize
int acquiredSize()Measure the current number of resources that have been successfullyacquiredand are in active use, outside of the control of the pool until they're released back to it. This number is only incremented after the resource has been successfully allocated and is about to be handed off to the subscriber ofPool.acquire().- Returns:
- the number of acquired resources
-
allocatedSize
int allocatedSize()Measure the current number of allocated resources in thePool, acquired or idle.- Returns:
- the total number of allocated resources managed by the
Pool
-
idleSize
int idleSize()Measure the current number of idle resources in thePool.Note that some resources might be lazily evicted when they're next considered for an incoming
Pool.acquire()call. Such resources would still count towards this method.- Returns:
- the number of idle resources
-
pendingAcquireSize
int pendingAcquireSize()Measure the current number of "pending"acquire Monosin thePool.An acquire is in the pending state when it is attempted at a point when no idle resource is available in the pool, and no new resource can be created.
- Returns:
- the number of pending acquire
-
secondsSinceLastInteraction
default long secondsSinceLastInteraction()Measure the duration in seconds since the pool was last interacted with in a meaningful way. This is a best effort indicator of pool inactivity, provided the pool counters (acquiredSize(),idleSize(),pendingAcquireSize()andallocatedSize()) are also at zero.The lower the duration, the greater the chances that an interaction could be occurring in parallel to this call. This is why the duration is truncated to the second. A pool implementation that cannot yet support this measurement MAY choose to return -1 seconds instead.
Interactions include background eviction, disposal of the pool, explicit pool warmup, resource acquisition and release (in the default implementation, any interaction triggering the drain loop)...
- Returns:
- a number of seconds indicative of the time elapsed since last pool interaction
- See Also:
-
isInactiveForMoreThan
A convenience way to check the pool is inactive, in the sense thatacquiredSize(),idleSize(),pendingAcquireSize()andallocatedSize()are all at zero and that the last recorded interaction with the pool (secondsSinceLastInteraction()) was more than or exactlydurationago.- Returns:
- true if the pool can be considered inactive (see above), false otherwise
- See Also:
-
getMaxAllocatedSize
int getMaxAllocatedSize()Get the maximum number of live resources thisPoolwill allow.A
Poolmight be unbounded, in which case this method returnsInteger.MAX_VALUE.- Returns:
- the maximum number of live resources that can be allocated by this
Pool
-
getMaxPendingAcquireSize
int getMaxPendingAcquireSize()Get the maximum number ofPool.acquire()thisPoolcan queue in a pending state when no available resource is immediately handy (and thePoolcannot allocate more resources).A
Poolpending queue might be unbounded, in which case this method returnsInteger.MAX_VALUE.- Returns:
- the maximum number of pending acquire that can be enqueued by this
Pool
-