Interface SlowQueryReportJmxMBean
- All Known Implementing Classes:
SlowQueryReportJmx
SlowQueryReportJmx is published 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.
The MBean is published once per connection pool name - 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.
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 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 name of the connection pool this MBean reports for, as thePoolNameattribute. The registration, the notifications and the statistics are all keyed by pool name, so every live pool configured with the same name shares the one MBean reporting that name.- Returns:
- the name of the pool, unique within the JVM;
nullwhen this interceptor instance is not bound to a pool yet - an instance registered with the MBeanServer always is
-
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. Statistics are keyed by pool name, so this clears the map shared by every live pool configured with that name. 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
-