Class EventCounter

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    SessionCounter

    public class EventCounter
    extends Metric
    This class is used to count and observe the frequency of events.

    An EventCounter treats events as instantaneous, happening at a specific point in time and with no observable duration. For observing events that have both frequency and duration, consider a SessionCounter.

    See Also:
    Serialized Form
    • Constructor Detail

      • EventCounter

        public EventCounter()
      • EventCounter

        public EventCounter​(String inLabel,
                            int inIntervalSeconds)
        Constructs an EventCounter with a specific interval duration.
        Parameters:
        inLabel - descriptive String used in reporting
        inIntervalSeconds - int duration of each interval in seconds
      • EventCounter

        public EventCounter​(String inLabel)
        Constructs a new EventCounter with an interval duration of 1 second.
        Parameters:
        inLabel - descriptive String used in reporting
    • Method Detail

      • getEventCounter

        public static EventCounter getEventCounter​(String inLabel)
        Get an instance of an EventCounter with a particular label from the MetricRepository, creating one if necessary.
        Parameters:
        inLabel - Description of the Parameter
        Returns:
        The eventCounter value
      • getCurrentInterval

        public Interval getCurrentInterval()
        Gets the current Interval, the one to which current events are added.
        Returns:
        Interval - the current interval
      • getPeakEventsInterval

        public EventCounterInterval getPeakEventsInterval()
        Gets the interval in which the greatest number of events were added.
        Returns:
        Interval - having the greatest getEvents()
      • getPeakEvents

        public long getPeakEvents()
        Gets the number of events that occurred during the interval in which the most events occurred. A convenience method equivalent to getPeakEventsInterval().getEvents()
        Returns:
        The peakEvents value
      • getCount

        public long getCount()
        Description copied from class: Metric
        Gets the total count of events.
        Specified by:
        getCount in class Metric
        Returns:
        count
      • getCumulativeEvents

        public long getCumulativeEvents()
        Equivalent to getCount(), gets the total number of events added to this EventCounter.
        Returns:
        total number of events
      • getCumulativeFreq

        public float getCumulativeFreq()
        Gets the overall event frequency for this EventCounter
        Returns:
        float - events per second
      • getCurrentFreq

        public float getCurrentFreq()
        Gets the current event frequency for this EventCounter. The calculation includes the current incomplete interval. In order to reduce excessive fluctuations when the current interval has just begun, the immediately preceding interval, if one exists, is also included in the calculation.
        Returns:
        float - events per second
      • add

        public void add​(int inCount)
        Adds a number events.

        All events are considered to have happened now simultaneously.

        Specified by:
        add in class Metric
        Parameters:
        inCount - number of events counted by this call
      • normalize

        public void normalize()
        Normalizes this EventCounter if necessary. An EventCounter is considered to be normalized if the current time falls within the time span implied by the currentInterval. Once enough time has elapsed for the currentInterval to be outdated, then normalize() closes it and opens up a new currentInterval.
      • normalizeCurrent_ScenarioA

        protected void normalizeCurrent_ScenarioA()
      • normalizePrior_ScenarioA

        protected void normalizePrior_ScenarioA()
      • normalizeCurrent_ScenarioB

        protected void normalizeCurrent_ScenarioB()
      • normalizePrior_ScenarioB

        protected void normalizePrior_ScenarioB​(long nEmptyIntervals)
      • reset

        public void reset()
        Reset this EventCounter to its "zero" condition so that it can be reused, avoiding the overhead of constructing a new instance.
        Overrides:
        reset in class Metric
      • createIntervals

        protected void createIntervals()