Class RequestRateLimiter

java.lang.Object
org.apache.solr.servlet.RequestRateLimiter
Direct Known Subclasses:
QueryRateLimiter

@ThreadSafe 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.

  • Field Details

  • Constructor Details

    • RequestRateLimiter

      public RequestRateLimiter(RateLimiterConfig rateLimiterConfig)
  • Method Details

    • handleRequest

      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 RequestRateLimiter.SlotReservation 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.
    • getRateLimiterConfig

      public RateLimiterConfig getRateLimiterConfig()