Package org.apache.catalina.util
Class FastRateLimiter
java.lang.Object
org.apache.catalina.util.FastRateLimiter
- All Implemented Interfaces:
RateLimiter
A RateLimiter that compromises accuracy for speed in order to provide maximum throughput.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Cleanup no longer needed resources.intintintIncrements 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.
-
Constructor Details
-
FastRateLimiter
public FastRateLimiter()
-
-
Method Details
-
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
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
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
-