Class SqlStatistic
java.lang.Object
java.lang.Thread
clazzfish.core.util.ShutdownHook
clazzfish.monitor.AbstractMonitor
clazzfish.jdbc.AbstractStatistic
clazzfish.jdbc.SqlStatistic
- All Implemented Interfaces:
Shutdownable, AbstractStatisticMBean, SqlStatisticMBean, AbstractMonitorMBean, Runnable
This class monitors and measures SQL statements.
- Since:
- 0.9
- Author:
- oliver
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Method Summary
Modifier and TypeMethodDescriptionExports the SQL statistic as CSV.Returns the URI where the statistic should be exported to.static SqlStatisticvoidImports the statistics from the given URI.voidreset()To start a new statistic call this method.voidsetXPorter(CsvXPorter xPorter) 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.toString()As the toString implementation the name of the registered MBean is used.Methods inherited from class AbstractStatistic
dumpMe, dumpMe, getCsvLines, getMaxAvg, getMaxAvgLabel, getMaxAvgStatistic, getMaxHits, getMaxHitsLabel, getMaxHitsStatistic, getMaxMax, getMaxMaxLabel, getMaxMaxStatistic, getMaxSize, getMaxTotal, getMaxTotalLabel, getMaxTotalStatistic, getMonitor, getMonitors, getSortedMonitors, getStatistics, logMe, resetRootMonitor, setMaxSize, startProfileMonitorForModifier and TypeMethodDescriptiondumpMe()This operation dumps statistic into a (temporary) file with the classname as prefix.voidDump statistic to the given file.doubleGets the max avg.Gets the max avg label.Gets the max avg statistic.intGets the max hits.Gets the max hits label.Gets the max hits statistic.doubleGets the max max.Gets the max max label.Gets the max max statistic.intGets the max size.doubleGets the max total.Gets the max total label.Gets the max total statistic.getMonitor(String label) Returns the monitor for the given label.Gets the monitors (unsorted).protected final ProfileMonitor[]Gets the sorted monitors.Gets the statistics.voidlogMe()Log statistic.protected voidResets the root monitor.voidsetMaxSize(int size) Here you can set the maximal size of the statistic entries.Start profile monitor for the given signature.Methods inherited from class AbstractMonitor
copyResource, dump, dump, dumpArray, dumpArray, dumpHeadline, dumpMe, getDumpDir, isMBean, registerMeAsMBean, registerMeAsMBean, run, toStringArray, unregisterMeAsMBeanModifier and TypeMethodDescriptionprotected voidcopyResource(String name, File file) Copy a resource to the given file.protected voiddump(BufferedWriter writer, String... getterMethodNames) This operation dumps the different MBean attributes.protected voidDumps different arrays to the given dumpDir directory, each array in its own file.protected static voiddumpArray(Object[] array, BufferedWriter writer, String title) Dump array.protected static voidDumps an array to the given directory.protected static voiddumpHeadline(BufferedWriter writer, String headline) Dump headline.voidThis operation dumps the different MBean attributes to the given directory.The base directory where all is dumped can be configured (seeConfig.getDumpDir().booleanisMBean()If you want to ask JMX if bean is already registered you can ask the MBeanHelper or you can ask this method.voidWith this method you can register the monitor with the default name.voidregisterMeAsMBean(ObjectName name) With this method you can register the monitor with your own name.voidrun()This method is called when the ClasspathMonitor is registered as shutdown hook.protected static String[]toStringArray(URI[] uris) We remove the URI prefix from the result to be in-line with the other classpath methods.voidUnregister monitor as MBean.Methods inherited from class ShutdownHook
addMeAsShutdownHook, isShutdownHook, removeMeAsShutdownHookModifier and TypeMethodDescriptionvoidTo be able to register the class as shutdown hook via JMX we can't use a static method - this is the reason why this additional method was added.booleanHere you can ask if the class was already registered as shutdown hook.voidIf you want to unregister the instance as shutdown hook you can use this (not static) method.Methods inherited from class 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, threadId, yield
-
Method Details
-
getInstance
-
getXPorter
-
setXPorter
-
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
-
exportCSV
Exports the SQL statistic as CSV.- Overrides:
exportCSVin classAbstractMonitor- Returns:
- the URI where the statistic is exported
- Throws:
IOException- in case of IO problems- Since:
- 3.0
-
getExportURI
Description copied from interface:SqlStatisticMBeanReturns the URI where the statistic should be exported to.- Specified by:
getExportURIin interfaceSqlStatisticMBean- Returns:
- export URI
-
importCSV
Imports the statistics from the given URI.- Parameters:
csvURI- URI where the statistic should be imported from
-
toString
Description copied from class:AbstractMonitorAs the toString implementation the name of the registered MBean is used.- Overrides:
toStringin classAbstractMonitor- Returns:
- the registered MBean name
-