Package com.newrelic.telemetry
Class LimitingScheduler
- java.lang.Object
-
- com.newrelic.telemetry.LimitingScheduler
-
public class LimitingScheduler extends java.lang.Object
A scheduler that delegates to a ScheduledExecutorService while also enforcing a maximum upper bound of the amount of work that is being done. For our purposes, the amount of work corresponds to the number of telemetry items "in-flight" (being buffered) in memory.A call to schedule() will include a work unit "size" that is accumulated, and if the max would be exceeded then the work unit is rejected and a warning is logged.
-
-
Constructor Summary
Constructors Constructor Description LimitingScheduler(java.util.concurrent.ScheduledExecutorService executor, int max)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(int shutdownSeconds, java.util.concurrent.TimeUnit seconds)
boolean
isTerminated()
boolean
schedule(int size, java.lang.Runnable command)
boolean
schedule(int size, java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
void
shutdown()
void
shutdownNow()
-
-
-
Method Detail
-
schedule
public boolean schedule(int size, java.lang.Runnable command)
-
schedule
public boolean schedule(int size, java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
-
isTerminated
public boolean isTerminated()
-
shutdown
public void shutdown()
-
awaitTermination
public boolean awaitTermination(int shutdownSeconds, java.util.concurrent.TimeUnit seconds) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
shutdownNow
public void shutdownNow()
-
-