@InterfaceAudience.Private public class TimeoutExceptionInjector extends Object
The timer won't start tracking time until calling start()
. If complete()
or
trigger()
is called before start()
, calls to start()
will fail.
Modifier and Type | Field and Description |
---|---|
private boolean |
complete |
private static org.slf4j.Logger |
LOG |
private long |
maxTime |
private long |
start |
private Timer |
timer |
private TimerTask |
timerTask |
Constructor and Description |
---|
TimeoutExceptionInjector(ForeignExceptionListener listener,
long maxTime)
Create a generic timer for a task/process.
|
Modifier and Type | Method and Description |
---|---|
void |
complete()
For all time forward, do not throw an error because the process has completed.
|
long |
getMaxTime() |
void |
start()
Start a timer to fail a process if it takes longer than the expected time to complete.
|
void |
trigger()
Trigger the timer immediately.
|
private static final org.slf4j.Logger LOG
private final long maxTime
private volatile boolean complete
private long start
public TimeoutExceptionInjector(ForeignExceptionListener listener, long maxTime)
listener
- listener to notify if the process times outmaxTime
- max allowed running time for the process. Timer starts on calls to
start()
public long getMaxTime()
public void complete()
public void start() throws IllegalStateException
Non-blocking.
IllegalStateException
- if the timer has already been marked done via complete()
or trigger()
public void trigger()
Exposed for testing.
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.