Class MovingAverage<T>

java.lang.Object
org.apache.hadoop.hbase.util.MovingAverage<T>
Direct Known Subclasses:
SimpleMovingAverage, WindowMovingAverage

@Private public abstract class MovingAverage<T> extends Object
The purpose of introduction of MovingAverage mainly is to measure execution time of a specific method, which can help us to know its performance fluctuation in response to different machine states or situations, better case, then to act accordingly.
In different situation, different MovingAverage algorithm can be used based on needs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract double
    Get average execution time of the measured method.
    measure(TimeMeasurable<T> measurable)
    Measure elapsed time of a measurable method.
    protected long
    Mark start time of an execution.
    protected long
    stop(long startTime)
    Mark end time of an execution, and return its interval.
    protected abstract void
    updateMostRecentTime(long elapsed)
    Update the most recent data.

    Methods inherited from class java.lang.Object

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

    • LOG

      private static final org.slf4j.Logger LOG
    • label

      protected final String label
  • Constructor Details

  • Method Details

    • start

      protected long start()
      Mark start time of an execution.
      Returns:
      time in ns.
    • stop

      protected long stop(long startTime)
      Mark end time of an execution, and return its interval.
      Parameters:
      startTime - start time of an execution
      Returns:
      elapsed time
    • measure

      public T measure(TimeMeasurable<T> measurable)
      Measure elapsed time of a measurable method.
      Parameters:
      measurable - method implements TimeMeasurable
      Returns:
      T it refers to the original return type of the measurable method
    • updateMostRecentTime

      protected abstract void updateMostRecentTime(long elapsed)
      Update the most recent data.
      Parameters:
      elapsed - elapsed time of the most recent measurement
    • getAverageTime

      public abstract double getAverageTime()
      Get average execution time of the measured method.
      Returns:
      average time in ns