java.lang.Object
io.hypersistence.optimizer.core.event.persistence.RuntimeRollup

public class RuntimeRollup extends Object
The RuntimeRollup is a mutable accumulator that aggregates all the runtime events sharing the same signature within the same time window.

Instead of storing one database row per event occurrence, the aggregator keeps a single RuntimeRollup per (signature, window) pair, tracking the number of occurrences and, when the events expose a duration, the total and maximum durations.

Since:
2.14.0
Author:
Vlad Mihalcea
  • Constructor Details

    • RuntimeRollup

      public RuntimeRollup(String eventName, String signature, String priority, long windowStart, long windowEnd)
  • Method Details

    • record

      public boolean record(Long durationMillis, String description)
      Record a single occurrence into this rollup.
      Parameters:
      durationMillis - the duration of the occurrence, or null if not available
      description - a representative description (kept only for the first occurrence)
      Returns:
      true if the occurrence was recorded, or false if the rollup was already closed, in which case the occurrence must be recorded into a new rollup
    • close

      public void close()
      Close the rollup prior to persisting it, so that its values no longer change and any occurrence recorded concurrently goes into a new rollup instead of being lost.
    • getEventName

      public String getEventName()
    • getSignature

      public String getSignature()
    • getPriority

      public String getPriority()
    • getWindowStart

      public long getWindowStart()
    • getWindowEnd

      public long getWindowEnd()
    • getOccurrenceCount

      public long getOccurrenceCount()
    • getTotalDurationMillis

      public Long getTotalDurationMillis()
      Get the total duration, or null when none of the aggregated events exposed one.
      Returns:
      the total duration in milliseconds, or null
    • getMaxDurationMillis

      public Long getMaxDurationMillis()
      Get the maximum duration, or null when none of the aggregated events exposed one.
      Returns:
      the maximum duration in milliseconds, or null
    • getSampleDescription

      public String getSampleDescription()