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);
-
@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 its 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:
Using the platform MBeanServer will make the pool visible to tools like JConsole and VisualVM.
- Since:
- 2.3
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getAllocationCount()
Return the number of objects the pool has allocated since it was created.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.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.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.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.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.double
getObjectLifetimePercentile(double percentile)
Get the approximate object lifetime, in milliseconds, for the given percentile/quantile.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.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.int
getTargetSize()
Get the current target size of the pool.boolean
isShutDown()
Returns 'true' if the shut down process has been started on this pool, 'false' otherwise.void
setTargetSize(int size)
Set a new target size of the pool.
-
-
-
Method Detail
-
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(int size)
Set a new target size of the pool.
- Parameters:
size
- The new target size.- See Also:
Pool.setTargetSize(int)
-
getTargetSize
int getTargetSize()
Get the current target size of the pool.
- Returns:
- The current target size.
- See Also:
Pool.getTargetSize()
-
isShutDown
boolean isShutDown()
Returns 'true' if the shut down process has been started on this pool, 'false' otherwise. This method does not reveal whether or not the shut down 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:
MetricsRecorder.getObjectLifetimePercentile(double)
-
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:
MetricsRecorder.getAllocationLatencyPercentile(double)
-
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:
MetricsRecorder.getAllocationFailureLatencyPercentile(double)
-
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:
MetricsRecorder.getReallocationLatencyPercentile(double)
-
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:
MetricsRecorder.getReallocationFailurePercentile(double)
-
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:
MetricsRecorder.getDeallocationLatencyPercentile(double)
-
-