Package org.apache.solr.servlet
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RequestRateLimiter.SlotReservation
-
Field Summary
Fields Modifier and Type Field Description static RequestRateLimiter.SlotReservation
UNLIMITED
-
Constructor Summary
Constructors Constructor Description RequestRateLimiter(RateLimiterConfig rateLimiterConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestRateLimiter.SlotReservation
allowSlotBorrowing()
Whether to allow another request type to borrow a slot from this request rate limiter.RateLimiterConfig
getRateLimiterConfig()
RequestRateLimiter.SlotReservation
handleRequest()
Handles an incoming request.
-
-
-
Field Detail
-
UNLIMITED
public static final RequestRateLimiter.SlotReservation UNLIMITED
-
-
Constructor Detail
-
RequestRateLimiter
public RequestRateLimiter(RateLimiterConfig rateLimiterConfig)
-
-
Method Detail
-
handleRequest
public RequestRateLimiter.SlotReservation 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 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()
-
-