Class EventCounterInterval

    • Field Detail

      • events

        protected volatile long events
        Number of events that have been counted in this interval
    • Constructor Detail

      • EventCounterInterval

        public EventCounterInterval()
      • EventCounterInterval

        public EventCounterInterval​(long inDuration,
                                    long inStartTime)
        Constructs a new EventCounterInterval.

        This constructor is not public because Intervals are constructed only via Metric according to the Abstract Factory design pattern.

        Parameters:
        inDuration - - length of this interval
        inStartTime - - time stamp of the first millisecond of the interval
    • Method Detail

      • getDuration

        public long getDuration()
        Description copied from interface: Interval
        Gets the duration, in milliseconds, of this Interval
        Specified by:
        getDuration in interface Interval
        Returns:
        long - number of seconds
      • getStartTime

        public long getStartTime()
        Description copied from interface: Interval
        Gets a timestamp corresponding to the start of this Interval in System.currentTimeMillis() format.
        Specified by:
        getStartTime in interface Interval
        Returns:
        start time of this Interval
      • getEventRatePerSecond

        public float getEventRatePerSecond()
        Description copied from interface: Interval
        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.

        Specified by:
        getEventRatePerSecond in interface Interval
        Returns:
        events per second
      • getEvents

        public long getEvents()
        Description copied from interface: Interval
        Gets the number of events counted during this interval.
        Specified by:
        getEvents in interface Interval
        Returns:
        number of events
      • getCumulativeEvents

        public long getCumulativeEvents()
        Description copied from interface: Interval
        Gets the total number of events, including those that occurred in previous intervals.
        Specified by:
        getCumulativeEvents in interface Interval
        Returns:
        number of events
      • add

        public void add​(int inCount)
        Description copied from interface: Interval
        Registers the occurrence of n new events.

        Intended for internal use only.

        Specified by:
        add in interface Interval
        Parameters:
        inCount - number of events to be counted
      • setClosed

        public void setClosed​(boolean closed)
        Description copied from interface: Interval
        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.

        Specified by:
        setClosed in interface Interval
      • isPast

        public boolean isPast()
        Description copied from interface: Interval
        Returns true if the current time is after the end of this interval.
        Specified by:
        isPast in interface Interval
        Returns:
        true if the current time is beyond the end of this interval
      • intervalsBefore

        public long intervalsBefore​(long inTime)
        Returns the number of intervals that have elapsed between this Interval and the time specified by the argument.

        The argument is typically a recently-noted timestamp.

        Specified by:
        intervalsBefore in interface Interval
        Parameters:
        inTime - - reference point in time
        Returns:
        long - number of intervals
      • toString

        public String toString()
        Summarizes this Interval as a String for display purposes.
        Overrides:
        toString in class Object
        Returns:
        String summary