Package net.targetr.rc.monitoring.health
Class Health
java.lang.Object
net.targetr.rc.monitoring.health.Health
Monitors the server health and stores a history of stats.
- Author:
- Dr Michael Gardiner
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum number of stats to store in history.static final intThe sleep duration between stat collections. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddTimeOffset(HealthStat stat, long time) Converts the absolute timestamp of a stat into an offset relative to the current time.static Healthget()Gets the singleton instance of the Health monitor.static HealthStatgetChanges(HealthStat oldState, HealthStat newState) Calculates the differences between an old health state and a new one.Retrieves the history of health stats, structured as initial state and subsequent differences.Retrieves the most recently collected health stat.
-
Field Details
-
STAT_PERIOD
public static final int STAT_PERIODThe sleep duration between stat collections.- See Also:
-
MAX_HISTORY_SIZE
public static final int MAX_HISTORY_SIZEThe maximum number of stats to store in history.- See Also:
-
-
Constructor Details
-
Health
public Health()Constructs the Health monitor and starts the monitoring thread.
-
-
Method Details
-
get
Gets the singleton instance of the Health monitor.- Returns:
- the health monitor instance
-
getRecent
Retrieves the most recently collected health stat.- Returns:
- a HealthStat object containing the latest server stats
-
getHistory
Retrieves the history of health stats, structured as initial state and subsequent differences.- Returns:
- a list of HealthStat objects representing the changes over time
-
addTimeOffset
Converts the absolute timestamp of a stat into an offset relative to the current time.- Parameters:
stat- the stat to updatetime- the current time against which to calculate the offset
-
getChanges
Calculates the differences between an old health state and a new one.- Parameters:
oldState- the previous statenewState- the current state- Returns:
- a HealthStat containing only the fields that have changed
-