Class Meter

  • All Implemented Interfaces:
    Counting, Metered, Metric

    public class Meter
    extends java.lang.Object
    implements Metered
    A meter metric which measures mean throughput and one-, five-, and fifteen-minute exponentially-weighted moving average throughputs.
    See Also:
    EWMA
    • Constructor Summary

      Constructors 
      Constructor Description
      Meter()
      Creates a new Meter.
      Meter​(Clock clock)
      Creates a new Meter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getCount()
      Returns the number of events which have been marked.
      double getFifteenMinuteRate()
      Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
      double getFiveMinuteRate()
      Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
      double getMeanRate()
      Returns the mean rate at which events have occurred since the meter was created.
      double getOneMinuteRate()
      Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
      void mark()
      Mark the occurrence of an event.
      void mark​(long n)
      Mark the occurrence of a given number of events.
      private void tickIfNecessary()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TICK_INTERVAL

        private static final long TICK_INTERVAL
      • m1Rate

        private final EWMA m1Rate
      • m5Rate

        private final EWMA m5Rate
      • m15Rate

        private final EWMA m15Rate
      • startTime

        private final long startTime
      • lastTick

        private final java.util.concurrent.atomic.AtomicLong lastTick
      • clock

        private final Clock clock
    • Constructor Detail

      • Meter

        public Meter()
        Creates a new Meter.
      • Meter

        public Meter​(Clock clock)
        Creates a new Meter.
        Parameters:
        clock - the clock to use for the meter ticks
    • Method Detail

      • mark

        public void mark()
        Mark the occurrence of an event.
      • mark

        public void mark​(long n)
        Mark the occurrence of a given number of events.
        Parameters:
        n - the number of events
      • tickIfNecessary

        private void tickIfNecessary()
      • getCount

        public long getCount()
        Description copied from interface: Metered
        Returns the number of events which have been marked.
        Specified by:
        getCount in interface Counting
        Specified by:
        getCount in interface Metered
        Returns:
        the number of events which have been marked
      • getFifteenMinuteRate

        public double getFifteenMinuteRate()
        Description copied from interface: Metered
        Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.

        This rate has the same exponential decay factor as the fifteen-minute load average in the top Unix command.

        Specified by:
        getFifteenMinuteRate in interface Metered
        Returns:
        the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
      • getFiveMinuteRate

        public double getFiveMinuteRate()
        Description copied from interface: Metered
        Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.

        This rate has the same exponential decay factor as the five-minute load average in the top Unix command.

        Specified by:
        getFiveMinuteRate in interface Metered
        Returns:
        the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
      • getMeanRate

        public double getMeanRate()
        Description copied from interface: Metered
        Returns the mean rate at which events have occurred since the meter was created.
        Specified by:
        getMeanRate in interface Metered
        Returns:
        the mean rate at which events have occurred since the meter was created
      • getOneMinuteRate

        public double getOneMinuteRate()
        Description copied from interface: Metered
        Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.

        This rate has the same exponential decay factor as the one-minute load average in the top Unix command.

        Specified by:
        getOneMinuteRate in interface Metered
        Returns:
        the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created