Search in sources :

Example 1 with LinkSpec

use of com.cosylab.acs.laser.dao.utils.LinkSpec in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method updateAlarmReductionRule.

/**
	 * Update the reduction rules involving the passed alarm
	 * 
	 * @param alarm The parent alarm whose reduction rule has to be
	 *  			updated
	 */
private void updateAlarmReductionRule(AlarmImpl alarm) {
    if (alarm == null) {
        throw new IllegalArgumentException("The passed alarm can't be null");
    }
    Collection<Alarm> cc = alarmDefs.values();
    AlarmImpl[] allAlarms = new AlarmImpl[cc.size()];
    cc.toArray(allAlarms);
    int num = allAlarms.length;
    LinkSpec[] ls = new LinkSpec[reductionRules.size()];
    reductionRules.toArray(ls);
    for (LinkSpec lsb : ls) {
        if (lsb.matchChild(alarm)) {
            AlarmRefMatcher parentMatcher = lsb._parent;
            boolean isMulti = lsb.isMultiplicity();
            for (int c = 0; c < num; c++) {
                if (alarm.getAlarmId().equals(allAlarms[c].getAlarmId())) {
                    continue;
                }
                AlarmImpl aic = allAlarms[c];
                if (parentMatcher.isMatch(aic)) {
                    if (isMulti) {
                        addMultiplicityChild(aic, alarm);
                        aic.setMultiplicityThreshold(theThreshods.get(aic.getAlarmId()));
                    } else {
                        addNodeChild(aic, alarm);
                    }
                }
            }
        } else if (lsb.matchParent(alarm)) {
            AlarmRefMatcher childMatcher = lsb._child;
            boolean isMulti = lsb.isMultiplicity();
            for (int c = 0; c < num; c++) {
                if (alarm.getAlarmId().equals(allAlarms[c].getAlarmId())) {
                    continue;
                }
                AlarmImpl aic = allAlarms[c];
                if (childMatcher.isMatch(aic)) {
                    if (isMulti) {
                        addMultiplicityChild(alarm, aic);
                        alarm.setMultiplicityThreshold(theThreshods.get(alarm.getAlarmId()));
                    } else {
                        addNodeChild(alarm, aic);
                    }
                }
            }
        }
    }
}
Also used : LinkSpec(com.cosylab.acs.laser.dao.utils.LinkSpec) Alarm(cern.laser.business.data.Alarm) AlarmImpl(cern.laser.business.data.AlarmImpl) AlarmRefMatcher(com.cosylab.acs.laser.dao.utils.AlarmRefMatcher)

Example 2 with LinkSpec

use of com.cosylab.acs.laser.dao.utils.LinkSpec in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method updateReductionRules.

/**
	 * Update the reduction rules.
	 * <P> 
	 * Reduction rules have the property that the parent is:
	 * <UL>
	 * 	<LI>always one single node 
	 *  <LI>is never a wildcard neither a regular expression
	 * </UL>
	 * 
	 * <P>
	 * <I>Performance notes</I>: at the OSF we had problems loading the configuration and
	 * creating an alarm from the default. In both cases the problems were in this method.
	 * To improve performances we made several changes and found that
	 * <UL>
	 * 	<LI>iterate over an array is faster then iterating over a {@link Collection}
	 *  <LI>comparing String seems slower then checking regurlar expression (once that it has been compiled into a pattern)  
	 * <UL>
	 */
private void updateReductionRules() {
    Collection<Alarm> cc = alarmDefs.values();
    AlarmImpl[] allAlarms = new AlarmImpl[cc.size()];
    cc.toArray(allAlarms);
    LinkSpec[] ls = new LinkSpec[reductionRules.size()];
    reductionRules.toArray(ls);
    int num = allAlarms.length;
    logger.log(AcsLogLevel.DEBUG, "Updating all expanded alarms with RR information");
    // Iterate over the alarms 
    for (int a = 0; a < num; a++) {
        for (LinkSpec lsb : ls) {
            if (lsb.matchChild(allAlarms[a])) {
                // This alarm is a child in this reduction rule lsb, let's
                // get the parent from the reduction rule itself
                String alarmParentID = lsb._parent.getMatcherAlarmID();
                Alarm parent = alarmDefs.get(alarmParentID);
                if (parent != null) {
                    if (lsb.isMultiplicity()) {
                        addMultiplicityChild(parent, allAlarms[a]);
                        parent.setMultiplicityThreshold(theThreshods.get(parent.getAlarmId()));
                    } else {
                        addNodeChild(parent, allAlarms[a]);
                    }
                } else {
                }
            }
        }
    }
    logger.log(AcsLogLevel.DEBUG, "All alarms updated with RR information");
}
Also used : LinkSpec(com.cosylab.acs.laser.dao.utils.LinkSpec) Alarm(cern.laser.business.data.Alarm) AlarmImpl(cern.laser.business.data.AlarmImpl)

Example 3 with LinkSpec

use of com.cosylab.acs.laser.dao.utils.LinkSpec in project ACS by ACS-Community.

the class ACSAlarmDAOImpl method loadReductionRules.

/**
	 * Load the reduction rules from the CDB.
	 * 
	 * Read the reduction rules from the CDB and set up the alarms accordingly
	 */
private void loadReductionRules() {
    ReductionDefinitions rds = getReductionDefinitions();
    if (rds == null)
        return;
    // Read the links to create from the CDB
    ReductionLinkDefinitionListType ltc = rds.getLinksToCreate();
    //	Read the thresholds from the CDB
    Thresholds thresholds = rds.getThresholds();
    if (thresholds != null) {
        // Store the thresholds in the HashMap
        Threshold[] threshold = thresholds.getThreshold();
        for (Threshold t : threshold) {
            StringBuilder alarmID = new StringBuilder();
            alarmID.append(t.getAlarmDefinition().getFaultFamily());
            alarmID.append(':');
            alarmID.append(t.getAlarmDefinition().getFaultMember());
            alarmID.append(':');
            alarmID.append(t.getAlarmDefinition().getFaultCode());
            Integer thresholdValue = Integer.valueOf(t.getValue());
            theThreshods.put(alarmID.toString(), thresholdValue);
        }
    }
    if (ltc != null) {
        ReductionLinkType[] rls = ltc.getReductionLink();
        for (ReductionLinkType link : rls) {
            LinkSpec newRule = new LinkSpec(link);
            reductionRules.add(newRule);
            if (logger.isLoggable(AcsLogLevel.DEBUG)) {
                Parent p = link.getParent();
                Child c = link.getChild();
                StringBuffer buf = new StringBuffer();
                buf.replace(0, buf.length(), "");
                if (newRule._isMultiplicity) {
                    buf.append("Found MULTIPLICITY RR: parent <");
                } else {
                    buf.append("Found NODE RR: parent=<");
                }
                buf.append(p.getAlarmDefinition().getFaultFamily());
                buf.append(", ");
                buf.append(p.getAlarmDefinition().getFaultMember());
                buf.append(", ");
                buf.append(p.getAlarmDefinition().getFaultCode());
                buf.append("> child=<");
                buf.append(c.getAlarmDefinition().getFaultFamily());
                buf.append(", ");
                buf.append(c.getAlarmDefinition().getFaultMember());
                buf.append(", ");
                buf.append(c.getAlarmDefinition().getFaultCode());
                buf.append('>');
                logger.log(AcsLogLevel.DEBUG, buf.toString());
            }
        }
    }
    logger.log(AcsLogLevel.DEBUG, reductionRules.size() + " reduction rules read from CDB");
    updateReductionRules();
}
Also used : Thresholds(alma.alarmsystem.alarmmessage.generated.Thresholds) Parent(alma.alarmsystem.alarmmessage.generated.Parent) ReductionDefinitions(alma.alarmsystem.alarmmessage.generated.ReductionDefinitions) ReductionLinkType(alma.alarmsystem.alarmmessage.generated.ReductionLinkType) LinkSpec(com.cosylab.acs.laser.dao.utils.LinkSpec) ReductionLinkDefinitionListType(alma.alarmsystem.alarmmessage.generated.ReductionLinkDefinitionListType) Child(alma.alarmsystem.alarmmessage.generated.Child) Threshold(alma.alarmsystem.alarmmessage.generated.Threshold)

Aggregations

LinkSpec (com.cosylab.acs.laser.dao.utils.LinkSpec)3 Alarm (cern.laser.business.data.Alarm)2 AlarmImpl (cern.laser.business.data.AlarmImpl)2 Child (alma.alarmsystem.alarmmessage.generated.Child)1 Parent (alma.alarmsystem.alarmmessage.generated.Parent)1 ReductionDefinitions (alma.alarmsystem.alarmmessage.generated.ReductionDefinitions)1 ReductionLinkDefinitionListType (alma.alarmsystem.alarmmessage.generated.ReductionLinkDefinitionListType)1 ReductionLinkType (alma.alarmsystem.alarmmessage.generated.ReductionLinkType)1 Threshold (alma.alarmsystem.alarmmessage.generated.Threshold)1 Thresholds (alma.alarmsystem.alarmmessage.generated.Thresholds)1 AlarmRefMatcher (com.cosylab.acs.laser.dao.utils.AlarmRefMatcher)1