Class AbstractStatistic
java.lang.Object
java.lang.Thread
clazzfish.core.util.ShutdownHook
clazzfish.monitor.AbstractMonitor
clazzfish.jdbc.AbstractStatistic
- All Implemented Interfaces:
Shutdownable, AbstractStatisticMBean, AbstractMonitorMBean, Runnable
- Direct Known Subclasses:
SqlStatistic
This was constructed as a thin layer around com.jamonapi.MonitorFactory for
the needs of generating statistics. The reason for this layer is that sometimes you
want to minimize the use of other libraries. So this implementation provides
also an implementation if the JaMon library is missing.
- 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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractStatistic(String rootLabel) Instantiates a new profile statistic. -
Method Summary
Modifier 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.voidreset()We can't reset all ProfileMonitors - we must keep the empty monitors with 0 hits to see which methods or constructors are never called.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, exportCSV, getDumpDir, isMBean, registerMeAsMBean, registerMeAsMBean, run, toString, 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.If you want to configure viaConfig.DUMP_URIthe location where the monitored data should be exported you should override this method.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.toString()As the toString implementation the name of the registered MBean is used.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
-
Constructor Details
-
AbstractStatistic
Instantiates a new profile statistic.- Parameters:
rootLabel- the root label
-
-
Method Details
-
reset
public void reset()We can't reset all ProfileMonitors - we must keep the empty monitors with 0 hits to see which methods or constructors are never called.- Specified by:
resetin interfaceAbstractStatisticMBean
-
resetRootMonitor
protected void resetRootMonitor()Resets the root monitor. -
setMaxSize
public void setMaxSize(int size) Here you can set the maximal size of the statistic entries.- Specified by:
setMaxSizein interfaceAbstractStatisticMBean- Parameters:
size- the new max size
-
getMaxSize
public int getMaxSize()Gets the max size.- Specified by:
getMaxSizein interfaceAbstractStatisticMBean- Returns:
- the max size
-
startProfileMonitorFor
Start profile monitor for the given signature.- Parameters:
sig- the signature- Returns:
- the profile monitor
-
getMonitors
-
getMonitor
Returns the monitor for the given label. It it does not exists anIllegalArgumentExceptionwill be thrown.- Parameters:
label- label of the monitor- Returns:
- monitor with the given label
-
getSortedMonitors
Gets the sorted monitors.- Returns:
- monitors sorted after total time (descending order)
-
getMaxHits
public int getMaxHits()Gets the max hits.- Specified by:
getMaxHitsin interfaceAbstractStatisticMBean- Returns:
- the max hits
-
getMaxHitsLabel
Gets the max hits label.- Specified by:
getMaxHitsLabelin interfaceAbstractStatisticMBean- Returns:
- the max hits label
-
getMaxHitsStatistic
Gets the max hits statistic.- Specified by:
getMaxHitsStatisticin interfaceAbstractStatisticMBean- Returns:
- the max hits statistic
-
getMaxTotal
public double getMaxTotal()Gets the max total.- Specified by:
getMaxTotalin interfaceAbstractStatisticMBean- Returns:
- the max total
-
getMaxTotalLabel
Gets the max total label.- Specified by:
getMaxTotalLabelin interfaceAbstractStatisticMBean- Returns:
- the max total label
-
getMaxTotalStatistic
Gets the max total statistic.- Specified by:
getMaxTotalStatisticin interfaceAbstractStatisticMBean- Returns:
- the max total statistic
-
getMaxAvg
public double getMaxAvg()Gets the max avg.- Specified by:
getMaxAvgin interfaceAbstractStatisticMBean- Returns:
- the max avg
-
getMaxAvgLabel
Gets the max avg label.- Specified by:
getMaxAvgLabelin interfaceAbstractStatisticMBean- Returns:
- the max avg label
-
getMaxAvgStatistic
Gets the max avg statistic.- Specified by:
getMaxAvgStatisticin interfaceAbstractStatisticMBean- Returns:
- the max avg statistic
-
getMaxMax
public double getMaxMax()Gets the max max.- Specified by:
getMaxMaxin interfaceAbstractStatisticMBean- Returns:
- the max max
-
getMaxMaxLabel
Gets the max max label.- Specified by:
getMaxMaxLabelin interfaceAbstractStatisticMBean- Returns:
- the max max label
-
getMaxMaxStatistic
Gets the max max statistic.- Specified by:
getMaxMaxStatisticin interfaceAbstractStatisticMBean- Returns:
- the max max statistic
-
getStatistics
Gets the statistics.- Specified by:
getStatisticsin interfaceAbstractStatisticMBean- Returns:
- the statistics
-
logMe
public void logMe()Log statistic.- Specified by:
logMein interfaceAbstractMonitorMBean- Specified by:
logMein classAbstractMonitor
-
dumpMe
This operation dumps statistic into a (temporary) file with the classname as prefix. The name of the created file is returned so that you can see it in the 'jconsole' (if you have triggered it from there).- Specified by:
dumpMein interfaceAbstractMonitorMBean- Overrides:
dumpMein classAbstractMonitor- Returns:
- the file
- Throws:
IOException- Signals that an I/O exception has occurred.- See Also:
-
dumpMe
Dump statistic to the given file.- Overrides:
dumpMein classAbstractMonitor- Parameters:
dumpFile- the dump file- Throws:
IOException- Signals that an I/O exception has occurred.
-
getCsvLines
-