Class SlowQueryReportJmx.Registration
- java.lang.Object
-
- org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx.Registration
-
- All Implemented Interfaces:
javax.management.NotificationBroadcaster,javax.management.NotificationEmitter,SlowQueryReportJmx.RegistrationMBean,SlowQueryReportJmxMBean
- Enclosing class:
- SlowQueryReportJmx
public static class SlowQueryReportJmx.Registration extends java.lang.Object implements javax.management.NotificationEmitter, SlowQueryReportJmx.RegistrationMBean
The resource published with the MBeanServer for one pool.It holds the name, the statistics store of the pool it reports for, and that pool's JMX state, and nothing else: every attribute and operation it serves reads the store and the pool's broadcaster exactly as an interceptor instance of the pool would. Keeping the pool out of the resource is the point: the MBeanServer outlives a pool that was abandoned without closing, and a resource that reached the pool would pin it, its sessions and its classloader for the life of the JVM, since a registration is only ever taken down by a close the abandoned pool never runs. The published surface is unchanged by this indirection:
SlowQueryReportJmxMBeanplus the notification methods ofNotificationEmitter, with listeners landing on the pool's shared broadcaster.The ObjectName is deliberately not among what it holds: the name a publication occupies is recorded by the pool's
SlowQueryReportJmx.PoolJmx, which is also what gives it up, so the resource cannot be the one to give up a name other than the one it was published under - and does not need to know any.The class is public because the Standard-MBean introspection publishes the resource through its interfaces; instances are created only by
SlowQueryReportJmx.registerJmx().
-
-
Constructor Summary
Constructors Constructor Description Registration(java.lang.String poolName, SlowQueryReport.PoolStatistics statistics, SlowQueryReportJmx.PoolJmx state)Creates the registration of one pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)javax.management.MBeanNotificationInfo[]getNotificationInfo()java.lang.StringgetPoolName()Returns the registration name of the connection pool this MBean reports for, as thePoolNameattribute.java.lang.String[]getPoolNames()Returns the names of all the connection pools this JVM currently holds recorded query statistics for, as thePoolNamesattribute.javax.management.openmbean.CompositeData[]getSlowQueriesCD()Returns slow query statistics as JMX CompositeData, as theSlowQueriesCDattribute.voidremoveNotificationListener(javax.management.NotificationListener listener)voidremoveNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)voidresetStats()Removes all query statistics recorded for the pool this MBean reports for, so an operator can start from a clean slate instead of restarting the pool.
-
-
-
Constructor Detail
-
Registration
public Registration(java.lang.String poolName, SlowQueryReport.PoolStatistics statistics, SlowQueryReportJmx.PoolJmx state)Creates the registration of one pool.- Parameters:
poolName- the pool name to report forstatistics- the statistics store of the pool the registration reports forstate- the JMX state of that pool
-
-
Method Detail
-
getPoolName
public java.lang.String getPoolName()
Description copied from interface:SlowQueryReportJmxMBeanReturns the registration name of the connection pool this MBean reports for, as thePoolNameattribute. The registration, the notifications and the statistics belong to that one pool; a second live pool configured with the same name does not share this MBean, and its registration is refused while this one holds the name.The value is recorded when the pool starts. It is not cleared when the pool's chain is released, so it can remain non-null after the MBean has been given up; only an instance that was never bound to a pool answers
null.- Specified by:
getPoolNamein interfaceSlowQueryReportJmxMBean- Returns:
- the pool's recorded registration name, or
nullbefore this instance is bound to a pool
-
getPoolNames
public java.lang.String[] getPoolNames()
Description copied from interface:SlowQueryReportJmxMBeanReturns the names of all the connection pools this JVM currently holds recorded query statistics for, as thePoolNamesattribute. That is a JVM-wide view, not this pool alone: a pool using the plainSlowQueryReportinterceptor, which never registers an MBean of its own, appears here as well, and pools configured with the same name appear once.- Specified by:
getPoolNamesin interfaceSlowQueryReportJmxMBean- Returns:
- the names of the pools that currently hold a statistics map; an empty array when no pool has registered statistics
-
resetStats
public void resetStats()
Description copied from interface:SlowQueryReportJmxMBeanRemoves all query statistics recorded for the pool this MBean reports for, so an operator can start from a clean slate instead of restarting the pool. Only that pool's store is cleared; another live pool's statistics are untouched, even if it shares the name (a configuration the pool does not support for JMX publication). Only the recorded content is dropped: the pool stays monitored and keeps accumulating statistics afterwards, and a query recorded again starts from empty counters.- Specified by:
resetStatsin interfaceSlowQueryReportJmxMBean
-
getSlowQueriesCD
public javax.management.openmbean.CompositeData[] getSlowQueriesCD() throws javax.management.openmbean.OpenDataExceptionDescription copied from interface:SlowQueryReportJmxMBeanReturns slow query statistics as JMX CompositeData, as theSlowQueriesCDattribute. The element schema isSlowQueryReport.QueryStats: every duration (maxInvocationTime,minInvocationTime,totalInvocationTime,prepareTime) is in milliseconds and every date field (maxInvocationDate,minInvocationDate,lastInvocation) is epoch milliseconds.- Specified by:
getSlowQueriesCDin interfaceSlowQueryReportJmxMBean- Returns:
- array of composite data representing slow query statistics
- Throws:
javax.management.openmbean.OpenDataException- if the composite data cannot be created; a JMX client gets it wrapped in anMBeanException
-
addNotificationListener
public void addNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback) throws java.lang.IllegalArgumentException- Specified by:
addNotificationListenerin interfacejavax.management.NotificationBroadcaster- Throws:
java.lang.IllegalArgumentException
-
getNotificationInfo
public javax.management.MBeanNotificationInfo[] getNotificationInfo()
- Specified by:
getNotificationInfoin interfacejavax.management.NotificationBroadcaster
-
removeNotificationListener
public void removeNotificationListener(javax.management.NotificationListener listener) throws javax.management.ListenerNotFoundException- Specified by:
removeNotificationListenerin interfacejavax.management.NotificationBroadcaster- Throws:
javax.management.ListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback) throws javax.management.ListenerNotFoundException- Specified by:
removeNotificationListenerin interfacejavax.management.NotificationEmitter- Throws:
javax.management.ListenerNotFoundException
-
-