Package org.yamcs.alarms
Class AlarmServer<S,T>
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
-
Constructor Summary
ConstructorDescriptionAlarmServer
(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 void
addActiveAlarmFromTuple
(Mdb mdb, Tuple t) Map<S,
ActiveAlarm<T>> addAlarmListener
(AlarmListener<T> listener) Register for alarm noticesprotected abstract String
clear
(ActiveAlarm<T> alarm, String username, long clearTime, String message) Acknowledges an active alarm instance.void
clearAll()
Removes all active alarms without acknowledgement !void
doStart()
void
doStop()
getActiveAlarm
(S subject) Returns the active alarm for the specifiedsubject
.getActiveAlarm
(S subject, int id) Returns the active alarm for the specifiedsubject
if it also matches the specifiedid
.Map<S,
ActiveAlarm<T>> Returns the current set of active alarmsprotected abstract String
protected abstract S
getSubject
(T value) protected static boolean
moreSevere
(Object newValue, Object oldValue) protected static boolean
moreSevere
(Event.EventSeverity es1, Event.EventSeverity es2) protected static boolean
void
removeAlarmListener
(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 alarmvoid
void
Methods 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 specifiedsubject
if 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
null
if 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
null
if 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. Leavenull
when 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. Leavenull
when 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:
doStart
in classcom.google.common.util.concurrent.AbstractService
-
update
-
update
-
moreSevere
-
moreSevere
-
moreSevere
-
doStop
public void doStop()- Specified by:
doStop
in 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
-