public class AlarmSourceImpl extends java.lang.Object implements AlarmSource
AlarmSource.
Flushing of queued alarms is done by a thread to avoid blocking
the caller if there are too many queued alarms.
There is possible critical race if the user executes a sequence
of queueAlarms()/flushAlarms(), it happens if the queueAlarms()
is called when the thread has not yet finished flushing
the alarms.
This is avoided by copying the alarms in queue
in a temporary immutable vector.
Instances of AlarmSource objects should be get with ContainerServices#getAlarmSource().
| Modifier and Type | Field and Description |
|---|---|
static int |
ALARM_OSCILLATION_TIME
To limit the effect of oscillations, publishing of inactive alarms
is delayed by
ALARM_OSCILLATION_TIME (in seconds) |
| Constructor and Description |
|---|
AlarmSourceImpl(ContainerServicesBase containerServices)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode)
The alarm to clear is not sent directly to the alarm service.
|
void |
disableAlarms()
Disable the sending of alarms.
|
void |
enableAlarms()
Enable the sending of alarms.
|
void |
flushAlarms()
Flush the alarms queued and stop queuing.
|
void |
queueAlarms()
Start queuing the alarms.
|
void |
queueAlarms(long delayTime,
java.util.concurrent.TimeUnit unit)
Start queuing the alarms.
|
void |
raiseAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode)
Raise an alarm with the given triplet.
|
void |
raiseAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode,
java.util.Properties properties)
Raise an alarm with the given triplet and a set of properties.
|
void |
setAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode,
boolean active)
Send the alarm with the passed triplet to the
alarm service.
|
void |
setAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode,
java.util.Properties alarmProps,
boolean active)
Send the alarm with the passed triplet and properties to the
alarm service.
|
void |
start()
Start the threads.
|
void |
tearDown()
Life-cycle: tearDown must be called when terminated using this class
|
void |
terminateAllAlarms()
Terminate all the active alarms.
|
public static final int ALARM_OSCILLATION_TIME
ALARM_OSCILLATION_TIME (in seconds)
If during this time interval the alarm is activated again then its temporary deactivation will be skipped.
Visibility is public for testing purposes.
public AlarmSourceImpl(ContainerServicesBase containerServices)
containerServices - The container servicespublic void raiseAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode)
AlarmSourceIf the alarm is already active, it is not sent again to the alarm service.
raiseAlarm in interface AlarmSourcefaultFamily - The FaultFamilyfaultMember - The FaultMemberfaultCode - The FaultCodepublic void raiseAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode,
java.util.Properties properties)
AlarmSourceIf the alarm is already active, it is not sent again to the alarm service.
raiseAlarm in interface AlarmSourcefaultFamily - The FaultFamilyfaultMember - The FaultMemberfaultCode - The FaultCodeproperties - The user properties.
It can be null or empty.public void clearAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode)
alarmsToClean and
will be cleared by the oscillation loop.clearAlarm in interface AlarmSourcefaultFamily - The FaultFamilyfaultMember - The FaultMemberfaultCode - The FaultCodepublic void setAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode,
java.util.Properties alarmProps,
boolean active)
AlarmSourceThis method is the most complete way to send an alarm.
If the alarm is already active, it is not sent again to the alarm service. If the alarm is already terminated, it is not sent again to the alarm service.
setAlarm in interface AlarmSourcefaultFamily - The FaultFamilyfaultMember - The FaultMemberfaultCode - The FaultCodealarmProps - The user properties.
It can be null or empty.active - if true the alarm is activated
otherwise it is terminated.public void setAlarm(java.lang.String faultFamily,
java.lang.String faultMember,
int faultCode,
boolean active)
AlarmSourceThis method is the most complete way to send an alarm.
If the alarm is already active, it is not sent again to the alarm service. If the alarm is already terminated, it is not sent again to the alarm service.
setAlarm in interface AlarmSourcefaultFamily - The FaultFamilyfaultMember - The FaultMemberfaultCode - The FaultCodeactive - if true the alarm is activated
otherwise it is terminated.public void terminateAllAlarms()
AlarmSourceterminateAllAlarms in interface AlarmSourcepublic void queueAlarms(long delayTime,
java.util.concurrent.TimeUnit unit)
AlarmSourceThe alarms are flushed when the passed time expires or flush gets called.
The purpose of the queuing is to avoid alarms flickering for example during the initialization phase of a device where spurious states could trigger the event of false alarms
queueAlarms in interface AlarmSourcedelayTime - The time to queue alarmsunit - The unit of the delaypublic void queueAlarms()
AlarmSource
The alarms are queued until flushAlarms() is executed.
The purpose of the queuing is to avoid alarms flickering for example during the initialization phase of a device where spurious states could trigger the event of false alarms.
queueAlarms in interface AlarmSourceAlarmSource.flushAlarms()public void flushAlarms()
This method gets called both directly for flushing alarms immediately, and also
delayed (new thread from queueAlarms(long, TimeUnit)).
Implementation note: this method is synchronized and calls setAlarm(String, String, int, Properties, boolean)
asynchronously in order to not block access to this class for too long.
flushAlarms in interface AlarmSourceAlarmSource.flushAlarms()public void disableAlarms()
AlarmSourceWhen the alarms are disabled, all the alarms submitted with raise, clear and set are discarded. This means that those alarms are immediately discarded. They are not queued, and will never arrive at the alarm service.
disableAlarms in interface AlarmSourceAlarmSource.enableAlarms()public void enableAlarms()
AlarmSourceBetter just "This method reverts the effect of a previous call to disableAlarms(), so that alarms will get processed again.
Alarms are enabled by default.
enableAlarms in interface AlarmSourceAlarmSource.disableAlarms()public void start()
start in interface AlarmSourcetearDown()public void tearDown()
AlarmSourcetearDown in interface AlarmSource