Package org.apache.storm
Class StormTimer
java.lang.Object
org.apache.storm.StormTimer
- All Implemented Interfaces:
- AutoCloseable
The timer defined in this file is very similar to java.util.Timer, except it integrates with Storm's time simulation capabilities. This
 lets us test code that does asynchronous work on the timer thread.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic class
- 
Constructor SummaryConstructorsConstructorDescriptionStormTimer(String name, Thread.UncaughtExceptionHandler onKill) Makes a Timer in the form of a StormTimerTask Object.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()cancel timer.booleanis timer waiting.voidvoidSchedule a function to be executed in the timer.voidscheduleMs(long delayMs, Runnable func) voidscheduleMs(long delayMs, Runnable func, boolean checkActive, int jitterMs) Same as schedule with millisecond resolution.voidscheduleRecurring(int delaySecs, int recurSecs, Runnable func) Schedule a function to run recurrently.voidscheduleRecurringMs(long delayMs, long recurMs, Runnable func) Schedule a function to run recurrently.voidscheduleRecurringWithJitter(int delaySecs, int recurSecs, int jitterMs, Runnable func) Schedule a function to run recurrently with jitter.
- 
Constructor Details- 
StormTimerMakes a Timer in the form of a StormTimerTask Object.- Parameters:
- name- name of the timer
- onKill- function to call when timer is killed unexpectedly
 
 
- 
- 
Method Details- 
scheduleSchedule a function to be executed in the timer.- Parameters:
- delaySecs- the number of seconds to delay before running the function
- func- the function to run
- checkActive- whether to check is the timer is active
- jitterMs- add jitter to the run
 
- 
schedule
- 
scheduleMsSame as schedule with millisecond resolution.- Parameters:
- delayMs- the number of milliseconds to delay before running the function
- func- the function to run
- checkActive- whether to check is the timer is active
- jitterMs- add jitter to the run
 
- 
scheduleMs
- 
scheduleRecurringSchedule a function to run recurrently.- Parameters:
- delaySecs- the number of seconds to delay before running the function
- recurSecs- the time between each invocation
- func- the function to run
 
- 
scheduleRecurringMsSchedule a function to run recurrently.- Parameters:
- delayMs- the number of millis to delay before running the function
- recurMs- the time between each invocation
- func- the function to run
 
- 
scheduleRecurringWithJitterSchedule a function to run recurrently with jitter.- Parameters:
- delaySecs- the number of seconds to delay before running the function
- recurSecs- the time between each invocation
- jitterMs- jitter added to the run
- func- the function to run
 
- 
closecancel timer.- Specified by:
- closein interface- AutoCloseable
- Throws:
- InterruptedException
 
- 
isTimerWaitingpublic boolean isTimerWaiting()is timer waiting. Used in timer simulation.
 
-