Class EventStats

java.lang.Object
io.activej.jmx.stats.EventStats
All Implemented Interfaces:
WithInitializer<EventStats>, JmxRefreshable, JmxRefreshableStats<EventStats>, JmxStats<EventStats>, JmxStatsWithReset, JmxStatsWithSmoothingWindow

Computes total amount of events and dynamic rate using exponential smoothing algorithm

Class is supposed to work in a single thread

  • Method Details

    • createAccumulator

      public static EventStats createAccumulator()
    • create

      public static EventStats create(Duration smoothingWindow)
      Creates new EventStats with specified smoothing window
      Parameters:
      smoothingWindow - in seconds
    • withRateUnit

      public EventStats withRateUnit(String rateUnit)
    • withPrecision

      public EventStats withPrecision(int precision)
    • withScientificNotation

      public EventStats withScientificNotation()
    • resetStats

      public void resetStats()
      Resets rate to zero
      Specified by:
      resetStats in interface JmxStatsWithReset
    • 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:
      refresh in interface JmxRefreshable
    • add

      public void add(EventStats anotherStats)
      Specified by:
      add in interface JmxStats<EventStats>
    • format

      public static String format(long count, double rate, String rateUnit, DecimalFormat decimalFormat)
    • 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

      public Duration getSmoothingWindow()
      Specified by:
      getSmoothingWindow in interface JmxStatsWithSmoothingWindow
    • setSmoothingWindow

      public void setSmoothingWindow(Duration smoothingWindow)
      Specified by:
      setSmoothingWindow in interface JmxStatsWithSmoothingWindow
    • get

      public String get()
    • toString

      public String toString()
      Overrides:
      toString in class Object