Class SqlStatistic
java.lang.Object
java.lang.Thread
clazzfish.monitor.util.Shutdowner
clazzfish.monitor.AbstractMonitor
clazzfish.jdbc.AbstractStatistic
clazzfish.jdbc.SqlStatistic
- All Implemented Interfaces:
AbstractStatisticMBean,SqlStatisticMBean,AbstractMonitorMBean,Shutdownable,Runnable
This class monitors and measures SQL statements.
- Since:
- 0.9
- Author:
- oliver
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidYou can register the instance as shutdown hook.static SqlStatisticGets the single instance of SqlStatistic.static voidregisterAsMBean(String name) With this method you can register the monitor with your own name.voidreset()To start a new statistic call this method.static ProfileMonitorStart the monitor for the given SQL statement.static voidstop(ProfileMonitor mon, String command) Stops the given 'mon' and logs the given command with the needed time if debug is enabled.static voidstop(ProfileMonitor mon, String command, Object returnValue) Stops the given 'mon' and logs the given command with the needed time if debug is enabled.Methods inherited from class clazzfish.jdbc.AbstractStatistic
dumpMe, dumpMe, getMaxAvg, getMaxAvgLabel, getMaxAvgStatistic, getMaxHits, getMaxHitsLabel, getMaxHitsStatistic, getMaxMax, getMaxMaxLabel, getMaxMaxStatistic, getMaxSize, getMaxTotal, getMaxTotalLabel, getMaxTotalStatistic, getMonitor, getMonitors, getRootMonitor, getSortedMonitors, getStatistics, logMe, resetRootMonitor, setMaxSize, startProfileMonitorForMethods inherited from class clazzfish.monitor.AbstractMonitor
copyResource, dump, dump, dumpArray, dumpArray, dumpHeadline, dumpMe, getDumpDir, isMBean, registerMeAsMBean, registerMeAsMBean, registerMeAsMBean, run, toString, toStringArray, unregisterMeAsMBeanMethods inherited from class clazzfish.monitor.util.Shutdowner
addMeAsShutdownHook, isShutdownHook, removeMeAsShutdownHookMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, yieldMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface clazzfish.jdbc.AbstractStatisticMBean
getMaxAvg, getMaxAvgLabel, getMaxAvgStatistic, getMaxHits, getMaxHitsLabel, getMaxHitsStatistic, getMaxMax, getMaxMaxLabel, getMaxMaxStatistic, getMaxSize, getMaxTotal, getMaxTotalLabel, getMaxTotalStatistic, getStatistics, setMaxSizeMethods inherited from interface clazzfish.monitor.util.Shutdownable
addMeAsShutdownHook, isShutdownHook, removeMeAsShutdownHook
-
Constructor Details
-
SqlStatistic
protected SqlStatistic()
-
-
Method Details
-
getInstance
Gets the single instance of SqlStatistic.- Returns:
- single instance of SqlStatistic
-
reset
public void reset()To start a new statistic call this method. In contradiction toAbstractStatistic.reset()oldProfileMonitors will removed.- Specified by:
resetin interfaceAbstractStatisticMBean- Overrides:
resetin classAbstractStatistic
-
start
Start the monitor for the given SQL statement.- Parameters:
sql- the SQL statement to be monitored- Returns:
- the started profile monitor
-
stop
Stops the given 'mon' and logs the given command with the needed time if debug is enabled.- Parameters:
mon- the moncommand- the command
-
stop
Stops the given 'mon' and logs the given command with the needed time if debug is enabled.- Parameters:
mon- the monitorcommand- the SQL commandreturnValue- the monitored return value
-
addAsShutdownHook
public static void addAsShutdownHook()You can register the instance as shutdown hook. If the VM is terminated the profile values are logged and dumped to a CSV file in the tmp directory. -
registerAsMBean
With this method you can register the monitor with your own name. This is e.g. useful if you have an application server with several applications.You can only register the monitor only once. If you want to register it with another name you have to first unregister it.
- Parameters:
name- the MBean name (e.g. "my.class.Monitor")
-