Interface PerfLogManager
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
PerfLogManagerImpl
This interface describes the Performance Logging and Monitoring Manager that is the frontend to the Performance Logging and Monitoring MBean that does the work behind the scenes.
Instances of PerfLogManager are thread-safe, so they can be
created as static:
01… 02 03/** 04 * The interface to the PerfLog MBean. 05 */ 06private static final PerfLogManager PERFLOGMANAGER; 07 08… 09 10static 11{ 12 //---* Initialise the Performance Logging *-------------------------------- 13 PERFLOGMANAGER = PerfLogUtils.createPerfLogManager(); 14} 15…
or as attributes as well.
Because PerfLogManager implements
AutoCloseable
it can be used with try-with-resources, too:
01… 02 03//---* Initialise the Performance Logging *------------------------------------ 04try( final var perfLogManager = PerfLogUtils.createPerfLogManager() ) 05{ 06 // Do something … 07 08 … 09} 10…
If an instance is abandoned, it will perform an automatic clean-up.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: PerfLogManager.java 1246 2026-05-16 14:07:00Z tquadrat $
- Since:
- 0.25.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.perflog.PerfLogManager"
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()default Optional<PerformanceTracker> Creates a performance tracker for thePerformanceSectionwith the given name.Creates a performance tracker for thePerformanceSectionwith the given name.Returns the performance section specified by the given name.voidloadPerformanceSectionDefinitions(Iterable<PerformanceSection> definitions) Loads the Performance Section definitions.default voidloadPerformanceSectionDefinitions(PerformanceSection... definitions) Loads the Performance Section definitions.
-
Method Details
-
close
void close()After
close()is called, calls to other methods of this instance may result in anIllegalStateExceptionto be thrown.- Specified by:
closein interfaceAutoCloseable
-
createPerformanceTracker
default Optional<PerformanceTracker> createPerformanceTracker(String name) throws IllegalStateException Creates a performance tracker for the
PerformanceSectionwith the given name.The return value will be empty if the performance section is currently ignored.
If there is currently no performance section defined with the given name, one will be created with default values.
- Parameters:
name- The name of the performance section.- Returns:
- An instance of
Optionalthat holds the new tracker. - Throws:
IllegalStateException-close()was already called on this instance.
-
createPerformanceTracker
Optional<PerformanceTracker> createPerformanceTracker(PerformanceSectionName name) throws IllegalStateException Creates a performance tracker for the
PerformanceSectionwith the given name.The return value will be empty if the performance section is currently ignored.
If there is currently no performance section defined with the given name, one will be created with default values.
- Parameters:
name- The name of the performance section.- Returns:
- An instance of
Optionalthat holds the new tracker. - Throws:
IllegalStateException-close()was already called on this instance.
-
getPerformanceSection
Optional<PerformanceSection> getPerformanceSection(PerformanceSectionName name) throws IllegalStateException Returns the performance section specified by the given name.
Delegates to
PerfLogMBean.getPerformanceSection(PerformanceSectionName)- Parameters:
name- The name of the performance section.- Returns:
- An instance of
Optionalthat holds the retrieved performance section. - Throws:
IllegalStateException-close()was already called on this instance.
-
loadPerformanceSectionDefinitions
default void loadPerformanceSectionDefinitions(PerformanceSection... definitions) throws IllegalStateException Loads the Performance Section definitions.
Because these definitions are stored globally in the Performance Logging and Monitorin MBean, they need to be loaded only once. But overwriting them does not harm, other than performance.
Each instance of
PerfLogManagershares the same instances ofPerformanceSection.- Parameters:
definitions- The definitions for the performance sections.- Throws:
IllegalStateException-close()was already called on this instance.
-
loadPerformanceSectionDefinitions
void loadPerformanceSectionDefinitions(Iterable<PerformanceSection> definitions) throws IllegalStateException Loads the Performance Section definitions.
Because these definitions are stored globally in the Performance Logging and Monitorin MBean, they need to be loaded only once. But overwriting them does not harm, other than performance.
Each instance of
PerfLogManagershares the same instances ofPerformanceSection.- Parameters:
definitions- The definitions for the performance sections.- Throws:
IllegalStateException-close()was already called on this instance.
-
