seda.sandStorm.core
Class RateLimitingPredicate

java.lang.Object
  extended by seda.sandStorm.core.RateLimitingPredicate
All Implemented Interfaces:
EnqueuePredicateIF

public class RateLimitingPredicate
extends java.lang.Object
implements EnqueuePredicateIF

This enqueue predicate implements input rate policing.


Field Summary
private  seda.util.StatsGatherer acceptArrivalStats
           
private static boolean DEBUG
           
private  int depth
           
private  seda.util.StatsGatherer interArrivalStats
           
private  long lasttime
           
private  long MIN_REGEN_TIME
           
private static boolean PROFILE
           
private  double regenTimeMS
           
private  double targetRate
           
private  SinkIF thesink
           
private  double tokenCount
           
 
Constructor Summary
RateLimitingPredicate(SinkIF sink, double targetRate, int depth)
          Create a new RateLimitingPredicate for the given sink, targetRate, and token bucket depth.
 
Method Summary
 boolean accept(QueueElementIF qel)
          Returns true if the given element can be accepted into the queue.
 int getBucketSize()
          Return the number of tokens currently in the bucket.
 int getDepth()
          Return the current depth.
 double getTargetRate()
          Return the current rate limit.
 void setDepth(int depth)
          Set the bucket depth.
 void setTargetRate(double targetRate)
          Set the rate limit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

thesink

private SinkIF thesink

targetRate

private double targetRate

depth

private int depth

tokenCount

private double tokenCount

regenTimeMS

private double regenTimeMS

lasttime

private long lasttime

MIN_REGEN_TIME

private long MIN_REGEN_TIME

PROFILE

private static final boolean PROFILE
See Also:
Constant Field Values

interArrivalStats

private seda.util.StatsGatherer interArrivalStats

acceptArrivalStats

private seda.util.StatsGatherer acceptArrivalStats
Constructor Detail

RateLimitingPredicate

public RateLimitingPredicate(SinkIF sink,
                             double targetRate,
                             int depth)
Create a new RateLimitingPredicate for the given sink, targetRate, and token bucket depth. A rate of -1.0 indicates no rate limit.

Method Detail

accept

public boolean accept(QueueElementIF qel)
Returns true if the given element can be accepted into the queue.

Specified by:
accept in interface EnqueuePredicateIF
Parameters:
qel - The QueueElementIF to enqueue
Returns:
True if the sink accepts the element; false otherwise.

getTargetRate

public double getTargetRate()
Return the current rate limit.


getDepth

public int getDepth()
Return the current depth.


getBucketSize

public int getBucketSize()
Return the number of tokens currently in the bucket.


setTargetRate

public void setTargetRate(double targetRate)
Set the rate limit. A limit of -1.0 indicates no rate limit.


setDepth

public void setDepth(int depth)
Set the bucket depth.