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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Cleanup no longer needed resources.int
int
int
Increments the number of requests by the given ipAddress in the current time window.void
setDuration
(int duration) Sets the configured duration value in seconds.void
setFilterConfig
(FilterConfig filterConfig) Pass the FilterConfig to configure the filter.void
setRequests
(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:
getDuration
in interfaceRateLimiter
- 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 interfaceRateLimiter
- Parameters:
duration
- The duration of the time window in seconds
-
getRequests
public int getRequests()- Specified by:
getRequests
in interfaceRateLimiter
- 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 interfaceRateLimiter
- Parameters:
requests
- The number of requests per time window
-
increment
Description copied from interface:RateLimiter
Increments the number of requests by the given ipAddress in the current time window.- Specified by:
increment
in interfaceRateLimiter
- 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 interfaceRateLimiter
-
setFilterConfig
Description copied from interface:RateLimiter
Pass the FilterConfig to configure the filter.- Specified by:
setFilterConfig
in interfaceRateLimiter
- Parameters:
filterConfig
- The FilterConfig used to configure the associated filter
-
getBucketCounter
-