Class SlowQueryReportJmx

  • All Implemented Interfaces:
    java.lang.reflect.InvocationHandler, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, SlowQueryReportJmxMBean

    public class SlowQueryReportJmx
    extends SlowQueryReport
    implements javax.management.NotificationEmitter, SlowQueryReportJmxMBean
    Publishes data to JMX and provides notifications when failures happen.
    • Field Detail

      • SLOW_QUERY_NOTIFICATION

        public static final java.lang.String SLOW_QUERY_NOTIFICATION
        See Also:
        Constant Field Values
      • FAILED_QUERY_NOTIFICATION

        public static final java.lang.String FAILED_QUERY_NOTIFICATION
        See Also:
        Constant Field Values
      • objectNameAttribute

        public static final java.lang.String objectNameAttribute
        See Also:
        Constant Field Values
      • SLOW_QUERY_TYPE

        protected static volatile javax.management.openmbean.CompositeType SLOW_QUERY_TYPE
      • mbeans

        protected static final java.util.concurrent.ConcurrentHashMap<java.lang.String,​SlowQueryReportJmxMBean> mbeans
      • notifier

        protected volatile javax.management.NotificationBroadcasterSupport notifier
      • poolName

        protected java.lang.String poolName
      • notifySequence

        protected static final java.util.concurrent.atomic.AtomicLong notifySequence
      • notifyPool

        protected boolean notifyPool
    • Constructor Detail

      • SlowQueryReportJmx

        public SlowQueryReportJmx()
    • Method Detail

      • 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
      • getCompositeType

        protected static javax.management.openmbean.CompositeType getCompositeType()
      • poolClosed

        public void poolClosed​(ConnectionPool pool)
        Description copied from class: SlowQueryReport
        This method is invoked by a connection pool when the pool is closed. Interceptor classes can override this method if they keep static variables or other tracking means around. This method is only invoked on a single instance of the interceptor, and not on every instance created.
        Overrides:
        poolClosed in class SlowQueryReport
        Parameters:
        pool - - the pool that is being closed.
      • poolStarted

        public void poolStarted​(ConnectionPool pool)
        Description copied from class: SlowQueryReport
        This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested. Interceptor classes can override this method if they keep static variables or other tracking means around. This method is only invoked on a single instance of the interceptor, and not on every instance created.
        Overrides:
        poolStarted in class SlowQueryReport
        Parameters:
        pool - - the pool that is being closed.
      • reportFailedQuery

        protected java.lang.String reportFailedQuery​(java.lang.String query,
                                                     java.lang.Object[] args,
                                                     java.lang.String name,
                                                     long start,
                                                     java.lang.Throwable t)
        Description copied from class: AbstractQueryReport
        Invoked when a query execution, a call to execute/executeQuery or executeBatch failed.
        Overrides:
        reportFailedQuery in class SlowQueryReport
        Parameters:
        query - the query that was executed and failed
        args - the arguments to the execution
        name - the name of the method used to execute AbstractCreateStatementInterceptor.isExecute(Method, boolean)
        start - the time the query execution started
        t - the exception that happened
        Returns:
        - the SQL that was executed or the string "batch" if it was a batch execution
      • notifyJmx

        protected void notifyJmx​(java.lang.String query,
                                 java.lang.String type)
      • reportSlowQuery

        protected java.lang.String reportSlowQuery​(java.lang.String query,
                                                   java.lang.Object[] args,
                                                   java.lang.String name,
                                                   long start,
                                                   long delta)
        Description copied from class: AbstractQueryReport
        Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was exceeded the timing threshold
        Overrides:
        reportSlowQuery in class SlowQueryReport
        Parameters:
        query - the query that was executed and failed
        args - the arguments to the execution
        name - the name of the method used to execute AbstractCreateStatementInterceptor.isExecute(Method, boolean)
        start - the time the query execution started
        delta - the time the execution took
        Returns:
        - the SQL that was executed or the string "batch" if it was a batch execution
      • getPoolNames

        public java.lang.String[] getPoolNames()
        JMX operation - return the names of all the pools
        Returns:
        - all the names of pools that we have stored data for
      • getPoolName

        public java.lang.String getPoolName()
        JMX operation - return the name of the pool
        Returns:
        the name of the pool, unique within the JVM
      • isNotifyPool

        public boolean isNotifyPool()
      • setNotifyPool

        public void setNotifyPool​(boolean notifyPool)
      • resetStats

        public void resetStats()
        JMX operation - remove all stats for this connection pool
      • getSlowQueriesCD

        public javax.management.openmbean.CompositeData[] getSlowQueriesCD()
                                                                    throws javax.management.openmbean.OpenDataException
        JMX operation - returns all the queries we have collected.
        Specified by:
        getSlowQueriesCD in interface SlowQueryReportJmxMBean
        Returns:
        - the slow query report as composite data.
        Throws:
        javax.management.openmbean.OpenDataException
      • deregisterJmx

        protected void deregisterJmx()
      • getObjectName

        public javax.management.ObjectName getObjectName​(java.lang.Class<?> clazz,
                                                         java.lang.String poolName)
                                                  throws javax.management.MalformedObjectNameException
        Throws:
        javax.management.MalformedObjectNameException
      • registerJmx

        protected void registerJmx()
      • setProperties

        public void setProperties​(java.util.Map<java.lang.String,​PoolProperties.InterceptorProperty> properties)
        Description copied from class: JdbcInterceptor
        Called during the creation of an interceptor The properties can be set during the configuration of an interceptor Override this method to perform type casts between string values and object properties
        Overrides:
        setProperties in class SlowQueryReport
        Parameters:
        properties - The properties