Package org.apache.catalina.util

# 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 Summary

Constructors
Constructor
Description
`FastRateLimiter()`

## Method Summary

Modifier and Type
Method
Description
`void`
`destroy()`
Cleanup no longer needed resources.
`TimeBucketCounter`
`getBucketCounter()`
`int`
`getDuration()`
`int`
`getRequests()`
`int`
`increment(String ipAddress)`
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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FastRateLimiter

public FastRateLimiter()

## Method Details

### 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()