Package com.linkedin.alpini.base.misc
Class RetryCountSlidingWindow
- java.lang.Object
-
- com.linkedin.alpini.base.misc.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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CounterQueue<RetryCounter>
getQueue()
Return a ThreadLocal Queue for I/O workers to keep counting retriy request count and total count.long
getRetryCount()
double
getRetryRatio()
long
getTotalCount()
-
-
-
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:
-
-