Class RateLimiterBase
java.lang.Object
org.apache.catalina.util.RateLimiterBase
- All Implemented Interfaces:
- RateLimiter
- Direct Known Subclasses:
- ExactRateLimiter,- FastRateLimiter
Base implementation of 
RateLimiter, provides runtime data maintenance mechanism monitor.- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoiddestroy()Cleanup no longer needed resources.Returns the internal instance ofTimeBucketCounterBase.protected abstract StringIf policy name has not been specified, the first call ofgetPolicyName()returns an auto-generated policy name using the default policy name as prefix and followed by auto-increase index.intintintIncrements the number of requests by the given identifier in the current time window.protected abstract TimeBucketCounterBasenewCounterInstance(int duration, ScheduledExecutorService utilityExecutor) Instantiate an instance ofTimeBucketCounterBasefor specific time bucket size.voidsetDuration(int duration) Sets the configured duration value in seconds.voidsetFilterConfig(FilterConfig filterConfig) Pass the FilterConfig to configure the filter.voidsetPolicyName(String name) Sets the policy name, otherwise an auto-generated name is used.voidsetRequests(int requests) Sets the configured number of requests allowed per time window.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.catalina.util.RateLimitergetPolicy, getQuota
- 
Constructor Details- 
RateLimiterBasepublic RateLimiterBase()
 
- 
- 
Method Details- 
getDefaultPolicyNameIf policy name has not been specified, the first call ofgetPolicyName()returns an auto-generated policy name using the default policy name as prefix and followed by auto-increase index.- Returns:
- default policy name, as a prefix of auto-generated policy name.
 
- 
getPolicyName- Specified by:
- getPolicyNamein interface- RateLimiter
- Returns:
- name of RateLimit policy
 
- 
setPolicyNameDescription copied from interface:RateLimiterSets the policy name, otherwise an auto-generated name is used.- Specified by:
- setPolicyNamein interface- RateLimiter
- Parameters:
- name- of rate limit policy
 
- 
getDurationpublic int getDuration()- Specified by:
- getDurationin interface- RateLimiter
- Returns:
- the actual duration of a time window in seconds
 
- 
setDurationpublic void setDuration(int duration) Description copied from interface:RateLimiterSets the configured duration value in seconds.- Specified by:
- setDurationin interface- RateLimiter
- Parameters:
- duration- The duration of the time window in seconds
 
- 
getRequestspublic int getRequests()- Specified by:
- getRequestsin interface- RateLimiter
- Returns:
- the maximum number of requests allowed per time window
 
- 
setRequestspublic void setRequests(int requests) Description copied from interface:RateLimiterSets the configured number of requests allowed per time window.- Specified by:
- setRequestsin interface- RateLimiter
- Parameters:
- requests- The number of requests per time window
 
- 
incrementDescription copied from interface:RateLimiterIncrements the number of requests by the given identifier in the current time window.- Specified by:
- incrementin interface- RateLimiter
- Parameters:
- identifier- the identifier for which the number of associated requests should be incremented
- Returns:
- the new value after incrementing
 
- 
destroypublic void destroy()Description copied from interface:RateLimiterCleanup no longer needed resources.- Specified by:
- destroyin interface- RateLimiter
 
- 
newCounterInstanceprotected abstract TimeBucketCounterBase newCounterInstance(int duration, ScheduledExecutorService utilityExecutor) Instantiate an instance ofTimeBucketCounterBasefor specific time bucket size. Concrete classes determine its counter policy by returning different implementation instances.- Parameters:
- duration- size of each time bucket in seconds
- utilityExecutor- the executor
- Returns:
- counter instance of TimeBucketCounterBase
 
- 
setFilterConfigDescription copied from interface:RateLimiterPass the FilterConfig to configure the filter.- Specified by:
- setFilterConfigin interface- RateLimiter
- Parameters:
- filterConfig- The FilterConfig used to configure the associated filter
 
- 
getBucketCounterReturns the internal instance ofTimeBucketCounterBase.- Returns:
- instance of TimeBucketCounterBase
 
 
-