Search in sources :

Example 1 with LaserRuntimeException

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

the class AlarmPublisherImpl method sendInit.

public void sendInit(Collection alarms, String destination) {
    try {
        logger.log(AcsLogLevel.DEBUG, "sending " + alarms.size() + " initial alarm(s) to " + destination + "...");
        Topic topic = getTopicSession().createTopic(destination);
        TextMessage message = getTopicSession().createTextMessage();
        Iterator iterator = alarms.iterator();
        while (iterator.hasNext()) {
            AlarmImpl alarm = (AlarmImpl) iterator.next();
            message.setText(AlarmMessageConversion.getXML(alarm));
            message.clearProperties();
            setMessageProperties(message, alarm);
            message.setObjectProperty("NOT_REDUCED_MASKED_SET", Boolean.TRUE);
            if (!(alarm.getStatus().getMasked().booleanValue() || alarm.getStatus().getReduced().booleanValue())) {
                message.setObjectProperty("REDUCED_MASKED_SET", Boolean.TRUE);
            } else {
                message.setObjectProperty("REDUCED_MASKED_SET", Boolean.FALSE);
            }
            getTopicPublisher().publish(topic, message);
        }
        logger.log(AcsLogLevel.DEBUG, "initial alarm(s) sent to " + destination);
    } catch (Exception e) {
        close();
        throw new LaserRuntimeException("unable to send alarms to " + destination + " : " + e.getMessage());
    }
}
Also used : AlarmImpl(cern.laser.business.data.AlarmImpl) Iterator(java.util.Iterator) Topic(javax.jms.Topic) TextMessage(javax.jms.TextMessage) NamingException(javax.naming.NamingException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserCreateException(cern.laser.business.LaserCreateException) JMSException(javax.jms.JMSException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 2 with LaserRuntimeException

use of cern.laser.business.LaserRuntimeException 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 3 with LaserRuntimeException

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

the class AlarmSourceMonitorImpl method start.

public void start() {
    try {
        if (timer == null) {
            delay = DEFAULT_DELAY;
            LOGGER.info("AlarmImpl Source Monitor check delay : " + delay + " milliseconds");
            LOGGER.info("starting source monitoring...");
            timer = new Timer();
            timer.schedule(createTimerTask(), delay, delay);
            LOGGER.info("source monitoring started");
        }
    } catch (Exception e) {
        throw new LaserRuntimeException("unable to start the source monitoring", e);
    }
}
Also used : Timer(java.util.Timer) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 4 with LaserRuntimeException

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

the class AlarmSourceMonitorImpl method isUpToDate.

public boolean isUpToDate() {
    try {
        Source[] sources = sourceDAO.findAllSources();
        Source laser_source = sourceDAO.findByLaserSource();
        for (int i = 0; i < sources.length; i++) {
            Source source = sources[i];
            if (!source.equals(laser_source)) {
                if (!source.getStatus().getConnected().booleanValue()) {
                    return false;
                }
            }
        }
        return true;
    } catch (Exception e) {
        throw new LaserRuntimeException("unable to check if sources are up to date", e);
    }
}
Also used : Source(cern.laser.business.data.Source) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 5 with LaserRuntimeException

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

the class AlarmSourceMonitorImpl method stop.

public void stop() {
    try {
        if (timer != null) {
            LOGGER.info("stopping source monitoring...");
            timer.cancel();
            timer = null;
            LOGGER.info("source monitoring stopped");
        }
    } catch (Exception e) {
        throw new LaserRuntimeException("unable to stop the source monitoring", e);
    }
}
Also used : LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Aggregations

LaserRuntimeException (cern.laser.business.LaserRuntimeException)15 Alarm (cern.laser.business.data.Alarm)8 Iterator (java.util.Iterator)6 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)5 LaserCreateException (cern.laser.business.LaserCreateException)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 JMSException (javax.jms.JMSException)3 Topic (javax.jms.Topic)3 NamingException (javax.naming.NamingException)3 AdminUser (cern.laser.business.data.AdminUser)2 AlarmImpl (cern.laser.business.data.AlarmImpl)2 Source (cern.laser.business.data.Source)2 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)2 LaserDefinitionException (cern.laser.business.definition.LaserDefinitionException)2 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)2 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)2 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)2 ObjectMessage (javax.jms.ObjectMessage)2 TextMessage (javax.jms.TextMessage)2