Module com.microsoft.gctoolkit.api
Package com.microsoft.gctoolkit.jvm
Class AbstractJavaVirtualMachine
- java.lang.Object
-
- com.microsoft.gctoolkit.jvm.AbstractJavaVirtualMachine
-
- All Implemented Interfaces:
JavaVirtualMachine
- Direct Known Subclasses:
PreUnifiedJavaVirtualMachine,UnifiedJavaVirtualMachine
public abstract class AbstractJavaVirtualMachine extends Object implements JavaVirtualMachine
The base implementation of JavaVirtualMachine that uses the message API to feed lines to the parser(s) and post events to the aggregators.
-
-
Constructor Summary
Constructors Constructor Description AbstractJavaVirtualMachine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalyze(List<Aggregator<? extends Aggregation>> registeredAggregators, JVMEventChannel eventBus, DataSourceChannel dataSourceBus)Orchestrate the analysis of a GC log.<T extends Aggregation>
Optional<T>getAggregation(Class<T> aggregationClass)Return theAggregationthat was used in the analysis of the GC log file that is the same class asaggregationClass.StringgetCommandLine()Return the command line used to run the JVM, if available.DateTimeStampgetEstimatedJVMStartTime()If the first event is significantly distant from zero in relation to the time intervals between the of the next N events, where N maybe 1, then this is likely a log fragment and not the start of the run.DateTimeStampgetJVMTerminationTime()JVM termination time will be one of either, the time stamp in the termination event if present or, the time of the last event + that events duration.doublegetRuntimeDuration()Return the runtime duration.DateTimeStampgetTimeOfFirstEvent()Return the time of the first event in the GC log file.booleanisCMS()Returntrueif the JVM was using CMS GC.booleanisG1GC()Returntrueif the JVM was using G1GC.booleanisParallel()Returntrueif the JVM was using Parallel GC.booleanisSerial()Returntrueif the JVM was using Serial GC.booleanisShenandoah()Returntrueif the JVM was using Shenandoah.booleanisZGC()Returntrueif the JVM was using ZGC.voidsetDataSource(DataSource logFile)Sets the data sourcevoidsetEstimatedJVMStartTime(DateTimeStamp estimatedStartTime)Sets the estimated start time as calculated by the Aggregation class-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microsoft.gctoolkit.jvm.JavaVirtualMachine
accepts, isUnifiedLogging
-
-
-
-
Method Detail
-
setDataSource
public void setDataSource(DataSource logFile) throws IOException
Sets the data source- Parameters:
logFile- is the source of GC logging data- Throws:
IOException- if there is any issues reading from the data source.
-
isG1GC
public boolean isG1GC()
Description copied from interface:JavaVirtualMachineReturntrueif the JVM was using G1GC.- Specified by:
isG1GCin interfaceJavaVirtualMachine- Returns:
trueif the GC is G1GC.
-
isZGC
public boolean isZGC()
Description copied from interface:JavaVirtualMachineReturntrueif the JVM was using ZGC.- Specified by:
isZGCin interfaceJavaVirtualMachine- Returns:
trueif the GC is ZGC.
-
isShenandoah
public boolean isShenandoah()
Description copied from interface:JavaVirtualMachineReturntrueif the JVM was using Shenandoah.- Specified by:
isShenandoahin interfaceJavaVirtualMachine- Returns:
trueif the GC is Shenandoah.
-
isParallel
public boolean isParallel()
Description copied from interface:JavaVirtualMachineReturntrueif the JVM was using Parallel GC.- Specified by:
isParallelin interfaceJavaVirtualMachine- Returns:
trueif the GC is Parallel GC.
-
isSerial
public boolean isSerial()
Description copied from interface:JavaVirtualMachineReturntrueif the JVM was using Serial GC.- Specified by:
isSerialin interfaceJavaVirtualMachine- Returns:
trueif the GC is Serial GC.
-
isCMS
public boolean isCMS()
Description copied from interface:JavaVirtualMachineReturntrueif the JVM was using CMS GC.- Specified by:
isCMSin interfaceJavaVirtualMachine- Returns:
trueif the GC is CMS GC.
-
getCommandLine
public String getCommandLine()
Description copied from interface:JavaVirtualMachineReturn the command line used to run the JVM, if available.- Specified by:
getCommandLinein interfaceJavaVirtualMachine- Returns:
- The command line used to run the JVM, or
null
-
getTimeOfFirstEvent
public DateTimeStamp getTimeOfFirstEvent()
Description copied from interface:JavaVirtualMachineReturn the time of the first event in the GC log file.- Specified by:
getTimeOfFirstEventin interfaceJavaVirtualMachine- Returns:
- The time of the last event.
-
getEstimatedJVMStartTime
public DateTimeStamp getEstimatedJVMStartTime()
If the first event is significantly distant from zero in relation to the time intervals between the of the next N events, where N maybe 1, then this is likely a log fragment and not the start of the run.Try to estimate the time at which the JVM started. For log fragments, this will be the time of the first event in the log. Otherwise it will be 0.000 seconds.
- Specified by:
getEstimatedJVMStartTimein interfaceJavaVirtualMachine- Returns:
- DateTimeStamp as estimated start time.
-
setEstimatedJVMStartTime
public void setEstimatedJVMStartTime(DateTimeStamp estimatedStartTime)
Sets the estimated start time as calculated by the Aggregation class- Parameters:
estimatedStartTime- as calculated from observations of the event timing in the gc log.
-
getJVMTerminationTime
public DateTimeStamp getJVMTerminationTime()
JVM termination time will be one of either, the time stamp in the termination event if present or, the time of the last event + that events duration.- Specified by:
getJVMTerminationTimein interfaceJavaVirtualMachine- Returns:
- DateTimeStamp
-
getRuntimeDuration
public double getRuntimeDuration()
Description copied from interface:JavaVirtualMachineReturn the runtime duration. This is not necessarily the difference between the first and last event. Rather, this calculation considers the duration of the events.- Specified by:
getRuntimeDurationin interfaceJavaVirtualMachine- Returns:
- The runtime duration that the GC log represents.
-
getAggregation
public <T extends Aggregation> Optional<T> getAggregation(Class<T> aggregationClass)
Description copied from interface:JavaVirtualMachineReturn theAggregationthat was used in the analysis of the GC log file that is the same class asaggregationClass. In other words,aggregationClassis a key used to look up an instance of theAggregation. The return value may benullif theAggregationwas not used in the analysis. WhichAggregations are used depends on the GC.- Specified by:
getAggregationin interfaceJavaVirtualMachine- Type Parameters:
T- type cast for the Aggregation class type.- Parameters:
aggregationClass- The class of the Aggregation to be returned.- Returns:
- an
AggregationwhosegetClass() == aggregationClass, ornullif given aggregationClass is not available.
-
analyze
public void analyze(List<Aggregator<? extends Aggregation>> registeredAggregators, JVMEventChannel eventBus, DataSourceChannel dataSourceBus)
Orchestrate the analysis of a GC log. Step wise 1. find the aggregators that aggregate events generated by the gc log 2. Register the aggregators with the message bus. Setup a callback so the message framework. 3. Stream the data to a publisher 4. Wait until all the aggregators have completed 5. Set the start and end times 6. Return to the caller- Specified by:
analyzein interfaceJavaVirtualMachine- Parameters:
registeredAggregators- all of the aggregations loaded by the module SPIeventBus- the bus to publish events ondataSourceBus- the bus that raw log lines are published on
-
-