Search in sources :

Example 1 with AlarmChange

use of cern.laser.business.data.AlarmChange in project ACS by ACS-Community.

the class AlarmCacheServerImpl method notify.

public void notify(Collection alarmChanges) {
    try {
        Iterator iterator = alarmChanges.iterator();
        while (iterator.hasNext()) {
            AlarmChange alarm_change = (AlarmChange) iterator.next();
            Alarm current_alarm = alarm_change.getCurrent();
            if (!current_alarm.getStatus().getActive().equals(alarm_change.getPrevious().getStatus().getActive())) {
                if (current_alarm.getPiquetGSM() != null) {
                    sendSMS(current_alarm);
                }
                if (current_alarm.getPiquetEmail() != null) {
                    sendEmail(current_alarm);
                }
            }
        }
    } catch (Exception e) {
        throw new LaserRuntimeException("unable to notify alarm(s)", e);
    }
}
Also used : AlarmChange(cern.laser.business.data.AlarmChange) Alarm(cern.laser.business.data.Alarm) Iterator(java.util.Iterator) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 2 with AlarmChange

use of cern.laser.business.data.AlarmChange in project ACS by ACS-Community.

the class AlarmDefinitionServiceImpl method propagateRemovedAlarm.

private void propagateRemovedAlarm(Alarm alarm) {
    try {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("propagating removed alarm : " + alarm.getTriplet());
        if (alarm.getStatus().getActive().booleanValue()) {
            Alarm terminated = (Alarm) ((AlarmImpl) alarm).clone();
            terminated.getStatus().setActive(Boolean.FALSE);
            terminated.getStatus().setSourceHostname("LASER");
            Timestamp now = new Timestamp(System.currentTimeMillis());
            terminated.getStatus().setSourceTimestamp(now);
            terminated.getStatus().setSystemTimestamp(now);
            terminated.getStatus().setUserTimestamp(now);
            terminated.getStatus().getProperties().clear();
            terminated.getStatus().getProperties().setProperty("REMOVED_BOOL", "TRUE");
            alarmPublisher.publish(new AlarmChange(terminated, alarm));
            alarmMessageProcessor.notifyReductionRelatives(alarm);
        }
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("propagated");
    } catch (Exception e) {
        LOGGER.error("unable to propagate removed alarm " + alarm.getTriplet() + " : " + e.getMessage());
    }
}
Also used : AlarmChange(cern.laser.business.data.AlarmChange) Alarm(cern.laser.business.data.Alarm) Timestamp(java.sql.Timestamp) LaserDefinitionNotFoundException(cern.laser.business.definition.LaserDefinitionNotFoundException) LaserDefinitionNotAllowedException(cern.laser.business.definition.LaserDefinitionNotAllowedException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException) LaserDefinitionException(cern.laser.business.definition.LaserDefinitionException) LaserDefinitionNotValidException(cern.laser.business.definition.LaserDefinitionNotValidException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Aggregations

LaserRuntimeException (cern.laser.business.LaserRuntimeException)2 Alarm (cern.laser.business.data.Alarm)2 AlarmChange (cern.laser.business.data.AlarmChange)2 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)1 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)1 LaserDefinitionException (cern.laser.business.definition.LaserDefinitionException)1 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)1 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)1 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)1 Timestamp (java.sql.Timestamp)1 Iterator (java.util.Iterator)1