public class HystrixTimer extends Object
HystrixCommand to timeout async executions and HystrixCollapser to trigger batch executions.| Modifier and Type | Class and Description |
|---|---|
static interface |
HystrixTimer.TimerListener |
| Modifier and Type | Method and Description |
|---|---|
Reference<HystrixTimer.TimerListener> |
addTimerListener(HystrixTimer.TimerListener listener)
Add a
HystrixTimer.TimerListener that will be executed until it is garbage collected or removed by clearing the returned Reference. |
static HystrixTimer |
getInstance()
Retrieve the global instance.
|
static void |
reset()
Clears all listeners.
|
protected void |
startThreadIfNeeded()
Since we allow resetting the timer (shutting down the thread) we need to lazily re-start it if it starts being used again.
|
public static HystrixTimer getInstance()
public static void reset()
NOTE: This will result in race conditions if addTimerListener(com.netflix.hystrix.util.HystrixTimer.TimerListener) is being concurrently called.
public Reference<HystrixTimer.TimerListener> addTimerListener(HystrixTimer.TimerListener listener)
HystrixTimer.TimerListener that will be executed until it is garbage collected or removed by clearing the returned Reference.
NOTE: It is the responsibility of code that adds a listener via this method to clear this listener when completed.
// add a TimerListener Reference<TimerListener> listener = HystrixTimer.getInstance().addTimerListener(listenerImpl); // sometime later, often in a thread shutdown, request cleanup, servlet filter or something similar the listener must be shutdown via the clear() method listener.clear();
listener - TimerListener implementation that will be triggered according to its getIntervalTimeInMilliseconds() method implementation.clear() methodprotected void startThreadIfNeeded()
This does the lazy initialization and start of the thread in a thread-safe manner while having little cost the rest of the time.
Copyright © 2017. All Rights Reserved.