Package org.apache.catalina.util
Class FastRateLimiter
- java.lang.Object
-
- org.apache.catalina.util.FastRateLimiter
-
- All Implemented Interfaces:
RateLimiter
public class FastRateLimiter extends java.lang.Object implements RateLimiter
A RateLimiter that compromises accuracy for speed in order to provide maximum throughput.
-
-
Constructor Summary
Constructors Constructor Description FastRateLimiter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Cleanup no longer needed resources.TimeBucketCountergetBucketCounter()intgetDuration()intgetRequests()intincrement(java.lang.String ipAddress)Increments the number of requests by the given ipAddress in the current time window.voidsetDuration(int duration)Sets the configured duration value in seconds.voidsetFilterConfig(FilterConfig filterConfig)Pass the FilterConfig to configure the filter.voidsetRequests(int requests)Sets the configured number of requests allowed per time window.
-
-
-
Method Detail
-
getDuration
public int getDuration()
- Specified by:
getDurationin interfaceRateLimiter- Returns:
- the actual duration of a time window in seconds
-
setDuration
public void setDuration(int duration)
Description copied from interface:RateLimiterSets the configured duration value in seconds.- Specified by:
setDurationin interfaceRateLimiter- Parameters:
duration- The duration of the time window in seconds
-
getRequests
public int getRequests()
- Specified by:
getRequestsin interfaceRateLimiter- Returns:
- the maximum number of requests allowed per time window
-
setRequests
public void setRequests(int requests)
Description copied from interface:RateLimiterSets the configured number of requests allowed per time window.- Specified by:
setRequestsin interfaceRateLimiter- Parameters:
requests- The number of requests per time window
-
increment
public int increment(java.lang.String ipAddress)
Description copied from interface:RateLimiterIncrements the number of requests by the given ipAddress in the current time window.- Specified by:
incrementin interfaceRateLimiter- Parameters:
ipAddress- the ip address- Returns:
- the new value after incrementing
-
destroy
public void destroy()
Description copied from interface:RateLimiterCleanup no longer needed resources.- Specified by:
destroyin interfaceRateLimiter
-
setFilterConfig
public void setFilterConfig(FilterConfig filterConfig)
Description copied from interface:RateLimiterPass the FilterConfig to configure the filter.- Specified by:
setFilterConfigin interfaceRateLimiter- Parameters:
filterConfig- The FilterConfig used to configure the associated filter
-
getBucketCounter
public TimeBucketCounter getBucketCounter()
-
-