Class 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: SlowQueryReportJmxMBean plus the notification methods of NotificationEmitter, 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().

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNotificationListener​(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)  
      javax.management.MBeanNotificationInfo[] getNotificationInfo()  
      java.lang.String getPoolName()
      Returns the registration name of the connection pool this MBean reports for, as the PoolName attribute.
      java.lang.String[] getPoolNames()
      Returns the names of all the connection pools this JVM currently holds recorded query statistics for, as the PoolNames attribute.
      javax.management.openmbean.CompositeData[] getSlowQueriesCD()
      Returns slow query statistics as JMX CompositeData, as the SlowQueriesCD attribute.
      void removeNotificationListener​(javax.management.NotificationListener listener)  
      void removeNotificationListener​(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)  
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 for
        statistics - the statistics store of the pool the registration reports for
        state - the JMX state of that pool
    • Method Detail

      • getPoolName

        public java.lang.String getPoolName()
        Description copied from interface: SlowQueryReportJmxMBean
        Returns the registration name of the connection pool this MBean reports for, as the PoolName attribute. 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:
        getPoolName in interface SlowQueryReportJmxMBean
        Returns:
        the pool's recorded registration name, or null before this instance is bound to a pool
      • getPoolNames

        public java.lang.String[] getPoolNames()
        Description copied from interface: SlowQueryReportJmxMBean
        Returns the names of all the connection pools this JVM currently holds recorded query statistics for, as the PoolNames attribute. That is a JVM-wide view, not this pool alone: a pool using the plain SlowQueryReport interceptor, which never registers an MBean of its own, appears here as well, and pools configured with the same name appear once.
        Specified by:
        getPoolNames in interface SlowQueryReportJmxMBean
        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: SlowQueryReportJmxMBean
        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.
        Specified by:
        resetStats in interface SlowQueryReportJmxMBean
      • getSlowQueriesCD

        public javax.management.openmbean.CompositeData[] getSlowQueriesCD()
                                                                    throws javax.management.openmbean.OpenDataException
        Description copied from interface: SlowQueryReportJmxMBean
        Returns slow query statistics as JMX CompositeData, as the SlowQueriesCD attribute. The element schema is SlowQueryReport.QueryStats: every duration (maxInvocationTime, minInvocationTime, totalInvocationTime, prepareTime) is in milliseconds and every date field (maxInvocationDate, minInvocationDate, lastInvocation) is epoch milliseconds.
        Specified by:
        getSlowQueriesCD in interface SlowQueryReportJmxMBean
        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 an MBeanException
      • addNotificationListener

        public void addNotificationListener​(javax.management.NotificationListener listener,
                                            javax.management.NotificationFilter filter,
                                            java.lang.Object handback)
                                     throws java.lang.IllegalArgumentException
        Specified by:
        addNotificationListener in interface javax.management.NotificationBroadcaster
        Throws:
        java.lang.IllegalArgumentException
      • getNotificationInfo

        public javax.management.MBeanNotificationInfo[] getNotificationInfo()
        Specified by:
        getNotificationInfo in interface javax.management.NotificationBroadcaster
      • removeNotificationListener

        public void removeNotificationListener​(javax.management.NotificationListener listener)
                                        throws javax.management.ListenerNotFoundException
        Specified by:
        removeNotificationListener in interface javax.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:
        removeNotificationListener in interface javax.management.NotificationEmitter
        Throws:
        javax.management.ListenerNotFoundException