Class SlidingWindow<T>

java.lang.Object
org.apache.dubbo.metrics.aggregate.SlidingWindow<T>
Type Parameters:
T - Value type for window statistics.
Direct Known Subclasses:
TimeWindowAggregator.SnapshotSlidingWindow

public abstract class SlidingWindow<T> extends Object
SlidingWindow adopts sliding window algorithm for statistics.

A window contains paneCount panes, intervalInMs = paneCount * paneIntervalInMs

  • Method Summary

    Modifier and Type
    Method
    Description
    Get the pane at the current timestamp.
    currentPane(long timeMillis)
    Get the pane at the specified timestamp in milliseconds.
    long
    Get total interval of the sliding window in milliseconds.
    long
    Get pane interval of the sliding window in milliseconds.
    getPaneValue(long timeMillis)
    Get statistic value from pane at the specified timestamp.
    boolean
    isPaneDeprecated(long timeMillis, Pane<T> pane)
    Checks if the specified pane is deprecated at the specified timestamp.
    boolean
    Checks if the specified pane is deprecated at the current timestamp.
    Get valid pane list for entire sliding window at the current time.
    list(long timeMillis)
    Get valid pane list for entire sliding window at the specified time.
    abstract T
    newEmptyValue(long timeMillis)
    Create a new statistic value for pane.
    Get aggregated value list for entire sliding window at the current time.
    values(long timeMillis)
    Get aggregated value list for entire sliding window at the specified time.

    Methods inherited from class java.lang.Object

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

    • currentPane

      public Pane<T> currentPane()
      Get the pane at the current timestamp.
      Returns:
      the pane at current timestamp.
    • currentPane

      public Pane<T> currentPane(long timeMillis)
      Get the pane at the specified timestamp in milliseconds.
      Parameters:
      timeMillis - a timestamp in milliseconds.
      Returns:
      the pane at the specified timestamp if the time is valid; null if time is invalid.
    • getPaneValue

      public T getPaneValue(long timeMillis)
      Get statistic value from pane at the specified timestamp.
      Parameters:
      timeMillis - the specified timestamp in milliseconds.
      Returns:
      the statistic value if pane at the specified timestamp is up-to-date; otherwise null.
    • newEmptyValue

      public abstract T newEmptyValue(long timeMillis)
      Create a new statistic value for pane.
      Parameters:
      timeMillis - the specified timestamp in milliseconds.
      Returns:
      new empty statistic value.
    • isPaneDeprecated

      public boolean isPaneDeprecated(Pane<T> pane)
      Checks if the specified pane is deprecated at the current timestamp.
      Parameters:
      pane - the specified pane.
      Returns:
      true if the pane is deprecated; otherwise false.
    • isPaneDeprecated

      public boolean isPaneDeprecated(long timeMillis, Pane<T> pane)
      Checks if the specified pane is deprecated at the specified timestamp.
      Parameters:
      timeMillis - the specified time.
      pane - the specified pane.
      Returns:
      true if the pane is deprecated; otherwise false.
    • list

      public List<Pane<T>> list()
      Get valid pane list for entire sliding window at the current time. The list will only contain "valid" panes.
      Returns:
      valid pane list for entire sliding window.
    • list

      public List<Pane<T>> list(long timeMillis)
      Get valid pane list for entire sliding window at the specified time. The list will only contain "valid" panes.
      Parameters:
      timeMillis - the specified time.
      Returns:
      valid pane list for entire sliding window.
    • values

      public List<T> values()
      Get aggregated value list for entire sliding window at the current time. The list will only contain value from "valid" panes.
      Returns:
      aggregated value list for entire sliding window.
    • values

      public List<T> values(long timeMillis)
      Get aggregated value list for entire sliding window at the specified time. The list will only contain value from "valid" panes.
      Returns:
      aggregated value list for entire sliding window.
    • getIntervalInMs

      public long getIntervalInMs()
      Get total interval of the sliding window in milliseconds.
      Returns:
      the total interval in milliseconds.
    • getPaneIntervalInMs

      public long getPaneIntervalInMs()
      Get pane interval of the sliding window in milliseconds.
      Returns:
      the interval of a pane in milliseconds.