java.lang.Object
org.apache.hadoop.hdfs.server.namenode.top.window.RollingWindow

@Private public class RollingWindow extends Object
A class for exposing a rolling window view on the event that occur over time. Events are reported based on occurrence time. The total number of events in the last period covered by the rolling window can be retrieved by the getSum(long) method.

Assumptions:

(1) Concurrent invocation of incAt(long, long) method are possible

(2) The time parameter of two consecutive invocation of incAt(long, long) could be in any given order

(3) The buffering delays are not more than the window length, i.e., after two consecutive invocation incAt(long time1, long) and incAt(long time2, long), time1 < time2 || time1 - time2 < windowLenMs. This assumption helps avoiding unnecessary synchronizations.

Thread-safety is built in the RollingWindow.Bucket

  • Method Summary

    Modifier and Type
    Method
    Description
    long
    getSum(long time)
    Get value represented by this window at the specified time
    void
    incAt(long time, long delta)
    When an event occurs at the specified time, this method reflects that in the rolling window.

    Methods inherited from class java.lang.Object

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

    • incAt

      public void incAt(long time, long delta)
      When an event occurs at the specified time, this method reflects that in the rolling window.

      Parameters:
      time - the time at which the event occurred
      delta - the delta that will be added to the window
    • getSum

      public long getSum(long time)
      Get value represented by this window at the specified time

      If time lags behind the latest update time, the new updates are still included in the sum

      Parameters:
      time -
      Returns:
      number of events occurred in the past period