Class HitCounter

  • Direct Known Subclasses:
    MaxHitRateTracker

    public class HitCounter
    extends Object
    This hit counter is for counting the number of hits within a range of time. Right now the granularity we use is second. In order to save the space and time, we store the number of hits over the last 100 time buckets. When the method hit gets called, we put the timestamp to the specified bucket. When the method getHitCount gets called, we sum all the number of hits within the last 100 time buckets.
    • Constructor Detail

      • HitCounter

        public HitCounter​(int timeRangeInSeconds)
      • HitCounter

        public HitCounter​(int timeRangeInSeconds,
                          int bucketCount)
    • Method Detail

      • hit

        public void hit()
        Increase the hit count in the current bucket.
      • getHitCount

        public int getHitCount()
        Get the total hit count within a time range.