Class CounterQueue<T extends RetryCounter>


  • public class CounterQueue<T extends RetryCounter>
    extends java.lang.Object
    A queue implemented with a circular buffer of AtomicReferences Example of using: 1. Initializing a SlidingWindow: RetryCountSlidingWindow w = new RetryCountSlidingWindow(500, _windowLen, scheduler); 2. Inside a thread, usually an io worker to get a queue: CounterQueue q = w.getQueue(); 3. increase the count: q.increaseCount(isRetry); For more examples, please refer to the class of TestRetryCountSlidingWindow
    • Constructor Summary

      Constructors 
      Constructor Description
      CounterQueue​(int queueLength, java.util.Map<java.lang.String,​CounterQueue<T>> queueMap, java.util.function.Supplier<T> retryCounterSupplier)
      Initialize the queue and register itself to the queue map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getTotalCount()  
      long getTotalRetryCount()  
      void increaseCount​(boolean isRetry)
      Non-thread safe method but it would only be called by a single thread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CounterQueue

        public CounterQueue​(int queueLength,
                            java.util.Map<java.lang.String,​CounterQueue<T>> queueMap,
                            java.util.function.Supplier<T> retryCounterSupplier)
        Initialize the queue and register itself to the queue map.
        Parameters:
        queueLength -
        retryCounterSupplier -
    • Method Detail

      • getTotalCount

        public long getTotalCount()
      • getTotalRetryCount

        public long getTotalRetryCount()
      • increaseCount

        public void increaseCount​(boolean isRetry)
        Non-thread safe method but it would only be called by a single thread. So the increment of _index does not have to be protected by AtomicReference. A volatile suffices.
        Parameters:
        isRetry -