public class InstanceMonitor extends TurbineDataMonitor<DataFromSingleInstance>
Instance.
The InstanceMonitor connects to the host as prescribed by the InstanceUrlClosure and then streams data down.
It assumes that the data format is json.
The monitor looks for 1st class attributes name and type and the rest of the attributes are parsed into one of 2 attribute maps i.e either numericAttributes or stringAttributes.
The monitor also keeps retrying the host connection unless told to do otherwise. It gives up reconnecting when it finds a bad status code
such as a 404 not found or UnknownHostException.
However the monitor continues to retry the connection even when it receives an IOException in order to be resilient against network flakiness.
Each InstanceMonitor has access to the TurbineDataDispatcher to dispatch data to. This helps it be decoupled from the TurbineDataHandler underneath.
If the dispatcher tells the monitor that there is no one listening then the monitor shuts itself down for efficiency.
| Modifier and Type | Class and Description |
|---|---|
static class |
InstanceMonitor.UnitTest |
| Modifier and Type | Field and Description |
|---|---|
static java.util.concurrent.ExecutorService |
ThreadPool |
| Constructor and Description |
|---|
InstanceMonitor(Instance host,
InstanceUrlClosure urlClosure,
TurbineDataDispatcher<DataFromSingleInstance> dispatcher,
MonitorConsole<DataFromSingleInstance> monitorConsole) |
| Modifier and Type | Method and Description |
|---|---|
TurbineDataDispatcher<DataFromSingleInstance> |
getDispatcher() |
long |
getLastEventUpdateTime()
Method that determines when this monitor last received an update.
|
java.lang.String |
getName()
The name of the InstanceMonitor.
|
Instance |
getStatsInstance() |
boolean |
hasStopped() |
boolean |
monitorRunning() |
void |
startMonitor()
Start monitoring
|
static void |
stop() |
void |
stopMonitor()
Request monitor to stop
|
getEventDiscarded, getEventProcessed, getRolling2MinuteStats, markEventDiscarded, markEventProcessedpublic InstanceMonitor(Instance host, InstanceUrlClosure urlClosure, TurbineDataDispatcher<DataFromSingleInstance> dispatcher, MonitorConsole<DataFromSingleInstance> monitorConsole)
host - - the host to monitorurlClosure - - config on how to connect to hostdispatcher - - the dispatcher to send data tomonitorConsole - - the console to manage itself in on startup and shutdownpublic java.lang.String getName()
getName in class TurbineDataMonitor<DataFromSingleInstance>public Instance getStatsInstance()
getStatsInstance in class TurbineDataMonitor<DataFromSingleInstance>Instancepublic TurbineDataDispatcher<DataFromSingleInstance> getDispatcher()
getDispatcher in class TurbineDataMonitor<DataFromSingleInstance>TurbineDataDispatcher<DataFromSingleInstance>public void startMonitor()
throws java.lang.Exception
startMonitor in class TurbineDataMonitor<DataFromSingleInstance>java.lang.Exceptionpublic void stopMonitor()
stopMonitor in class TurbineDataMonitor<DataFromSingleInstance>public long getLastEventUpdateTime()
TurbineDataMonitorgetLastEventUpdateTime in class TurbineDataMonitor<DataFromSingleInstance>public boolean monitorRunning()
public boolean hasStopped()
public static void stop()