Package io.grpc.rls

Class AdaptiveThrottler.TimeBasedAccumulator

java.lang.Object
io.grpc.rls.AdaptiveThrottler.TimeBasedAccumulator
Enclosing class:
AdaptiveThrottler

static final class AdaptiveThrottler.TimeBasedAccumulator extends Object
  • Field Details

    • NUM_SLOTS

      private static final int NUM_SLOTS
      The number of slots. This value determines the accuracy of the get() method to interval / NUM_SLOTS.
      See Also:
    • slots

      The array of slots.
    • interval

      private final long interval
      The time interval this statistic is concerned with.
    • slotNanos

      private final long slotNanos
      The number of nanoseconds in each slot.
    • currentIndex

      private volatile int currentIndex
      The current index into the slot array. currentIndex may be safely read without synchronization, but all writes must be performed inside of a synchronized(this){} block.
    • ticker

      private final com.google.common.base.Ticker ticker
  • Constructor Details

    • TimeBasedAccumulator

      TimeBasedAccumulator(long internalNanos, com.google.common.base.Ticker ticker)
      Interval constructor.
      Parameters:
      internalNanos - is the stat interval in nanoseconds
      Throws:
      IllegalArgumentException - if the supplied interval is too small to be effective
  • Method Details

    • getSlot

      private AdaptiveThrottler.TimeBasedAccumulator.Slot getSlot(long now)
      Gets the current slot.
    • getSlotEndTime

      private long getSlotEndTime(long time)
      Computes the end boundary since the last bucket can be partial size.
      Parameters:
      time - the time for which to find the nearest slot boundary
      Returns:
      the nearest slot boundary in nanos
    • getInterval

      long getInterval()
      Returns the interval used by this statistic.
      Returns:
      the interval
    • increment

      void increment(long now)
      Increments the count of the statistic by the specified amount for the specified time.
      Parameters:
      now - is the time used to increment the count
    • get

      long get(long now)
      Returns the count of the statistic using the specified time value as the current time.
      Parameters:
      now - the current time
      Returns:
      the statistic count
    • toString

      public String toString()
      Overrides:
      toString in class Object