Class Throttle
java.lang.Object
com.northconcepts.datapipeline.throttle.Throttle
Limits the average rate measured by a
Meter by making the calling thread sleep while the count is ahead of the allowed rate.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this throttle's limit, peak rate and meter state to the given exception and returns it.getMeter()doubleReturns the highest rate (units per second) the meter reported whenthrottle()was called.intReturns the maximum average rate, in the meter's units per second, thatthrottle()enforces.voidsetUnitsPerSecond(int unitsPerSecond) Sets the maximum average rate, in the meter's units per second, thatthrottle()enforces.voidthrottle()Sleeps the calling thread long enough to bring the meter's average rate back down to the limit; waits under 10 milliseconds are skipped.
-
Constructor Details
-
Throttle
-
-
Method Details
-
getMeter
-
getUnitsPerSecond
public int getUnitsPerSecond()Returns the maximum average rate, in the meter's units per second, thatthrottle()enforces. -
setUnitsPerSecond
public void setUnitsPerSecond(int unitsPerSecond) Sets the maximum average rate, in the meter's units per second, thatthrottle()enforces. -
getPeekUnitsPerSecond
public double getPeekUnitsPerSecond()Returns the highest rate (units per second) the meter reported whenthrottle()was called. -
throttle
Sleeps the calling thread long enough to bring the meter's average rate back down to the limit; waits under 10 milliseconds are skipped.- Throws:
InterruptedException
-
addExceptionProperties
Adds this throttle's limit, peak rate and meter state to the given exception and returns it.
-