- java.lang.Object
-
- com.microsoft.gctoolkit.GCToolKit
-
public class GCToolKit extends Object
The primary API for analyzing Java Garbage Collection (GC) logs.
-
-
Constructor Summary
Constructors Constructor Description GCToolKit()Instantiate a GCToolKit object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataSourceParser(DataSourceParser dataSourceParser)Add a DataSourceParser to be used to parse a DataSource.JavaVirtualMachineanalyze(DataSource<?> dataSource)Perform an analysis on a GC log file.voidloadAggregation(Aggregation aggregation)Registers anAggregationclass which can be used to perform analysis onJVMEvents.voidloadAggregationsFromServiceLoader()Loads all Aggregations defined in the application module through the java.util.ServiceLoader model.voidloadDataSourceChannel(DataSourceChannel channel)voidloadDataSourceParser(DataSourceParser dataSourceParser)This method allows full control over which DataSourceParsers are used to parse the DataSource.voidloadJVMEventChannel(JVMEventChannel channel)static voidLOG_DEBUG_MESSAGE(Supplier<String> message)Print a debug message to System.out if gctoolkit.debug is empty, is set to "all", or contains "className" but does not contain "-className".
-
-
-
Method Detail
-
LOG_DEBUG_MESSAGE
public static void LOG_DEBUG_MESSAGE(Supplier<String> message)
Print a debug message to System.out if gctoolkit.debug is empty, is set to "all", or contains "className" but does not contain "-className". For example, to enable debug logging for all classes except UnifiedG1GCParser:-Dgctoolkit.debug=all,-com.microsoft.gctoolkit.parser.UnifiedG1GCParser- Parameters:
message- Supplies the message to log. If null, nothing will be logged.
-
loadAggregationsFromServiceLoader
public void loadAggregationsFromServiceLoader()
Loads all Aggregations defined in the application module through the java.util.ServiceLoader model. To register a class that provides theAggregationAPI, define the following inmodule-info.java:import com.microsoft.gctoolkit.aggregator.Aggregation; import com.microsoft.gctoolkit.sample.aggregation.HeapOccupancyAfterCollectionSummary; module com.microsoft.gctoolkit.sample { ... provides Aggregation with HeapOccupancyAfterCollectionSummary; }
-
loadAggregation
public void loadAggregation(Aggregation aggregation)
Registers anAggregationclass which can be used to perform analysis onJVMEvents. GCToolKit will instantiate the Aggregation when needed.The
JavaVirtualMachine.getAggregation(Class)API will return an Aggregation that was used in the log analysis. Even though an Aggregation was registered, thegetAggregationmethod will return null if the Aggregation was not used in the analysis.- Parameters:
aggregation- the Aggregation class to register.- See Also:
Aggregation,JavaVirtualMachine
-
loadDataSourceChannel
public void loadDataSourceChannel(DataSourceChannel channel)
-
loadJVMEventChannel
public void loadJVMEventChannel(JVMEventChannel channel)
-
loadDataSourceParser
public void loadDataSourceParser(DataSourceParser dataSourceParser)
This method allows full control over which DataSourceParsers are used to parse the DataSource. This method should be called before theanalyze(DataSource)method. DataSourceParsers loaded by this method are used in place of those that are ordinarily loaded via the service provider interface. Use theaddDataSourceParser(DataSourceParser)method to load a DataSourceParser in addition to those loaded by the service provider interface.- Parameters:
dataSourceParser- An implementation of DataSourceParser that will be used to parse the DataSource.
-
addDataSourceParser
public void addDataSourceParser(DataSourceParser dataSourceParser)
Add a DataSourceParser to be used to parse a DataSource. The DataSourceParser will be used in addition to those loaded by the service provider interface. This method should be called before theanalyze(DataSource)method.- Parameters:
dataSourceParser- An implementation of DataSourceParser that will be used to parse the DataSource.
-
analyze
public JavaVirtualMachine analyze(DataSource<?> dataSource) throws IOException
Perform an analysis on a GC log file. The analysis will use the Aggregations that wereregistered, if appropriate for the GC log file.- Parameters:
dataSource- The log to analyze, typically aSingleGCLogFileorRotatingGCLogFile.- Returns:
- a representation of the state of the Java Virtual Machine resulting from the analysis of the GC log file.
- Throws:
IOException- when something goes wrong reading the data source
-
-