Class FastRateLimiter

java.lang.Object
org.apache.catalina.util.FastRateLimiter
All Implemented Interfaces:
RateLimiter

public class FastRateLimiter extends Object implements RateLimiter
A RateLimiter that compromises accuracy for speed in order to provide maximum throughput.
  • Constructor Details

    • FastRateLimiter

      public FastRateLimiter()
  • Method Details

    • getPolicyName

      public String getPolicyName()
      Specified by:
      getPolicyName in interface RateLimiter
      Returns:
      name of RateLimit policy
    • setPolicyName

      public void setPolicyName(String name)
      Description copied from interface: RateLimiter
      Sets the policy name, otherwise an auto-generated name is used.
      Specified by:
      setPolicyName in interface RateLimiter
      Parameters:
      name - of rate limit policy
    • getDuration

      public int getDuration()
      Specified by:
      getDuration in interface RateLimiter
      Returns:
      the actual duration of a time window in seconds
    • setDuration

      public void setDuration(int duration)
      Description copied from interface: RateLimiter
      Sets the configured duration value in seconds.
      Specified by:
      setDuration in interface RateLimiter
      Parameters:
      duration - The duration of the time window in seconds
    • getRequests

      public int getRequests()
      Specified by:
      getRequests in interface RateLimiter
      Returns:
      the maximum number of requests allowed per time window
    • setRequests

      public void setRequests(int requests)
      Description copied from interface: RateLimiter
      Sets the configured number of requests allowed per time window.
      Specified by:
      setRequests in interface RateLimiter
      Parameters:
      requests - The number of requests per time window
    • increment

      public int increment(String ipAddress)
      Description copied from interface: RateLimiter
      Increments the number of requests by the given ipAddress in the current time window.
      Specified by:
      increment in interface RateLimiter
      Parameters:
      ipAddress - the ip address
      Returns:
      the new value after incrementing
    • destroy

      public void destroy()
      Description copied from interface: RateLimiter
      Cleanup no longer needed resources.
      Specified by:
      destroy in interface RateLimiter
    • setFilterConfig

      public void setFilterConfig(FilterConfig filterConfig)
      Description copied from interface: RateLimiter
      Pass the FilterConfig to configure the filter.
      Specified by:
      setFilterConfig in interface RateLimiter
      Parameters:
      filterConfig - The FilterConfig used to configure the associated filter
    • getBucketCounter

      public TimeBucketCounter getBucketCounter()