public abstract class AbstractMonitor extends java.lang.Object implements Monitor, java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicLong |
lastActivityTimestampNanos |
protected java.util.concurrent.ExecutorService |
monitorExecutor |
protected java.util.concurrent.atomic.AtomicReference<MonitorState> |
state |
protected java.util.concurrent.atomic.AtomicBoolean |
stop |
protected java.util.concurrent.atomic.AtomicLong |
terminationTimeoutSec |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMonitor(long terminationTimeoutSec) |
protected |
AbstractMonitor(long terminationTimeoutSec,
java.util.concurrent.ExecutorService monitorExecutor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDispose()
Defines whether this monitor can be disposed.
|
void |
close()
Closes all resources used by this monitor.
|
long |
getLastActivityTimestampNanos()
Gets the timestamp for the last action performed by this monitor, in nanoseconds.
|
MonitorState |
getState()
Gets the current state of this monitor.
|
void |
run()
Starts the monitor workflow, making sure to set the initial state of the monitor.
|
void |
start()
Submits this monitor in a separate thread to begin its monitoring tasks.
|
void |
stop()
Stops the monitoring tasks for this monitor and closes all resources.
|
protected final java.util.concurrent.atomic.AtomicBoolean stop
protected final java.util.concurrent.ExecutorService monitorExecutor
protected final java.util.concurrent.atomic.AtomicLong terminationTimeoutSec
protected final java.util.concurrent.atomic.AtomicLong lastActivityTimestampNanos
protected final java.util.concurrent.atomic.AtomicReference<MonitorState> state
protected AbstractMonitor(long terminationTimeoutSec)
protected AbstractMonitor(long terminationTimeoutSec,
java.util.concurrent.ExecutorService monitorExecutor)
public void start()
Monitorpublic void run()
MonitorState.ERROR.run in interface java.lang.Runnablepublic void stop()
Monitorpublic void close()
MonitorMonitor.stop().public long getLastActivityTimestampNanos()
MonitorgetLastActivityTimestampNanos in interface Monitorpublic MonitorState getState()
Monitorpublic boolean canDispose()
MonitorcanDispose in interface Monitor