Class AbstractQueryReport
java.lang.Object
org.apache.tomcat.jdbc.pool.JdbcInterceptor
org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport
- All Implemented Interfaces:
InvocationHandler
- Direct Known Subclasses:
ResetAbandonedTimer
,SlowQueryReport
Abstract class that wraps statements and intercepts query executions.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Class to measure query execute time -
Field Summary
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
-
Method Summary
Modifier and TypeMethodDescriptioncreateStatement
(Object proxy, Method method, Object[] args, Object statement, long time) Creates a statement interceptor to monitor query response timeslong
returns the query measure threshold.protected abstract void
prepareCall
(String query, long time) Invoked when prepareCall has been called and completed.protected abstract void
prepareStatement
(String sql, long time) Invoked when prepareStatement has been called and completed.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
reportQuery
(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 within the timing thresholdprotected 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 thresholdvoid
setThreshold
(long threshold) Sets the query measurement threshold.Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
closeInvoked, getConstructor, invoke, isExecute, isStatement, process, reset
Methods inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor
compare, compare, disconnected, getNext, getProperties, isUseEquals, poolClosed, poolStarted, setNext, setProperties, setUseEquals
-
Field Details
-
threshold
protected long thresholdThe threshold in milliseconds. If the query is faster than this, we don't measure it
-
-
Constructor Details
-
AbstractQueryReport
public AbstractQueryReport()
-
-
Method Details
-
prepareStatement
Invoked when prepareStatement has been called and completed.- Parameters:
sql
- - the string used to prepare the statement withtime
- - the time it took to invoke prepare
-
prepareCall
Invoked when prepareCall has been called and completed.- Parameters:
query
- - the string used to prepare the statement withtime
- - the time it took to invoke prepare
-
reportFailedQuery
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.- Parameters:
query
- the query that was executed and failedargs
- the arguments to the executionname
- the name of the method used to executeAbstractCreateStatementInterceptor.isExecute(Method, boolean)
start
- the time the query execution startedt
- the exception that happened- Returns:
- - the SQL that was executed or the string "batch" if it was a batch execution
-
reportQuery
Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was within the timing threshold- Parameters:
query
- the query that was executed and failedargs
- the arguments to the executionname
- the name of the method used to executeAbstractCreateStatementInterceptor.isExecute(Method, boolean)
start
- the time the query execution starteddelta
- the time the execution took- Returns:
- - the SQL that was executed or the string "batch" if it was a batch execution
-
reportSlowQuery
Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was exceeded the timing threshold- Parameters:
query
- the query that was executed and failedargs
- the arguments to the executionname
- the name of the method used to executeAbstractCreateStatementInterceptor.isExecute(Method, boolean)
start
- the time the query execution starteddelta
- the time the execution took- Returns:
- - the SQL that was executed or the string "batch" if it was a batch execution
-
getThreshold
public long getThreshold()returns the query measure threshold. This value is in milliseconds. If the query is faster than this threshold than it won't be accounted for- Returns:
- the threshold in milliseconds
-
setThreshold
public void setThreshold(long threshold) Sets the query measurement threshold. The value is in milliseconds. If the query goes faster than this threshold it will not be recorded.- Parameters:
threshold
- set to -1 to record every query. Value is in milliseconds.
-
createStatement
public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) Creates a statement interceptor to monitor query response times- Specified by:
createStatement
in classAbstractCreateStatementInterceptor
- Parameters:
proxy
- the actual proxy objectmethod
- the method that was called. It will be one of the methods defined inAbstractCreateStatementInterceptor.STATEMENT_TYPES
args
- the arguments to the methodstatement
- the statement that the underlying connection createdtime
- Elapsed time- Returns:
- a
Statement
object
-