Package host.anzo.core.service
Class FirewallService.BurstRateLimiter
java.lang.Object
host.anzo.core.service.FirewallService.BurstRateLimiter
- Enclosing class:
FirewallService
Implementation of a rate limiter with a burst (i.e. a limiter that allows some amount of bursty traffic).
The burst is replenished at a constant rate.
-
Constructor Summary
ConstructorsConstructorDescriptionBurstRateLimiter(double permitsPerSecond, double maxBurst) Creates a newFirewallService.BurstRateLimiterwith the given rate and burst. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTries to acquire 1 permit.booleantryAcquire(double permits) Tries to acquire the given number of permits (fractional).
-
Constructor Details
-
BurstRateLimiter
public BurstRateLimiter(double permitsPerSecond, double maxBurst) Creates a newFirewallService.BurstRateLimiterwith the given rate and burst.- Parameters:
permitsPerSecond- the rate of the limiter (permits/second)maxBurst- the maximum burst of the limiter
-
-
Method Details
-
tryAcquire
public boolean tryAcquire()Tries to acquire 1 permit.- Returns:
trueif the permits are acquired,falseotherwise
-
tryAcquire
public boolean tryAcquire(double permits) Tries to acquire the given number of permits (fractional).- Parameters:
permits- the number of permits to acquire- Returns:
trueif the permits are acquired,falseotherwise
-