Package reactor.pool

Interface InstrumentedPool.PoolMetrics

All Known Implementing Classes:
SimpleDequePool
Enclosing interface:
InstrumentedPool<POOLABLE>

public static interface InstrumentedPool.PoolMetrics
An object that can be used to get live information about a 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 Details

    • acquiredSize

      int acquiredSize()
      Measure the current number of resources that have been successfully acquired and 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 of Pool.acquire().
      Returns:
      the number of acquired resources
    • allocatedSize

      int allocatedSize()
      Measure the current number of allocated resources in the Pool, 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 the Pool.

      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 Monos in the Pool.

      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() and allocatedSize()) 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

      default boolean isInactiveForMoreThan(Duration duration)
      A convenience way to check the pool is inactive, in the sense that acquiredSize(), idleSize(), pendingAcquireSize() and allocatedSize() are all at zero and that the last recorded interaction with the pool (secondsSinceLastInteraction()) was more than or exactly duration ago.
      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 this Pool will allow.

      A Pool might be unbounded, in which case this method returns Integer.MAX_VALUE.

      Returns:
      the maximum number of live resources that can be allocated by this Pool
    • getMaxPendingAcquireSize

      int getMaxPendingAcquireSize()
      Get the maximum number of Pool.acquire() this Pool can queue in a pending state when no available resource is immediately handy (and the Pool cannot allocate more resources).

      A Pool pending queue might be unbounded, in which case this method returns Integer.MAX_VALUE.

      Returns:
      the maximum number of pending acquire that can be enqueued by this Pool