public class WatchDog extends Object
Several LastEventOperators can be registered, the WatchDog use a singleton thread to watch them all. You can cancel a LastEventOperator once done. That is, you can safely create one LastEventOperator per bolt or spout instance.
Here is a typical usage:
LastEventOperator lastEventOp;
init() {
// we want to die if not ticked for more than 5 seconds
lastEventOp = WatchDog.fire(5000, LOG);
..
}
... {
// you must call this regularly, at least once every 5 seconds
lastEvent.mark();
}
}
As an alternative you can also use a watchdog metrics.Constructor and Description |
---|
WatchDog() |
Modifier and Type | Method and Description |
---|---|
static void |
cancel(org.thales.punch.libraries.punchlang.operator.LastEventOperator le)
Stop verifying a watchdog lastEventOperator.
|
static org.thales.punch.libraries.punchlang.operator.LastEventOperator |
fire(long elapsedMs,
org.apache.logging.log4j.Logger logger)
Return a punch
LastEventOperator register into a singleton watchdog. |
public static void cancel(org.thales.punch.libraries.punchlang.operator.LastEventOperator le)
le
- the LastEventOperatorpublic static org.thales.punch.libraries.punchlang.operator.LastEventOperator fire(long elapsedMs, org.apache.logging.log4j.Logger logger)
LastEventOperator
register into a singleton watchdog.
If you do not call LastEventOperator.mark()
regularly,
the WatchDog will kill the entire jvm.
WATCHOUT: you read correctly : it kills the entire Jvm.
elapsedMs
- the watchdog timeout in milliseconds. If that value is less than or equal to zero,
you will get an safe without-effect LastEventOperator.log
- a logger to at least have a trace of the owner who fired the watchdogLastEventOperator
Copyright © 2023. All rights reserved.