Interface SlowQueryReportJmxMBean
- All Known Subinterfaces:
SlowQueryReportJmx.RegistrationMBean
- All Known Implementing Classes:
SlowQueryReportJmx, SlowQueryReportJmx.Registration
The resource published for a pool name is SlowQueryReportJmx.Registration, exposed as a Standard
MBean, so this interface is the whole management surface: a public method of the resource that is not declared here
stays invisible to a JMX client - only the notification methods contributed by
NotificationEmitter come on top. Everything an operator needs, and everything the
interceptor's mbeans-descriptors.xml advertises, therefore has to be declared here.
Each pool publishes its own MBean, under
tomcat.jdbc:type=org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx,name=<pool> unless the
objectName interceptor property overrides it, and only when the interceptor is configured with
notifyPool=false. With the default notifyPool=true no MBean is registered and the statistics are only
observable through the connection pool's own MBean. A second live pool trying to publish under a name that is already
occupied is refused by the MBean server; sharing one name between live pools is not supported.
notifyPool itself is deliberately not part of this interface. It is a per-interceptor-instance configuration
property - the pool builds one interceptor chain per pooled connection and configures every instance with it - and
every instance decides the routing of its own notifications from its own copy when it reports a query. Writing it
through JMX would change only the single instance that happens to own the registration and leave the pool's other
connections routing as before, so the attribute would promise a pool-wide effect it could not deliver. It stays a
configuration entry point, applied to every instance of the pool by
SlowQueryReportJmx.setProperties(java.util.Map).
-
Method Summary
Modifier and TypeMethodDescriptionReturns the registration name of the connection pool this MBean reports for, as thePoolNameattribute.String[]Returns the names of all the connection pools this JVM currently holds recorded query statistics for, as thePoolNamesattribute.Returns slow query statistics as JMX CompositeData, as theSlowQueriesCDattribute.voidRemoves 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.
-
Method Details
-
getPoolName
String getPoolName()Returns 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.- Returns:
- the pool's recorded registration name, or
nullbefore this instance is bound to a pool
-
getPoolNames
String[] getPoolNames()Returns 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.- Returns:
- the names of the pools that currently hold a statistics map; an empty array when no pool has registered statistics
-
resetStats
void resetStats()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. 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. -
getSlowQueriesCD
Returns 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.- Returns:
- array of composite data representing slow query statistics
- Throws:
OpenDataException- if the composite data cannot be created; a JMX client gets it wrapped in anMBeanException
-