SlowQueryReportJmx (Apache Tomcat 8.5.57 API Documentation)

org.apache.tomcat.jdbc.pool.interceptor

## Class SlowQueryReportJmx

- java.lang.Object
- - org.apache.tomcat.jdbc.pool.JdbcInterceptor
  - - org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
    - - org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport
      - - org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport
        - - org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx

- All Implemented Interfaces:
    InvocationHandler, NotificationBroadcaster, NotificationEmitter, SlowQueryReportJmxMBean

      public class SlowQueryReportJmx
      extends SlowQueryReport
      implements NotificationEmitter, SlowQueryReportJmxMBean

  Publishes data to JMX and provides notifications when failures happen.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport

      `SlowQueryReport.QueryStats, SlowQueryReport.QueryStatsComparator`

    - ### Nested classes/interfaces inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport

      `AbstractQueryReport.StatementProxy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `FAILED_QUERY_NOTIFICATION`
    `protected static ConcurrentHashMap<String,SlowQueryReportJmxMBean>` | `mbeans`
    `protected NotificationBroadcasterSupport` | `notifier`
    `protected boolean` | `notifyPool`
    `protected static AtomicLong` | `notifySequence`
    `static String` | `objectNameAttribute`
    `protected ConnectionPool` | `pool`
    `protected String` | `poolName`
    `static String` | `SLOW_QUERY_NOTIFICATION`
    `protected static CompositeType` | `SLOW_QUERY_TYPE`

    - ### Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport

      `logFailed, logSlow, maxQueries, perPoolStats, queries, queryStatsComparator`

    - ### Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport

      `threshold`

    - ### Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor

      `constructors, CREATE_STATEMENT, CREATE_STATEMENT_IDX, EXECUTE, EXECUTE_BATCH, EXECUTE_QUERY, EXECUTE_TYPES, EXECUTE_UPDATE, PREPARE_CALL, PREPARE_CALL_IDX, PREPARE_STATEMENT, PREPARE_STATEMENT_IDX, STATEMENT_TYPE_COUNT, STATEMENT_TYPES`

    - ### Fields inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor

      `CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SlowQueryReportJmx()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)`
    `protected void` | `deregisterJmx()`
    `protected static CompositeType` | `getCompositeType()`
    `MBeanNotificationInfo[]` | `getNotificationInfo()`
    `ObjectName` | `getObjectName(Class<?> clazz, String poolName)`
    `String` | `getPoolName()` JMX operation - return the name of the pool
    `String[]` | `getPoolNames()` JMX operation - return the names of all the pools
    `CompositeData[]` | `getSlowQueriesCD()` JMX operation - returns all the queries we have collected.
    `boolean` | `isNotifyPool()`
    `protected void` | `notifyJmx(String query, String type)`
    `void` | `poolClosed(ConnectionPool pool)` This method is invoked by a connection pool when the pool is closed.
    `void` | `poolStarted(ConnectionPool pool)` This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested.
    `protected void` | `registerJmx()`
    `void` | `removeNotificationListener(NotificationListener listener)`
    `void` | `removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)`
    `protected String` | `reportFailedQuery(String query, Object[] args, String name, long start, Throwable t)` Invoked when a query execution, a call to execute/executeQuery or executeBatch failed.
    `protected String` | `reportSlowQuery(String query, Object[] args, String name, long start, long delta)` Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was exceeded the timing threshold
    `void` | `reset(ConnectionPool parent, PooledConnection con)` no-op for this interceptor. no state is stored.
    `void` | `resetStats()` JMX operation - remove all stats for this connection pool
    `void` | `setNotifyPool(boolean notifyPool)`
    `void` | `setProperties(Map<String,PoolProperties.InterceptorProperty> properties)` 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

    - ### Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport

      `closeInvoked, getPoolStats, getQueryStats, isLogFailed, isLogSlow, prepareCall, prepareStatement, removeOldest, reportQuery, setLogFailed, setLogSlow, setMaxQueries`

    - ### Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport

      `createStatement, getThreshold, setThreshold`

    - ### Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor

      `getConstructor, invoke, isExecute, isStatement, process`

    - ### Methods inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor

      `compare, compare, disconnected, getNext, getProperties, isUseEquals, setNext, setUseEquals`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SLOW_QUERY_NOTIFICATION

          public static final String SLOW_QUERY_NOTIFICATION

      See Also:
        Constant Field Values

    - #### FAILED_QUERY_NOTIFICATION

          public static final String FAILED_QUERY_NOTIFICATION

      See Also:
        Constant Field Values

    - #### objectNameAttribute

          public static final String objectNameAttribute

      See Also:
        Constant Field Values

    - #### SLOW_QUERY_TYPE

          protected static volatile CompositeType SLOW_QUERY_TYPE

    - #### mbeans

          protected static final ConcurrentHashMap<String,SlowQueryReportJmxMBean> mbeans

    - #### notifier

          protected volatile NotificationBroadcasterSupport notifier

    - #### poolName

          protected String poolName

    - #### notifySequence

          protected static final AtomicLong notifySequence

    - #### notifyPool

          protected boolean notifyPool

    - #### pool

          protected ConnectionPool pool

  - ### Constructor Detail

    - #### SlowQueryReportJmx

          public SlowQueryReportJmx()

  - ### Method Detail

    - #### addNotificationListener

          public void addNotificationListener(NotificationListener listener,
                                     NotificationFilter filter,
                                     Object handback)
                                       throws IllegalArgumentException

      Specified by:
        `addNotificationListener` in interface `NotificationBroadcaster`
      Throws:
        `IllegalArgumentException`

    - #### getNotificationInfo

          public MBeanNotificationInfo[] getNotificationInfo()

      Specified by:
        `getNotificationInfo` in interface `NotificationBroadcaster`

    - #### removeNotificationListener

          public void removeNotificationListener(NotificationListener listener)
                                          throws ListenerNotFoundException

      Specified by:
        `removeNotificationListener` in interface `NotificationBroadcaster`
      Throws:
        `ListenerNotFoundException`

    - #### removeNotificationListener

          public void removeNotificationListener(NotificationListener listener,
                                        NotificationFilter filter,
                                        Object handback)
                                          throws ListenerNotFoundException

      Specified by:
        `removeNotificationListener` in interface `NotificationEmitter`
      Throws:
        `ListenerNotFoundException`

    - #### getCompositeType

          protected static CompositeType getCompositeType()

    - #### reset

          public void reset(ConnectionPool parent,
                   PooledConnection con)

      Description copied from class: `AbstractCreateStatementInterceptor`
      no-op for this interceptor. no state is stored.
      Overrides:
        `reset` in class `SlowQueryReport`
      Parameters:
        `parent` - - the connection pool owning the connection
        `con` - - the pooled connection

    - #### 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 String reportFailedQuery(String query,
                                 Object[] args,
                                 String name,
                                 long start,
                                 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(String query,
                       String type)

    - #### reportSlowQuery

          protected String reportSlowQuery(String query,
                               Object[] args,
                               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 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 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 CompositeData[] getSlowQueriesCD()
                                           throws 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:
        `OpenDataException`

    - #### deregisterJmx

          protected void deregisterJmx()

    - #### getObjectName

          public ObjectName getObjectName(Class<?> clazz,
                                 String poolName)
                                   throws MalformedObjectNameException

      Throws:
        `MalformedObjectNameException`

    - #### registerJmx

          protected void registerJmx()

    - #### setProperties

          public void setProperties(Map<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

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.