Module stormpot
Package stormpot

Interface ManagedPool

All Known Implementing Classes:
BlazePool

@MXBean public interface ManagedPool
This is the JMX management interface for Stormpot object pools.

Using this interface, pools can be exposed to external management as an MXBean. Since it is an MXBean, and not just an MBean, it imposes no special requirements on 3rd party JMX integrators.

Once you have created your pool, it is easy to expose it through the platform MBeanServer, or any MBeanServer you like:

Pool<MyPoolable> pool = Pool.from(new MyAllocator()).build();
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("com.myapp:objectpool=stormpot");
server.registerMBean(pool.getManagedPool(), name);
Using the platform MBeanServer will make the pool visible to tools like JConsole and VisualVM.
Since:
2.3
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Return the number of objects the pool has allocated since it was created.
    double
    Get the approximate latency value, in milliseconds, for failed allocation latencies within the given percentile/quantile of what has been recorded so far.
    double
    getAllocationLatencyPercentile(double percentile)
    Get the approximate Poolable object allocation latency value, in milliseconds, of the given percentile/quantile of the values recorded so far.
    default long
    Get the approximate number of currently allocated objects.
    default long
    Get the approximate number of objects currently in use.
    double
    Get the approximate latency value, in milliseconds, for deallocation latencies within the given percentile/quantile of what has been recorded so far.
    long
    Return the number of allocations that has failed, either because the allocator threw an exception or because it returned null, since the pool was created.
    long
    If the pool is capable of precise object leak detection, this method will return the number of object leaks that have been detected, and prevented, since the pool was created.
    double
    getObjectLifetimePercentile(double percentile)
    Get the approximate object lifetime, in milliseconds, for the given percentile/quantile.
    double
    Get the approximate latency value, in milliseconds, for failed reallocation latencies within the given percentile/quantile of what has been recorded so far.
    double
    Get the approximate latency value, in milliseconds, for reallocation latencies within the given percentile/quantile of what has been recorded so far.
    long
    Get the current target size of the pool.
    boolean
    Returns true if the shutdown process has been started on this pool, false otherwise.
    void
    setTargetSize(long size)
    Set a new target size of the pool.
  • Method Details

    • getAllocationCount

      long getAllocationCount()
      Return the number of objects the pool has allocated since it was created.
      Returns:
      The number of Poolable objects ever created by this pool.
    • getFailedAllocationCount

      long getFailedAllocationCount()
      Return the number of allocations that has failed, either because the allocator threw an exception or because it returned null, since the pool was created.
      Returns:
      The number of allocations that have failed for one reason or another.
    • getLeakedObjectsCount

      long getLeakedObjectsCount()
      If the pool is capable of precise object leak detection, this method will return the number of object leaks that have been detected, and prevented, since the pool was created. If the pool does not support precise object leak detection, then this method returns -1.

      There are two kinds of leaks: One where the application forgets to release an object back to the pool, but keeps a strong reference to the object, and another where the application not only forgets to release the object, but also looses the reference to the object, making it eligible for garbage collection. The precise leak detector will only count leaks of the latter kind, where the leaked object has been garbage collected.

      Returns:
      The number of objects leaked from the users of this pool, since the pool was created, or -1 if the pool does not implement precise leak detection.
    • setTargetSize

      void setTargetSize(long size)
      Set a new target size of the pool.
      Parameters:
      size - The new target size.
      See Also:
    • getTargetSize

      long getTargetSize()
      Get the current target size of the pool.
      Returns:
      The current target size.
      See Also:
    • isShutDown

      boolean isShutDown()
      Returns true if the shutdown process has been started on this pool, false otherwise. This method does not reveal whether the shutdown process has completed.
      Returns:
      true if Pool.shutdown() has been called on this pool.
    • getObjectLifetimePercentile

      double getObjectLifetimePercentile(double percentile)
      Get the approximate object lifetime, in milliseconds, for the given percentile/quantile.
      Parameters:
      percentile - The percentile to get, as a decimal, e.g. a number between 0.0 and 1.0.
      Returns:
      The approximate object lifetime in milliseconds, for the given percentile, or Double.NaN if no MetricsRecorder has been configured for the pool.
      See Also:
    • getAllocationLatencyPercentile

      double getAllocationLatencyPercentile(double percentile)
      Get the approximate Poolable object allocation latency value, in milliseconds, of the given percentile/quantile of the values recorded so far.
      Parameters:
      percentile - The percentile to get, as a decimal, e.g. a number between 0.0 and 1.0.
      Returns:
      The approximate latency for allocations in milliseconds, for the given percentile, or Double.NaN if no MetricsRecorder has been configured for the pool.
      See Also:
    • getAllocationFailureLatencyPercentile

      double getAllocationFailureLatencyPercentile(double percentile)
      Get the approximate latency value, in milliseconds, for failed allocation latencies within the given percentile/quantile of what has been recorded so far.
      Parameters:
      percentile - The percentile to get, as a decimal, e.g. a number between 0.0 and 1.0.
      Returns:
      The approximate latency for failed allocations in milliseconds, for the given percentile, or Double.NaN if no MetricsRecorder has been configured for the pool.
      See Also:
    • getReallocationLatencyPercentile

      double getReallocationLatencyPercentile(double percentile)
      Get the approximate latency value, in milliseconds, for reallocation latencies within the given percentile/quantile of what has been recorded so far.
      Parameters:
      percentile - The percentile to get, as a decimal, e.g. a number between 0.0 and 1.0.
      Returns:
      The approximate latency for reallocations in milliseconds, for the given percentile, or Double.NaN if no MetricsRecorder has been configured for the pool.
      See Also:
    • getReallocationFailureLatencyPercentile

      double getReallocationFailureLatencyPercentile(double percentile)
      Get the approximate latency value, in milliseconds, for failed reallocation latencies within the given percentile/quantile of what has been recorded so far.
      Parameters:
      percentile - The percentile to get, as a decimal, e.g. a number between 0.0 and 1.0.
      Returns:
      The approximate latency for failed reallocations in milliseconds, for the given percentile, or Double.NaN if no MetricsRecorder has been configured for the pool.
      See Also:
    • getDeallocationLatencyPercentile

      double getDeallocationLatencyPercentile(double percentile)
      Get the approximate latency value, in milliseconds, for deallocation latencies within the given percentile/quantile of what has been recorded so far.
      Parameters:
      percentile - The percentile to get, as a decimal, e.g. a number between 0.0 and 1.0.
      Returns:
      The approximate latency for deallocations, regardless of whether the throw exceptions or not, in milliseconds for the given percentile, or Double.NaN if no MetricsRecorder has been configured for the pool.
      See Also:
    • getCurrentAllocatedCount

      default long getCurrentAllocatedCount()
      Get the approximate number of currently allocated objects.

      This operation has time complexity O(poolSize) to count the number of slots.

      The default implementation of this interface methods returns -1.

      Unlike getAllocationCount(), this returns only the number of objects currently in the pool, which typically would be the same as getTargetSize().

      Returns:
      The current approximate number of allocated objects.
    • getCurrentInUseCount

      default long getCurrentInUseCount()
      Get the approximate number of objects currently in use.

      This operation has time complexity O(poolSize) to check each slot.

      The counting operation is "weakly consistent", in a similar sense to ConcurrentLinkedQueue.iterator().

      The default implementation of this interface methods returns -1.

      Returns:
      number of objects currently in use