Interface Interval

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    EventCounterInterval, SessionCounterInterval

    public interface Interval
    extends Serializable
    An object that counts events occurring during a single time slice within the life of a Metric instance.

    The life of a Metric is conceptually a sequence of non-overlapping intervals. Each Interval has a duration that is a whole number of seconds, and all intervals for a given Metric have a uniform duration. Each Interval has a start time, which can be determined from the start time of the previous Interval of the Metric and its duration.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(int count)
      Registers the occurrence of n new events.
      long getCumulativeEvents()
      Gets the total number of events, including those that occurred in previous intervals.
      long getDuration()
      Gets the duration, in milliseconds, of this Interval
      float getEventRatePerSecond()
      Returns the computed event rate per second during this Interval.
      long getEvents()
      Gets the number of events counted during this interval.
      long getStartTime()
      Gets a timestamp corresponding to the start of this Interval in System.currentTimeMillis() format.
      long intervalsBefore​(long time)
      Returns the number of intervals that have elapsed between this Interval and the time specified by the argument.
      boolean isPast()
      Returns true if the current time is after the end of this interval.
      void setClosed​(boolean closed)
      Marks the interval as open or closed.
    • Method Detail

      • getStartTime

        long getStartTime()
        Gets a timestamp corresponding to the start of this Interval in System.currentTimeMillis() format.
        Returns:
        start time of this Interval
      • getDuration

        long getDuration()
        Gets the duration, in milliseconds, of this Interval
        Returns:
        long - number of seconds
      • getEvents

        long getEvents()
        Gets the number of events counted during this interval.
        Returns:
        number of events
      • getEventRatePerSecond

        float getEventRatePerSecond()
        Returns the computed event rate per second during this Interval.

        If the current time falls within this interval, consider only the time that has passed. Otherwise, consider the entire duration of the interval.

        Returns:
        events per second
      • getCumulativeEvents

        long getCumulativeEvents()
        Gets the total number of events, including those that occurred in previous intervals.
        Returns:
        number of events
      • isPast

        boolean isPast()
        Returns true if the current time is after the end of this interval.
        Returns:
        true if the current time is beyond the end of this interval
      • add

        void add​(int count)
        Registers the occurrence of n new events.

        Intended for internal use only.

        Parameters:
        count - number of events to be counted
      • setClosed

        void setClosed​(boolean closed)
        Marks the interval as open or closed.

        Intended for internal use only. A closed interval is one known to be fully in the past. By flagging an interval as closed, we can calculate such things as the event rate without sampling the clock.

        Parameters:
        closed -
      • intervalsBefore

        long intervalsBefore​(long time)
        Returns the number of intervals that have elapsed between this Interval and the time specified by the argument.
        Parameters:
        time - typically the current time
        Returns:
        number of intervals