Class RequestRateLimiter

  • Direct Known Subclasses:
    QueryRateLimiter

    @SolrThreadSafe
    public class RequestRateLimiter
    extends Object
    Handles rate limiting for a specific request type.

    The control flow is as follows: Handle request -- Check if slot is available -- If available, acquire slot and proceed -- else reject the same.

    • Constructor Detail

      • RequestRateLimiter

        public RequestRateLimiter​(RateLimiterConfig rateLimiterConfig)
    • Method Detail

      • handleRequest

        public org.apache.solr.servlet.RequestRateLimiter.SlotMetadata handleRequest()
                                                                              throws InterruptedException
        Handles an incoming request. returns a metadata object representing the metadata for the acquired slot, if acquired. If a slot is not acquired, returns a null metadata object.
        Throws:
        InterruptedException
      • allowSlotBorrowing

        public org.apache.solr.servlet.RequestRateLimiter.SlotMetadata allowSlotBorrowing()
                                                                                   throws InterruptedException
        Whether to allow another request type to borrow a slot from this request rate limiter. Typically works fine if there is a relatively lesser load on this request rate limiter's type compared to the others (think of skew).
        Returns:
        returns a metadata object for the acquired slot, if acquired. If the slot was not acquired, returns a metadata object with a null pool.
        Throws:
        InterruptedException
        WARNING: This API is experimental and might change in incompatible ways in the next release.
        -- Can cause slots to be blocked if a request borrows a slot and is itself long lived.