public class SlowQueryReport extends AbstractQueryReport
Modifier and Type | Class and Description |
---|---|
static class |
SlowQueryReport.QueryStats |
AbstractQueryReport.StatementProxy
Modifier and Type | Field and Description |
---|---|
protected boolean |
logFailed
Flag to enable disable logging of failed queries
|
protected boolean |
logSlow
Flag to enable disable logging of slow queries
|
protected int |
maxQueries
Maximum number of queries we will be storing
|
protected static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats>> |
perPoolStats
we will be keeping track of query stats on a per pool basis
|
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats> |
queries
the queries that are used for this interceptor.
|
protected java.util.Comparator<SlowQueryReport.QueryStats> |
queryStatsComparator
Sort QueryStats by last invocation time
|
threshold
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
CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL
Constructor and Description |
---|
SlowQueryReport()
Creates a slow query report interceptor
|
Modifier and Type | Method and Description |
---|---|
void |
closeInvoked()
invoked when the connection receives the close request
Not used for now.
|
static java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats> |
getPoolStats(java.lang.String poolname)
Returns the query stats for a given pool
|
protected SlowQueryReport.QueryStats |
getQueryStats(java.lang.String sql) |
boolean |
isLogFailed() |
boolean |
isLogSlow() |
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.
|
void |
prepareCall(java.lang.String sql,
long time)
Invoked when prepareCall has been called and completed.
|
void |
prepareStatement(java.lang.String sql,
long time)
Invoked when prepareStatement has been called and completed.
|
protected void |
removeOldest(java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats> queries)
Sort QueryStats by last invocation time
|
protected java.lang.String |
reportFailedQuery(java.lang.String query,
java.lang.Object[] args,
java.lang.String name,
long start,
java.lang.Throwable t)
Invoked when a query execution, a call to execute/executeQuery or executeBatch failed.
|
protected java.lang.String |
reportQuery(java.lang.String query,
java.lang.Object[] args,
java.lang.String name,
long start,
long delta)
Invoked when a query execution, a call to execute/executeQuery or executeBatch succeeded and was within the timing threshold
|
protected java.lang.String |
reportSlowQuery(java.lang.String query,
java.lang.Object[] args,
java.lang.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 |
setLogFailed(boolean logFailed) |
void |
setLogSlow(boolean logSlow) |
void |
setMaxQueries(int maxQueries) |
void |
setProperties(java.util.Map<java.lang.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
|
createStatement, getThreshold, setThreshold
getConstructor, invoke, isExecute, isStatement, process
compare, compare, disconnected, getNext, getProperties, isUseEquals, setNext, setUseEquals
protected static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats>> perPoolStats
protected volatile java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats> queries
protected int maxQueries
protected boolean logSlow
protected boolean logFailed
protected final java.util.Comparator<SlowQueryReport.QueryStats> queryStatsComparator
public static java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats> getPoolStats(java.lang.String poolname)
poolname
- - the name of the pool we want to retrieve stats forpublic void setMaxQueries(int maxQueries)
protected java.lang.String reportFailedQuery(java.lang.String query, java.lang.Object[] args, java.lang.String name, long start, java.lang.Throwable t)
AbstractQueryReport
reportFailedQuery
in class AbstractQueryReport
query
- the query that was executed and failedargs
- the arguments to the executionname
- the name of the method used to execute AbstractCreateStatementInterceptor.isExecute(Method, boolean)
start
- the time the query execution startedt
- the exception that happenedprotected java.lang.String reportQuery(java.lang.String query, java.lang.Object[] args, java.lang.String name, long start, long delta)
AbstractQueryReport
reportQuery
in class AbstractQueryReport
query
- the query that was executed and failedargs
- the arguments to the executionname
- the name of the method used to execute AbstractCreateStatementInterceptor.isExecute(Method, boolean)
start
- the time the query execution starteddelta
- the time the execution tookprotected java.lang.String reportSlowQuery(java.lang.String query, java.lang.Object[] args, java.lang.String name, long start, long delta)
AbstractQueryReport
reportSlowQuery
in class AbstractQueryReport
query
- the query that was executed and failedargs
- the arguments to the executionname
- the name of the method used to execute AbstractCreateStatementInterceptor.isExecute(Method, boolean)
start
- the time the query execution starteddelta
- the time the execution tookpublic void closeInvoked()
closeInvoked
in class AbstractCreateStatementInterceptor
public void prepareStatement(java.lang.String sql, long time)
AbstractQueryReport
prepareStatement
in class AbstractQueryReport
sql
- - the string used to prepare the statement withtime
- - the time it took to invoke preparepublic void prepareCall(java.lang.String sql, long time)
AbstractQueryReport
prepareCall
in class AbstractQueryReport
sql
- - the string used to prepare the statement withtime
- - the time it took to invoke preparepublic void poolStarted(ConnectionPool pool)
poolStarted
in class JdbcInterceptor
pool
- - the pool that is being closed.public void poolClosed(ConnectionPool pool)
poolClosed
in class JdbcInterceptor
pool
- - the pool that is being closed.protected SlowQueryReport.QueryStats getQueryStats(java.lang.String sql)
protected void removeOldest(java.util.concurrent.ConcurrentHashMap<java.lang.String,SlowQueryReport.QueryStats> queries)
queries
- public void reset(ConnectionPool parent, PooledConnection con)
AbstractCreateStatementInterceptor
reset
in class AbstractCreateStatementInterceptor
parent
- - the connection pool owning the connectioncon
- - the pooled connectionpublic boolean isLogSlow()
public void setLogSlow(boolean logSlow)
public boolean isLogFailed()
public void setLogFailed(boolean logFailed)
public void setProperties(java.util.Map<java.lang.String,PoolProperties.InterceptorProperty> properties)
JdbcInterceptor
setProperties
in class JdbcInterceptor
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.