Class RuntimeAggregation

  • All Implemented Interfaces:
    Aggregation
    Direct Known Subclasses:
    PauseTimeAggregation

    public class RuntimeAggregation
    extends Object
    implements Aggregation
    An Aggregation that collates runtime data. This class is meant to be extended by other implementations that need access to runtime data to perform calculations.

    The following code shows recommended practice for using this Aggregation. The example uses RuntimeAggregation to calculate the ratio of pause time to runtime duration for a G1GC log.

    
     @Collates(G1PauseTimeAggregator.class)
     public abstract class G1PauseTimeAggregation extends RuntimeAggregation {
          public abstract void recordPause(double pauseTime);
     }
    
     @Aggregates({EventSource.G1GC)
     public class G1PauseTimeAggregator extends RuntimeAggregator<G1PauseTimeAggregation> {
    
         public G1PauseTimeAggregator(G1PauseTimeAggregation aggregation) {
             super(aggregation);
             register(G1RealPause.class, this::process);
         }
    
          private void process(G1RealPause event) {
              aggregation().recordPause(event.getDuration());
          }
     }
    
     public class G1PauseTimeRatio extends G1PauseTimeAggregation {
    
         long totalPauseTime;
    
         public MaxFullGCPauseTime() {}
    
         @Override
         public void recordPause(double pauseTime) {
             totalPauseTime += pauseTime;
         }
    
         public double getPauseTimeRatio() {
             return getRuntimeDuration() > 0.0 ? totalPauseTime / getRuntimeDuration() : 0.0;
         }
    
         @Override
         public boolean hasWarning() { return false; }
    
         @Override
         public boolean isEmpty() { return getRuntimeDuration() <= 0.0; }
     }
     
    • Constructor Detail

      • RuntimeAggregation

        public RuntimeAggregation()
        This class is meant to be extended.
    • Method Detail

      • record

        public void record​(DateTimeStamp eventTime,
                           double duration)
        RuntimeAggregation collates the time of an event and the duration of the event.
        Parameters:
        eventTime - The time a JVMEvent occurred.
        duration - The duration of the JVMEvent.
      • getTimeOfFirstEvent

        public DateTimeStamp getTimeOfFirstEvent()
        Return the time of the first event of the GC log.
        Returns:
        The time of the first event.
      • getTimeOfLastEvent

        public DateTimeStamp getTimeOfLastEvent()
        Return the time of the last event of the GC log. Note well! The time of the last event is not the start time of the event, but is the time the event ended (event start time plus the event duration).
        Returns:
        The time of the last event.
      • getRuntimeDuration

        public double getRuntimeDuration()
        Return the duration of the GC log. Fundamentally, this is the difference between the time of the last event and the time of the first event.
        Returns:
        The duration of the JVM runtime represented by the log.