org.d_haven.event.impl
public class RateLimitingPredicate extends Object implements EnqueuePredicate
Version: $Revision: 1.11 $
| Field Summary | |
|---|---|
| int | m_depth |
| long | m_lastTime |
| double | m_regenTimeMs |
| double | m_targetRate |
| int | m_tokenCount |
| static double | SECOND |
| Constructor Summary | |
|---|---|
| RateLimitingPredicate(int depth)
Create a new RateLimitingPredicate for the given sink, bucket
depth and no rate limit.
| |
| RateLimitingPredicate(double targetRate, int depth)
Create a new RateLimitingPredicate for the given sink,
targetRate, and token bucket depth. | |
| Method Summary | |
|---|---|
| boolean | accept(Object element, Sink sink) |
| boolean | accept(Object[] elements, Sink sink) |
| int | getBucketSize()
Returns the number of tokens currently in the bucket.
|
| int | getDepth()
Returns the current depth.
|
| double | getTargetRate()
Returns the current rate limit.
|
| void | setDepth(int depth)
Allows to set the bucket depth.
|
| void | setTargetRate(double targetRate)
Allows to set the rate limit. |
| boolean | testRate(int tokenCount) |
| String | toString() |
Parameters: depth The token bucket depth.
Since: May 15, 2002
Parameters: targetRate The rate that is the target for this predicate depth The token bucket depth.
Since: May 15, 2002
Returns: int the number of tokens currently in the bucket.
Since: May 15, 2002
Returns: int The current bucket depth.
Since: May 15, 2002
Returns: double the current target rate
Since: May 15, 2002
Parameters: depth The bucket depth as an integer.
Since: May 15, 2002
Parameters: targetRate the current rate limit.
Since: May 15, 2002