Class RetryCountSlidingWindow


  • public class RetryCountSlidingWindow
    extends java.lang.Object
    A Sliding Window implementation that is implemented as followed: 1. Each thread maintains a ThreadLocal queue to count certain metric by removing the data that is out of the time range. 2. A dedicated thread collected the counts from those ThreadLocalQueue and sum them up into a thread-safe counter periodically Since the internal ThreadLocal instance is not a static one. Please do not create more than one RetryCountSlidingWindow. And please refer to the explanation just right above the ThreadLocal instance for why we made it a non-static variable.
    • Constructor Summary

      Constructors 
      Constructor Description
      RetryCountSlidingWindow​(int updateIntervalMs, int slidingWindowLengthInSecond, java.util.concurrent.ScheduledExecutorService updateExecutor)  
    • Constructor Detail

      • RetryCountSlidingWindow

        public RetryCountSlidingWindow​(int updateIntervalMs,
                                       int slidingWindowLengthInSecond,
                                       java.util.concurrent.ScheduledExecutorService updateExecutor)
    • Method Detail

      • getRetryRatio

        public double getRetryRatio()
      • getTotalCount

        public long getTotalCount()
      • getRetryCount

        public long getRetryCount()
      • getQueue

        public CounterQueue<RetryCounter> getQueue()
        Return a ThreadLocal Queue for I/O workers to keep counting retriy request count and total count.
        Returns: