Package io.activej.jmx.stats
Class EventStats
java.lang.Object
io.activej.jmx.stats.EventStats
- All Implemented Interfaces:
WithInitializer<EventStats>,JmxRefreshable,JmxRefreshableStats<EventStats>,JmxStats<EventStats>,JmxStatsWithReset,JmxStatsWithSmoothingWindow
public final class EventStats
extends Object
implements JmxRefreshableStats<EventStats>, JmxStatsWithSmoothingWindow, JmxStatsWithReset, WithInitializer<EventStats>
Computes total amount of events and dynamic rate using exponential smoothing algorithm
Class is supposed to work in a single thread
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(EventStats anotherStats) static EventStatsCreates new EventStats with specified smoothing windowstatic EventStatsstatic Stringformat(long count, double rate, String rateUnit, DecimalFormat decimalFormat) get()doubleReturns smoothed value of rate in events per second.longReturns total amount of recorded eventsvoidRecords event and updates ratevoidrecordEvents(int events) Records events and updates ratevoidrefresh(long timestamp) voidResets rate to zerovoidsetSmoothingWindow(Duration smoothingWindow) toString()withPrecision(int precision) withRateUnit(String rateUnit) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.activej.common.initializer.WithInitializer
withInitializer
-
Method Details
-
createAccumulator
-
create
Creates new EventStats with specified smoothing window- Parameters:
smoothingWindow- in seconds
-
withRateUnit
-
withPrecision
-
withScientificNotation
-
resetStats
public void resetStats()Resets rate to zero- Specified by:
resetStatsin interfaceJmxStatsWithReset
-
recordEvent
public void recordEvent()Records event and updates rate -
recordEvents
public void recordEvents(int events) Records events and updates rate- Parameters:
events- number of events
-
refresh
public void refresh(long timestamp) - Specified by:
refreshin interfaceJmxRefreshable
-
add
- Specified by:
addin interfaceJmxStats<EventStats>
-
format
-
getSmoothedRate
public double getSmoothedRate()Returns smoothed value of rate in events per second.Value may be delayed. Last update was performed during
recordEvent()method invocation- Returns:
- smoothed value of rate in events per second
-
getTotalCount
public long getTotalCount()Returns total amount of recorded events- Returns:
- total amount of recorded events
-
getSmoothingWindow
- Specified by:
getSmoothingWindowin interfaceJmxStatsWithSmoothingWindow
-
setSmoothingWindow
- Specified by:
setSmoothingWindowin interfaceJmxStatsWithSmoothingWindow
-
get
-
toString
-