Class RuntimeEventAggregator
java.lang.Object
io.hypersistence.optimizer.core.event.persistence.RuntimeEventAggregator
The
RuntimeEventAggregator rolls up runtime events into time windows so that a slow
operation triggered many times is summarized as a handful of rows (one per window) carrying an
occurrence count and, when available, the total and maximum durations, rather than one row per
occurrence.
The aggregator is thread-safe: runtime events arrive from many application threads, while a
single background thread periodically flushes the windows that have closed. On JVM shutdown, or
when stop() is called, any remaining windows are flushed as well.
- Since:
- 2.14.0
- Author:
- Vlad Mihalcea
-
Constructor Summary
ConstructorsConstructorDescriptionRuntimeEventAggregator(EventPersistenceSettings settings, EventStore eventStore) -
Method Summary
Modifier and TypeMethodDescriptionvoidflushAll()Flush all windows, regardless of whether they have closed.voidflushClosedWindows(long referenceMillis) Flush every window whose end time is at or before the provided reference time.longGet the number of runtime events that were dropped because the signature cap was reached.voidRecord a single runtime event into the current time window.voidstart()Start the background flush scheduler and register the JVM shutdown hook.voidstop()Stop the aggregator, flushing any remaining windows.
-
Constructor Details
-
RuntimeEventAggregator
-
-
Method Details
-
start
public void start()Start the background flush scheduler and register the JVM shutdown hook. -
record
Record a single runtime event into the current time window.- Parameters:
event- the runtimeEvent
-
flushClosedWindows
public void flushClosedWindows(long referenceMillis) Flush every window whose end time is at or before the provided reference time.- Parameters:
referenceMillis- the reference time in milliseconds
-
flushAll
public void flushAll()Flush all windows, regardless of whether they have closed. -
stop
public void stop()Stop the aggregator, flushing any remaining windows. -
getDroppedCount
public long getDroppedCount()Get the number of runtime events that were dropped because the signature cap was reached.- Returns:
- the dropped count
-