- java.lang.Object
-
- com.microsoft.gctoolkit.aggregator.Aggregation
-
public abstract class Aggregation extends Object
AnAggregationcollates data from anAggregatorand may be thought of as a view of the data. AnAggregationmight collate data into a time series for plotting, or it might summarize the data. Separating the capture of the data, which is the job of theAggregatorfrom how the data is aggregated, which is the job of theAggregation, allows for multiple views of the data to be built for the sameAggregator.The
Collatesannotation is used to indicate whichAggregatoranAggregationworks with. If anAggregationdoes not have theCollatesannotation, theAggregationwill not be used.An implementation of Aggregation must have a public, no-arg constructor.
Best practice for creating an
Aggregationis to create an interface for the methods theAggregatorwill call. When a GC log is analyzed,JVMEventsare captured by theAggregators. AnAggregatorextracts data from the JVMEvent and calls theAggregationAPI to collate the data.As an example, say one wants to record the pause times of full GCs. An
Aggregationcould present an API that takes the date/time of the event, the cause of the full GC, and the duration of the full GC. TheAggregatorcould capture G1FullGC events and FullGC events. Which event is actually sent to theAggregatordepends on the what kind of GC log file is being parsed.The example FullGCAggregator is annotated with the
@Aggregatesannotation, giving the G1GC and Generational as the event source. This lets GCToolKit know that this Aggregator is capturing events from those sources. Notice also that the constructor of FullGCAggregator registers the JVMEvent types that it is interested in, and gives the method to call for that event type. Lastly, the process method extracts the data from the event and calls the FullGCAggregation API.The implementation of FullGCAggregation can collate the data however desired. MaxFullGCPauseTime is just one example. Notice that the method to get the maximum pause time is defined in MaxFullGCPauseTime, not in FullGCAggregation. This keeps the FullGCAggregation interface from imposing API that some other view (some other Aggregation) of the data might not want or need.
@Collates(FullGCAggregator.class) public interface FullGCAggregation extends Aggregation { void recordFullGC(DateTimeStamp timeStamp, GCCause cause, double pauseTime); } @Aggregates({EventSource.G1GC, EventSource.Generational}) public class FullGCAggregator implements Aggregator<FullGCAggregation> { public FullGCAggregator(FullGCAggregation aggregation) { super(aggregation); register(G1FullGC.class, this::process); register(FullGC.class, this::process); } private void process(GCEvent event) { aggregation().recordFullGC(event.getDateTimeStamp(), event.getGCCause(), event.getDuration()); } } public class MaxFullGCPauseTime implements FullGCAggregation { Map<GCCause, Double> maxPauseTime = new HashMap(); public MaxFullGCPauseTime() {} @Override public void recordFullGC(DateTimeStamp timeStamp, GCCause cause, double pauseTime) { maxPauseTime.compute(cause, (k, v) -> (v == null) ? pauseTime : Math.max(v, pauseTime)); } public double getMaxPauseTime(GCCause cause) { return maxPauseTime.get(cause); } @Override public boolean hasWarning() { return false; } @Override public boolean isEmpty() { return maxPauseTime.isEmpty(); } }- See Also:
JavaVirtualMachine.getAggregation(Class),Collates
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAggregation()Constructor for the module SPI
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Class<? extends Aggregator<?>>collates()Sort if a given Aggregator collates for this aggregation.doubleestimatedRuntime()DateTimeStampestimatedStartTime()Estimates the start time of the log based on the available data.abstract booleanhasWarning()Return true if the Aggregation contains a warning.abstract booleanisEmpty()Returntrueif there is no data in the Aggregation.DateTimeStamptimeOfFirstEvent()voidtimeOfFirstEvent(DateTimeStamp eventTime)DateTimeStamptimeOfTerminationEvent()voidtimeOfTerminationEvent(DateTimeStamp eventTime)Interface to record the time span of the log Estimate based on information carried in the JVMTermination event.voidupdateEventFrequency(JVMEvent event)
-
-
-
Method Detail
-
timeOfFirstEvent
public void timeOfFirstEvent(DateTimeStamp eventTime)
- Parameters:
eventTime- of first event seen
-
timeOfFirstEvent
public DateTimeStamp timeOfFirstEvent()
- Returns:
- time of first event seen
-
timeOfTerminationEvent
public void timeOfTerminationEvent(DateTimeStamp eventTime)
Interface to record the time span of the log Estimate based on information carried in the JVMTermination event.- Parameters:
eventTime- - estimate start time of the log.
-
timeOfTerminationEvent
public DateTimeStamp timeOfTerminationEvent()
- Returns:
- the timestamp reported by the JVM termination record if present otherwise the end of the last event.
-
estimatedStartTime
public DateTimeStamp estimatedStartTime()
Estimates the start time of the log based on the available data.If the first event does not have a timestamp, the method returns the time of the first event minus the variance of GC frequency.
If the timestamp is present and the timestamp of the first event is greater than the variance, the method returns the timestamp minus the variance. However, if the resulting timestamp is negative, the method returns the time of the first event instead, since a negative timestamp is not possible.
- Returns:
- The estimated start time of the log based on the available data
-
estimatedRuntime
public double estimatedRuntime()
- Returns:
- estimate time span represented by the data presented.
-
hasWarning
public abstract boolean hasWarning()
Return true if the Aggregation contains a warning. For example, an Aggregation that looks at GC Cause might returntrueif it finds a System.gc() call.- Returns:
trueif the Aggregation contains a warning.
-
isEmpty
public abstract boolean isEmpty()
Returntrueif there is no data in the Aggregation.- Returns:
trueif there is no data in the Aggregation.
-
collates
public Class<? extends Aggregator<?>> collates()
Sort if a given Aggregator collates for this aggregation.- Returns:
- aggregator
-
updateEventFrequency
public void updateEventFrequency(JVMEvent event)
-
-