Class RequestLimit

  • public class RequestLimit
    extends Object
    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 503 Service Unavailable according to RFC7231 Section 6.6.4.

    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.

    Stuart Douglas
    See Also:
    • Constructor Detail

      • 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.
        maximumConcurrentRequests - the maximum concurrent requests
        queueSize - The maximum number of requests to queue
    • Method Detail

      • getMaximumConcurrentRequests

        public int getMaximumConcurrentRequests()
        Get the maximum concurrent requests.
        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.
        newMax - the maximum concurrent requests
      • getFailureHandler

        public HttpHandler getFailureHandler()
      • setFailureHandler

        public void setFailureHandler​(HttpHandler failureHandler)