Package io.undertow.server.handlers
Class RequestLimit
java.lang.Object
io.undertow.server.handlers.RequestLimit
Represents a limit on a number of running requests.
This is basically a counter with a configured set of limits, that is used by RequestLimitingHandler.
When the number of active requests goes over the configured max requests then requests will be suspended and queued.
If the queue is full requests will be rejected with a 513.
The reason why this is abstracted out into a separate class is so that multiple handlers can share the same state. This allows for fine grained control of resources.
- Author:
- Stuart Douglas
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRequestLimit(int maximumConcurrentRequests) RequestLimit(int maximumConcurrentRequests, int queueSize) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionintGet the maximum concurrent requests.voidhandleRequest(HttpServerExchange exchange, HttpHandler next) voidsetFailureHandler(HttpHandler failureHandler) intsetMaximumConcurrentRequests(int newMax) Set the maximum concurrent requests.
-
Constructor Details
-
RequestLimit
public RequestLimit(int maximumConcurrentRequests) -
RequestLimit
public RequestLimit(int maximumConcurrentRequests, int queueSize) Construct a new instance. The maximum number of concurrent requests must be at least one.- Parameters:
maximumConcurrentRequests- the maximum concurrent requestsqueueSize- The maximum number of requests to queue
-
-
Method Details
-
handleRequest
- Throws:
Exception
-
getMaximumConcurrentRequests
public int getMaximumConcurrentRequests()Get the maximum concurrent requests.- Returns:
- the maximum concurrent requests
-
setMaximumConcurrentRequests
public int setMaximumConcurrentRequests(int newMax) Set the maximum concurrent requests. The value must be greater than or equal to one.- Parameters:
newMax- the maximum concurrent requests
-
getFailureHandler
-
setFailureHandler
-