Package uk.ac.ebi.utils.runcontrol
Class RateLimitedExecutor
java.lang.Object
uk.ac.ebi.utils.runcontrol.RateLimitedExecutor
- All Implemented Interfaces:
Executor
- Direct Known Subclasses:
DynamicRateExecutor
A rate limiting executor, based on
RateLimiter
.- Author:
- brandizi
- Date:
- 5 Oct 2015
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.google.common.util.concurrent.RateLimiter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Controls the execution of the action in such a way that it is run at no more thangetRate()
speed within a given JVM.double
getRate()
The maximum speed allowed by this executor, in actions received per second. 0 means no limit is applied.void
setRate
(double requestsPerSecond) Note that the new actual rate might be slightly different than the passed parameters, depends on howRateLimiter
is implemented.
-
Field Details
-
rateLimiter
protected com.google.common.util.concurrent.RateLimiter rateLimiter
-
-
Constructor Details
-
RateLimitedExecutor
public RateLimitedExecutor(double requestsPerSecond) - See Also:
-
-
Method Details
-
execute
Controls the execution of the action in such a way that it is run at no more thangetRate()
speed within a given JVM. This is useful when you have a service that is hurt if hammered too fast. -
getRate
public double getRate()The maximum speed allowed by this executor, in actions received per second. 0 means no limit is applied. -
setRate
public void setRate(double requestsPerSecond) Note that the new actual rate might be slightly different than the passed parameters, depends on howRateLimiter
is implemented.
-