Top Description Fields Constructors Methods
org.apache.tomcat.jdbc.pool.interceptor

public Class SlowQueryReportJmx

extends SlowQueryReport
implements NotificationEmitter, SlowQueryReportJmxMBean
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmxMBean, javax.management.NotificationEmitter, javax.management.NotificationBroadcaster
Imports
java.util.Iterator, .Map, .Set, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicLong, javax.management.ListenerNotFoundException, .MBeanNotificationInfo, .MalformedObjectNameException, .Notification, .NotificationBroadcasterSupport, .NotificationEmitter, .NotificationFilter, .NotificationListener, .ObjectName, .RuntimeOperationsException, javax.management.openmbean.CompositeData, .CompositeDataSupport, .CompositeType, .OpenDataException, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.jdbc.pool.ConnectionPool, .PoolProperties.InterceptorProperty, .PooledConnection, org.apache.tomcat.jdbc.pool.jmx.JmxUtil

Publishes data to JMX and provides notifications when failures happen.

Field Summary

Modifier and TypeField and Description
public static final String
private static final Log
protected static final ConcurrentHashMap<String, SlowQueryReportJmxMBean>
protected volatile NotificationBroadcasterSupport
protected boolean
protected static final AtomicLong
public static final String
protected ConnectionPool
protected String
public static final String
protected static volatile CompositeType
Inherited from org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport:
logFailedlogSlowmaxQueriesperPoolStatsqueriesqueryStatsComparator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addNotificationListener(NotificationListener
The listener object which will handle the notifications emitted by the broadcaster.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
An opaque object to be sent back to the listener when a notification is emitted. This object cannot be used by the Notification broadcaster object. It should be resent unchanged with the notification to the listener.
handback
)

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Adds a listener to this MBean.

protected void
protected static CompositeType
public MBeanNotificationInfo[]
getNotificationInfo()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.

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

public String

Returns:

the name of the pool, unique within the JVM
getPoolName
()

JMX operation - return the name of the pool

public String[]

Returns:

- all the names of pools that we have stored data for
getPoolNames
()

JMX operation - return the names of all the pools

public CompositeData[]

Returns:

- the slow query report as composite data.
getSlowQueriesCD
()

Implements org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmxMBean.getSlowQueriesCD.

JMX operation - returns all the queries we have collected.

public boolean
protected void
notifyJmx(String query, String type)

public void
poolClosed(ConnectionPool
- the pool that is being closed.
pool
)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.poolClosed.

This method is invoked by a connection pool when the pool is closed.

public void
poolStarted(ConnectionPool
- the pool that is being closed.
pool
)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.poolStarted.

This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested.

protected void
public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
)

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Removes a listener from this MBean.

public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Implements javax.management.NotificationEmitter.removeNotificationListener.

Removes a listener from this MBean.

protected String
reportFailedQuery(String
the query that was executed and failed
query
,
Object[]
the arguments to the execution
args
,
String name, long
the time the query execution started
start
,
Throwable
the exception that happened
t
)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reportFailedQuery.

Invoked when a query execution, a call to execute/executeQuery or executeBatch failed.

protected String
reportSlowQuery(String
the query that was executed and failed
query
,
Object[]
the arguments to the execution
args
,
String name, long
the time the query execution started
start
,
long
the time the execution took
delta
)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reportSlowQuery.

Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was exceeded the timing threshold

public void
reset(ConnectionPool
- the connection pool owning the connection
parent
,
PooledConnection
- the pooled connection
con
)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reset.

no-op for this interceptor.

public void
resetStats()

JMX operation - remove all stats for this connection pool

public void
setNotifyPool(boolean notifyPool)

public void
setProperties(Map<String, PoolProperties.InterceptorProperty>
The properties
properties
)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.setProperties.

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

Inherited from org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport:
closeInvokedgetPoolStatsgetQueryStatsisLogFailedisLogSlowprepareCallprepareStatementremoveOldestreportQuerysetLogFailedsetLogSlowsetMaxQueries

Field Detail

FAILED_QUERY_NOTIFICATIONback to summary
public static final String FAILED_QUERY_NOTIFICATION
logback to summary
private static final Log log

Hides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.log.

mbeansback to summary
protected static final ConcurrentHashMap<String, SlowQueryReportJmxMBean> mbeans
notifierback to summary
protected volatile NotificationBroadcasterSupport notifier
notifyPoolback to summary
protected boolean notifyPool
notifySequenceback to summary
protected static final AtomicLong notifySequence
objectNameAttributeback to summary
public static final String objectNameAttribute
poolback to summary
protected ConnectionPool pool
poolNameback to summary
protected String poolName
SLOW_QUERY_NOTIFICATIONback to summary
public static final String SLOW_QUERY_NOTIFICATION
SLOW_QUERY_TYPEback to summary
protected static volatile CompositeType SLOW_QUERY_TYPE

Constructor Detail

SlowQueryReportJmxback to summary
public SlowQueryReportJmx()

Method Detail

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

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Doc from javax.management.NotificationBroadcaster.addNotificationListener.

Adds a listener to this MBean.

Parameters
listener:NotificationListener

The listener object which will handle the notifications emitted by the broadcaster.

filter:NotificationFilter

The filter object. If filter is null, no filtering will be performed before handling notifications.

handback:Object

An opaque object to be sent back to the listener when a notification is emitted. This object cannot be used by the Notification broadcaster object. It should be resent unchanged with the notification to the listener.

Annotations
@Override
Exceptions
IllegalArgumentException:
Listener parameter is null.
deregisterJmxback to summary
protected void deregisterJmx()
getCompositeTypeback to summary
protected static CompositeType getCompositeType()
getNotificationInfoback to summary
public MBeanNotificationInfo[] getNotificationInfo()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Doc from javax.management.NotificationBroadcaster.getNotificationInfo.

Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.

It is not illegal for the MBean to send notifications not described in this array. However, some clients of the MBean server may depend on the array being complete for their correct functioning.

Returns:MBeanNotificationInfo[]

the array of possible notifications.

Annotations
@Override
getObjectNameback to summary
public ObjectName getObjectName(Class<?> clazz, String poolName) throws MalformedObjectNameException
getPoolNameback to summary
public String getPoolName()

JMX operation - return the name of the pool

Returns:String

the name of the pool, unique within the JVM

getPoolNamesback to summary
public String[] getPoolNames()

JMX operation - return the names of all the pools

Returns:String[]

- all the names of pools that we have stored data for

getSlowQueriesCDback to summary
public CompositeData[] getSlowQueriesCD() throws OpenDataException

Implements org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmxMBean.getSlowQueriesCD.

JMX operation - returns all the queries we have collected.

Returns:CompositeData[]

- the slow query report as composite data.

Annotations
@Override
isNotifyPoolback to summary
public boolean isNotifyPool()
notifyJmxback to summary
protected void notifyJmx(String query, String type)
poolClosedback to summary
public void poolClosed(ConnectionPool pool)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.poolClosed.

Doc from org.apache.tomcat.jdbc.pool.JdbcInterceptor.poolClosed.

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.

Parameters
pool:ConnectionPool

- the pool that is being closed.

Annotations
@Override
poolStartedback to summary
public void poolStarted(ConnectionPool pool)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.poolStarted.

Doc from org.apache.tomcat.jdbc.pool.JdbcInterceptor.poolStarted.

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.

Parameters
pool:ConnectionPool

- the pool that is being closed.

Annotations
@Override
registerJmxback to summary
protected void registerJmx()
removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Doc from javax.management.NotificationBroadcaster.removeNotificationListener.

Removes a listener from this MBean. If the listener has been registered with different handback objects or notification filters, all entries corresponding to the listener will be removed.

Parameters
listener:NotificationListener

A listener that was previously added to this MBean.

Annotations
@Override
Exceptions
ListenerNotFoundException:
The listener is not registered with the MBean.
removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException

Implements javax.management.NotificationEmitter.removeNotificationListener.

Doc from javax.management.NotificationEmitter.removeNotificationListener.

Removes a listener from this MBean. The MBean must have a listener that exactly matches the given listener, filter, and handback parameters. If there is more than one such listener, only one is removed.

The filter and handback parameters may be null if and only if they are null in a listener to be removed.

Parameters
listener:NotificationListener

A listener that was previously added to this MBean.

filter:NotificationFilter

The filter that was specified when the listener was added.

handback:Object

The handback that was specified when the listener was added.

Annotations
@Override
Exceptions
ListenerNotFoundException:
The listener is not registered with the MBean, or it is not registered with the given filter and handback.
reportFailedQueryback to summary
protected String reportFailedQuery(String query, Object[] args, String name, long start, Throwable t)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reportFailedQuery.

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport.reportFailedQuery.

Invoked when a query execution, a call to execute/executeQuery or executeBatch failed.

Parameters
query:String

the query that was executed and failed

args:Object[]

the arguments to the execution

name:String

the name of the method used to execute AbstractCreateStatementInterceptor#isExecute(Method, boolean)

start:long

the time the query execution started

t:Throwable

the exception that happened

Returns:String

- the SQL that was executed or the string "batch" if it was a batch execution

Annotations
@Override
reportSlowQueryback to summary
protected String reportSlowQuery(String query, Object[] args, String name, long start, long delta)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reportSlowQuery.

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport.reportSlowQuery.

Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was exceeded the timing threshold

Parameters
query:String

the query that was executed and failed

args:Object[]

the arguments to the execution

name:String

the name of the method used to execute AbstractCreateStatementInterceptor#isExecute(Method, boolean)

start:long

the time the query execution started

delta:long

the time the execution took

Returns:String

- the SQL that was executed or the string "batch" if it was a batch execution

Annotations
@Override
resetback to summary
public void reset(ConnectionPool parent, PooledConnection con)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.reset.

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.reset.

no-op for this interceptor. no state is stored.

Parameters
parent:ConnectionPool

Doc from org.apache.tomcat.jdbc.pool.JdbcInterceptor.reset.

- the connection pool owning the connection

con:PooledConnection

Doc from org.apache.tomcat.jdbc.pool.JdbcInterceptor.reset.

- the pooled connection

Annotations
@Override
resetStatsback to summary
public void resetStats()

JMX operation - remove all stats for this connection pool

setNotifyPoolback to summary
public void setNotifyPool(boolean notifyPool)
setPropertiesback to summary
public void setProperties(Map<String, PoolProperties.InterceptorProperty> properties)

Overrides org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.setProperties.

Doc from org.apache.tomcat.jdbc.pool.JdbcInterceptor.setProperties.

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

Parameters
properties:Map<String, PoolProperties.InterceptorProperty>

The properties

Annotations
@Override