|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.d_haven.event.impl.RateLimitingPredicate
public class RateLimitingPredicate
This enqueue predicate implements input rate policing.
Field Summary | |
---|---|
private int |
m_depth
|
private long |
m_lastTime
|
private double |
m_regenTimeMs
|
private double |
m_targetRate
|
private int |
m_tokenCount
|
private static double |
SECOND
|
Constructor Summary | |
---|---|
RateLimitingPredicate(double targetRate,
int depth)
Create a new RateLimitingPredicate for the given sink, targetRate, and token bucket depth. |
|
RateLimitingPredicate(int depth)
Create a new RateLimitingPredicate for the given sink, bucket depth and no rate limit. |
Method Summary | |
---|---|
boolean |
accept(java.lang.Object[] elements,
Sink sink)
Tests the given element for acceptance onto the m_sink. |
boolean |
accept(java.lang.Object element,
Sink sink)
Tests the given element for acceptance onto the m_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. |
private boolean |
testRate(int tokenCount)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final double SECOND
private double m_targetRate
private int m_depth
private int m_tokenCount
private long m_lastTime
private double m_regenTimeMs
Constructor Detail |
---|
public RateLimitingPredicate(int depth)
depth
- The token bucket depth.public RateLimitingPredicate(double targetRate, int depth)
targetRate
- The rate that is the target for this predicatedepth
- The token bucket depth.Method Detail |
---|
public boolean accept(java.lang.Object element, Sink sink)
EnqueuePredicate
accept
in interface EnqueuePredicate
element
- The element to enqueuesink
- The sink that is used for this predicate
true
if the sink accepts the element;
false
otherwise.private boolean testRate(int tokenCount)
public boolean accept(java.lang.Object[] elements, Sink sink)
EnqueuePredicate
accept
in interface EnqueuePredicate
elements
- The array of elements to enqueuesink
- The sink that is used for this predicate
true
if the sink accepts all the elements;
false
otherwise.public double getTargetRate()
public int getDepth()
public int getBucketSize()
public void setTargetRate(double targetRate)
targetRate
- the current rate limit.public void setDepth(int depth)
depth
- The bucket depth as an integer.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |