java.lang.Object
com.google.common.util.concurrent.AbstractService
org.yamcs.alarms.AlarmServer<S,T>
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
- Direct Known Subclasses:
EventAlarmServer,ParameterAlarmServer
public abstract class AlarmServer<S,T>
extends com.google.common.util.concurrent.AbstractService
Maintains a list of active alarms.
(S,T) can be one of: (Parameter,ParamerValue) or (EventId, Event)
This class implements functionality common for parameter alarms and event alarms.
Specific functionality for each alarm type (e.g. disabling alarms) should be implemented in the respective
ParameterAlarmChecker or EventAlarmServer.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAlarmServer(String yamcsInstance, ProcessorConfig procConfig, ScheduledThreadPoolExecutor timer) -
Method Summary
Modifier and TypeMethodDescriptionacknowledge(ActiveAlarm<T> alarm, String username, long ackTime, String message) Acknowledges an active alarm instance.protected abstract voidaddActiveAlarmFromTuple(Mdb mdb, Tuple t) Map<S,ActiveAlarm<T>> addAlarmListener(AlarmListener<T> listener) Register for alarm noticesprotected abstract Stringclear(ActiveAlarm<T> alarm, String username, long clearTime, String message) Acknowledges an active alarm instance.voidclearAll()Removes all active alarms without acknowledgement !voiddoStart()voiddoStop()getActiveAlarm(S subject) Returns the active alarm for the specifiedsubject.getActiveAlarm(S subject, int id) Returns the active alarm for the specifiedsubjectif it also matches the specifiedid.Map<S,ActiveAlarm<T>> Returns the current set of active alarmsprotected abstract Stringprotected abstract SgetSubject(T value) protected static booleanmoreSevere(Object newValue, Object oldValue) protected static booleanmoreSevere(org.yamcs.protobuf.Event.EventSeverity es1, org.yamcs.protobuf.Event.EventSeverity es2) protected static booleanmoreSevere(org.yamcs.protobuf.Pvalue.MonitoringResult mr1, org.yamcs.protobuf.Pvalue.MonitoringResult mr2) voidremoveAlarmListener(AlarmListener<T> listener) reset(ActiveAlarm<T> alarm, String username, long resetTime, String message) Reset a latched alarmshelve(ActiveAlarm<T> alarm, String username, String message, long shelveDuration) Shelve an alarmunshelve(ActiveAlarm<T> alarm, String username) Un-shelve an alarmvoidvoidMethods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
-
Field Details
-
activeAlarms
-
-
Constructor Details
-
AlarmServer
public AlarmServer(String yamcsInstance, ProcessorConfig procConfig, ScheduledThreadPoolExecutor timer)
-
-
Method Details
-
addAlarmListener
Register for alarm notices- Returns:
- the current set of active alarms
-
removeAlarmListener
-
getActiveAlarms
Returns the current set of active alarms -
getActiveAlarm
Returns the active alarm for the specifiedsubjectif it also matches the specifiedid.- Parameters:
subject- the subject to look for.id- the expected id of the active alarm.- Returns:
- the active alarm, or
nullif no alarm was found - Throws:
AlarmSequenceException- when the specified id does not match the id of the active alarm
-
getActiveAlarm
Returns the active alarm for the specifiedsubject.- Parameters:
subject- the subject to look for.- Returns:
- the active alarm, or
nullif no alarm was found
-
acknowledge
public ActiveAlarm<T> acknowledge(ActiveAlarm<T> alarm, String username, long ackTime, String message) Acknowledges an active alarm instance. If the alarm state is no longer applicable, the alarm is also cleared, otherwise the alarm will remain active.- Parameters:
alarm- the alarm to acknowledgeusername- the acknowledging userackTime- the time associated with the acknowledgmentmessage- reason message. Leavenullwhen no reason is given.- Returns:
- the updated alarm instance or null if the alarm was not found
-
reset
Reset a latched alarm- Parameters:
alarm-username-resetTime-message-- Returns:
- the updated alarm instance or null if the alarm was not found
-
clear
Acknowledges an active alarm instance. If the alarm state is no longer applicable, the alarm is also cleared, otherwise the alarm will remain active.- Parameters:
alarm- the alarm to clearusername- the user that cleared the alarmmessage- reason message. Leavenullwhen no reason is given.- Returns:
- the updated alarm instance or null if the alarm was not found
-
shelve
public ActiveAlarm<T> shelve(ActiveAlarm<T> alarm, String username, String message, long shelveDuration) Shelve an alarm- Parameters:
alarm-username-message-shelveDuration- shelve duration in milliseconds- Returns:
- the updated alarm instance or null if the alarm was not found
-
unshelve
Un-shelve an alarm- Parameters:
alarm-username-- Returns:
- the updated alarm instance or null if the alarm was not found
-
doStart
public void doStart()- Specified by:
doStartin classcom.google.common.util.concurrent.AbstractService
-
update
-
update
-
moreSevere
-
moreSevere
protected static boolean moreSevere(org.yamcs.protobuf.Pvalue.MonitoringResult mr1, org.yamcs.protobuf.Pvalue.MonitoringResult mr2) -
moreSevere
protected static boolean moreSevere(org.yamcs.protobuf.Event.EventSeverity es1, org.yamcs.protobuf.Event.EventSeverity es2) -
doStop
public void doStop()- Specified by:
doStopin classcom.google.common.util.concurrent.AbstractService
-
clearAll
public void clearAll()Removes all active alarms without acknowledgement !use only for unit tests! -
getSubject
-
addActiveAlarmFromTuple
-
alarmTableName
-
getColNameLastEvent
-