Search in sources :

Example 51 with Alarm

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

the class AlarmPublisherImpl method publish.

public void publish(AlarmChange alarmChange) {
    if (alarmChange == null) {
        logger.log(AcsLogLevel.WARNING, "alarm change is null");
        return;
    }
    try {
        logger.log(AcsLogLevel.DEBUG, "publishing alarm change for " + alarmChange.getCurrent().getAlarmId() + ", active= " + alarmChange.getCurrent().getStatus().getActive());
        Alarm alarm = alarmChange.getCurrent();
        Alarm previous = alarmChange.getPrevious();
        Iterator iterator = alarm.getCategories().iterator();
        while (iterator.hasNext()) {
            Category category = (Category) iterator.next();
            String destination = categoryRootTopic + "." + category.getPath();
            Topic topic = getTopicSession().createTopic(destination);
            //ObjectMessage message = getTopicSession().createObjectMessage((AlarmImpl) alarm);
            TextMessage message = getTopicSession().createTextMessage();
            setMessageProperties(message, alarm);
            Status previous_alarm_status = previous.getStatus();
            Status current_alarm_status = alarm.getStatus();
            message.setObjectProperty("REDUCED_MASKED_SET", Boolean.FALSE);
            /**
         * change belongs to the reduced set if and only if the transition is from whatever to (ACTIVE, NOT REDUCED, NOT
         * MASKED) or from (ACTIVE, NOT REDUCED, NOT MASKED) to whatever else or if there was not a transition but a
         * change of something NOT REDUCED and NOT MASKED
         */
            if (current_alarm_status.getActive().booleanValue() && !(current_alarm_status.getMasked().booleanValue() || current_alarm_status.getReduced().booleanValue())) {
                // transition to (ACTIVE, NOT REDUCED, NOT MASKED) or change of
                // something NOT REDUCED and NOT MASKED
                message.setObjectProperty("REDUCED_MASKED_SET", Boolean.TRUE);
            } else {
                // else
                if (previous_alarm_status.getActive().booleanValue() && !(previous_alarm_status.getMasked().booleanValue() || previous_alarm_status.getReduced().booleanValue())) {
                    message.setObjectProperty("REDUCED_MASKED_SET", Boolean.TRUE);
                }
            }
            message.setObjectProperty("NOT_REDUCED_MASKED_SET", Boolean.FALSE);
            /**
         * change belongs to the not reduced set if an only if the transition was from ACTIVE to NOT ACTIVE or from NOT
         * ACTIVE to ACTIVE or if it was not triggered by reduction or mask flags
         */
            if (current_alarm_status.getActive().booleanValue() != previous_alarm_status.getActive().booleanValue()) {
                // transition from ACTIVE to NOT ACTIVE or from NOT ACTIVE to ACTIVE
                message.setObjectProperty("NOT_REDUCED_MASKED_SET", Boolean.TRUE);
            } else if (current_alarm_status.getActive().booleanValue() && (current_alarm_status.getMasked().booleanValue() == previous_alarm_status.getMasked().booleanValue()) && (current_alarm_status.getReduced().booleanValue() == previous_alarm_status.getReduced().booleanValue())) {
                // change not triggered by reduction or mask flags
                message.setObjectProperty("NOT_REDUCED_MASKED_SET", Boolean.TRUE);
            }
            // I insert the xml representation of this object
            // in the text field of the message
            String xml = AlarmMessageConversion.getXML((AlarmImpl) alarm);
            message.setText(xml);
            getTopicPublisher().publish(topic, message);
            logger.log(AcsLogLevel.DEBUG, "change published on : " + destination);
        }
    } catch (Exception e) {
        logger.log(AcsLogLevel.ERROR, "unable to publish", e);
        close();
    }
}
Also used : Status(cern.laser.business.data.Status) Category(cern.laser.business.data.Category) Alarm(cern.laser.business.data.Alarm) 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)

Example 52 with Alarm

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

the class AlarmSourceMonitorImpl method check.

public void check() {
    try {
        LOGGER.debug("checking sources...");
        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.isEnabled().booleanValue()) {
                    if (source.getStatus().getLastContact() == null) {
                        source.getStatus().setLastContact(new Timestamp(System.currentTimeMillis()));
                    }
                    if (((System.currentTimeMillis() - source.getStatus().getLastContact().getTime()) > source.getConnectionTimeout().longValue())) {
                        if (source.isConnected().booleanValue()) {
                            // generate surveillance alarm
                            Alarm surveillance_alarm = alarmCache.getCopy(source.getSurveillanceAlarmId());
                            FaultState surveillance_fs = AlarmSystemInterfaceFactory.createFaultState(surveillance_alarm.getTriplet().getFaultFamily(), surveillance_alarm.getTriplet().getFaultMember(), surveillance_alarm.getTriplet().getFaultCode().intValue());
                            Timestamp timestamp = new Timestamp(System.currentTimeMillis());
                            surveillance_fs.setDescriptor(FaultState.ACTIVE);
                            surveillance_fs.setUserTimestamp(timestamp);
                            LOGGER.warn("generating surveillance alarm :\n" + surveillance_fs);
                            alarmMessageProcessor.processChange(surveillance_fs, surveillance_alarm.getSource().getName(), InetAddress.getLocalHost().getHostName(), timestamp);
                            // set not connected
                            source.getStatus().setConnected(Boolean.FALSE);
                        }
                    } else {
                        if (!source.isConnected().booleanValue()) {
                            // terminate surveillance alarm
                            Alarm surveillance_alarm = alarmCache.getCopy(source.getSurveillanceAlarmId());
                            FaultState surveillance_fs = AlarmSystemInterfaceFactory.createFaultState(surveillance_alarm.getTriplet().getFaultFamily(), surveillance_alarm.getTriplet().getFaultMember(), surveillance_alarm.getTriplet().getFaultCode().intValue());
                            Timestamp timestamp = new Timestamp(System.currentTimeMillis());
                            surveillance_fs.setDescriptor(FaultState.TERMINATE);
                            surveillance_fs.setUserTimestamp(timestamp);
                            LOGGER.warn("generating surveillance alarm :\n" + surveillance_fs);
                            alarmMessageProcessor.processChange(surveillance_fs, surveillance_alarm.getSource().getName(), InetAddress.getLocalHost().getHostName(), timestamp);
                            // set connected
                            source.getStatus().setConnected(Boolean.TRUE);
                        }
                    }
                }
            }
        }
        LOGGER.debug("sources checked");
    } catch (Exception e) {
        throw new LaserRuntimeException("unable to check sources", e);
    }
}
Also used : Alarm(cern.laser.business.data.Alarm) FaultState(cern.laser.source.alarmsysteminterface.FaultState) Timestamp(java.sql.Timestamp) Source(cern.laser.business.data.Source) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserRuntimeException(cern.laser.business.LaserRuntimeException)

Example 53 with Alarm

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

the class AlarmMessageProcessorImpl method hasTooManyActiveMultiplicityChildren.

private boolean hasTooManyActiveMultiplicityChildren(Alarm alarm) throws Exception {
    int active_children = 0;
    String[] children = alarm.getMultiplicityChildren();
    for (int i = 0; i < children.length; i++) {
        Alarm child = alarmCache.getReference(children[i]);
        if (child.getStatus().getActive().booleanValue()) {
            active_children++;
        }
    }
    return (active_children > alarm.getMultiplicityThreshold().intValue());
}
Also used : Alarm(cern.laser.business.data.Alarm)

Example 54 with Alarm

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

the class AlarmMessageProcessorImpl method notifyMultiplicityParents.

private void notifyMultiplicityParents(Alarm alarm) throws Exception {
    String[] parents = alarm.getMultiplicityParents();
    for (int i = 0; i < parents.length; i++) {
        Alarm parent = alarmCache.getCopy(parents[i]);
        logger.log(AcsLogLevel.DEBUG, "notifying multiplicity parent " + parent.getTriplet());
        updateMultiplicityNode(parent);
    }
}
Also used : Alarm(cern.laser.business.data.Alarm)

Example 55 with Alarm

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

the class AlarmMessageProcessorImpl method dumpAlarmReductionStatus.

/** 
   * Print on the stdout the state of the reduction of the passed alarm.
   * 
   * @param alarm
   */
private void dumpAlarmReductionStatus(Alarm alarm) throws AlarmCacheException {
    System.out.print("Reduction state of " + alarm.getAlarmId() + ", active=" + alarm.getStatus().getActive());
    System.out.print(", isReduced=" + alarm.getStatus().getReduced());
    System.out.println(", isMasked=" + alarm.getStatus().getMasked());
    System.out.println("NODE Parents:");
    String[] nodeP = alarm.getNodeParents();
    for (String id : nodeP) {
        Alarm parent = alarmCache.getReference(id);
        dumpAlarm(parent);
    }
    System.out.println("NODE Childs:");
    String[] nodeC = alarm.getNodeChildren();
    for (String id : nodeC) {
        Alarm child = alarmCache.getReference(id);
        dumpAlarm(child);
    }
    System.out.println("MULTIPLICITY Parents:");
    String[] multiP = alarm.getMultiplicityParents();
    for (String id : multiP) {
        Alarm parent = alarmCache.getReference(id);
        dumpAlarm(parent);
    }
    System.out.println("MULTIPLICITY Childs:");
    String[] multiC = alarm.getMultiplicityChildren();
    for (String id : multiC) {
        Alarm child = alarmCache.getReference(id);
        dumpAlarm(child);
    }
}
Also used : Alarm(cern.laser.business.data.Alarm)

Aggregations

Alarm (cern.laser.business.data.Alarm)91 AlarmCacheException (cern.laser.business.cache.AlarmCacheException)24 LaserRuntimeException (cern.laser.business.LaserRuntimeException)21 ArrayList (java.util.ArrayList)21 Category (cern.laser.business.data.Category)16 Collection (java.util.Collection)14 AlarmImpl (cern.laser.business.data.AlarmImpl)13 LaserDefinitionNotValidException (cern.laser.business.definition.LaserDefinitionNotValidException)12 AdminUser (cern.laser.business.data.AdminUser)11 AlarmDefinition (alma.alarmsystem.alarmmessage.generated.AlarmDefinition)10 LaserDefinitionDuplicationException (cern.laser.business.definition.LaserDefinitionDuplicationException)10 LaserDefinitionNotFoundException (cern.laser.business.definition.LaserDefinitionNotFoundException)10 Iterator (java.util.Iterator)10 LaserProcessingException (cern.laser.business.LaserProcessingException)9 LaserDefinitionNotAllowedException (cern.laser.business.definition.LaserDefinitionNotAllowedException)9 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)7 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)7 FaultCode (alma.acs.alarmsystem.generated.FaultCode)6 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)6 FaultMember (alma.acs.alarmsystem.generated.FaultMember)6