Class EventRateSlidingWindow


  • public class EventRateSlidingWindow
    extends SlidingWindow<Void,​AtomicInteger,​Long>
    A simple sliding window used for calculating events rate in a given time frame
    Author:
    Eyal Schneider
    • Constructor Detail

    • Method Detail

      • clearRecord

        protected void clearRecord​(AtomicInteger record)
        Description copied from class: SlidingWindow
        clears a given record by resetting its data. It is up to the implementation to decide how to deal with data consistency in case of a concurrent query that inspects that record. It is highly unlikely that an event is registered in the record during this operation.
        Specified by:
        clearRecord in class SlidingWindow<Void,​AtomicInteger,​Long>
      • query

        protected Long query​(AtomicInteger[] records)
        Specified by:
        query in class SlidingWindow<Void,​AtomicInteger,​Long>
        Parameters:
        records - the array of records to inspect. Ordered from oldest to newest.
        Returns:
        The query result, relevant for the time period covered by the given lookback.
      • query

        public float query​(TimeUnit timeUnit)
        Parameters:
        timeUnit - a time unit
        Returns:
        The rate measured by this sliding window, in events per single time unit