Search in sources :

Example 16 with AlarmImpl

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

the class ACSAlarmDAOImpl method dumpReductionRules.

private void dumpReductionRules() {
    Vector<String> keys = new Vector<String>(alarmDefs.keySet());
    Collections.sort(keys);
    System.out.println("VVVVV Dumping reduction rules VVVVV");
    System.out.println("defined reduction rules: " + keys.size());
    for (String key : keys) {
        AlarmImpl alarm = (AlarmImpl) alarmDefs.get(key);
        System.out.println(alarm.getAlarmId());
        String[] nodeParents = alarm.getNodeParents();
        System.out.println("\tNODE parents");
        for (String id : nodeParents) {
            System.out.println("\t\t" + id);
        }
        String[] nodeChilds = alarm.getNodeChildren();
        System.out.println("\tNODE childs");
        for (String id : nodeChilds) {
            System.out.println("\t\t" + id);
        }
        String[] multiParents = alarm.getMultiplicityParents();
        System.out.println("\tMULTIPLICITY parents");
        for (String id : multiParents) {
            System.out.println("\t\t" + id);
        }
        String[] multiChilds = alarm.getMultiplicityChildren();
        System.out.println("\tMULTIPLICITY childs");
        for (String id : multiChilds) {
            System.out.println("\t\t" + id);
        }
        System.out.println("\tMULTIPLICITY threshold: " + alarm.getMultiplicityThreshold());
    }
    System.out.println("^^^^^                         ^^^^^");
}
Also used : AlarmImpl(cern.laser.business.data.AlarmImpl) Vector(java.util.Vector)

Example 17 with AlarmImpl

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

the class ACSAlarmCacheImpl method getCopy.

public Alarm getCopy(String identifier) throws AlarmCacheException {
    // This method get the reference to the object first and then
    // create a copy to return to the caller
    // The Alarm to return a copy of
    lock.lock();
    Alarm retAl;
    try {
        retAl = getReference(identifier);
        return (Alarm) (((AlarmImpl) retAl).clone());
    } finally {
        lock.unlock();
    }
}
Also used : Alarm(cern.laser.business.data.Alarm) AlarmImpl(cern.laser.business.data.AlarmImpl)

Example 18 with AlarmImpl

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

the class ACSAlarmDAOImpl method findAlarmIdsByPriority.

public String[] findAlarmIdsByPriority(Integer priority) {
    int p = priority.intValue();
    ArrayList result = null;
    Iterator i = alarmDefs.entrySet().iterator();
    while (i.hasNext()) {
        Map.Entry e = (Map.Entry) i.next();
        String id = e.getKey().toString();
        AlarmImpl ai = (AlarmImpl) e.getValue();
        if (ai.getPriority().intValue() == p) {
            if (result == null)
                result = new ArrayList();
            result.add(id);
        }
    }
    if (result == null) {
        return new String[0];
    } else {
        int s = result.size();
        String[] res = new String[s];
        result.toArray(res);
        return res;
    }
}
Also used : AlarmImpl(cern.laser.business.data.AlarmImpl) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 19 with AlarmImpl

use of cern.laser.business.data.AlarmImpl 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() {
    if (conf == null) {
        throw new IllegalStateException("Missing dal");
    }
    // The reduction rules (<parent, child>)
    ArrayList<LinkSpec> reductionRules = new ArrayList<LinkSpec>();
    String xml;
    try {
        xml = conf.getConfiguration(REDUCTION_DEFINITION_PATH);
    } catch (CDBRecordDoesNotExistEx cdbEx) {
        // No reduction rules defined in CDB
        logger.log(AcsLogLevel.WARNING, "No reduction rules defined in CDB");
        return;
    } catch (Exception e) {
        throw new RuntimeException("Couldn't read " + REDUCTION_DEFINITION_PATH, e);
    }
    ReductionDefinitions rds;
    try {
        rds = (ReductionDefinitions) ReductionDefinitions.unmarshalReductionDefinitions(new StringReader(xml));
    } catch (Exception e) {
        throw new RuntimeException("Couldn't parse " + REDUCTION_DEFINITION_PATH, e);
    }
    // Read the links to create from the CDB
    ReductionLinkDefinitionListType ltc = rds.getLinksToCreate();
    //	Read the thresholds from the CDB
    Thresholds thresholds = rds.getThresholds();
    if (ltc != null) {
        ReductionLinkType[] rls = ltc.getReductionLink();
        for (ReductionLinkType link : rls) {
            Parent p = link.getParent();
            Child c = link.getChild();
            if (p == null || c == null) {
                throw new RuntimeException("Missing child or parent in a reduction link");
            }
            boolean isMulti;
            if ("MULTIPLICITY".equals(link.getType())) {
                isMulti = true;
            } else if ("NODE".equals(link.getType())) {
                isMulti = false;
            } else {
                throw new RuntimeException("Unknown reduction-link type: " + link.getType());
            }
            if (p.getAlarmDefinition() == null || c.getAlarmDefinition() == null)
                throw new RuntimeException("Missing alarm-definition in child or parent");
            LinkSpec newRule = new LinkSpec(toMatcher(p.getAlarmDefinition()), toMatcher(c.getAlarmDefinition()), isMulti);
            reductionRules.add(newRule);
            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(newRule.parent.family + ", " + newRule.parent.member + ", " + newRule.parent.minCode + "-" + newRule.parent.minCode + ">");
            buf.append(" child=<" + newRule.child.family + ", " + newRule.child.member + ", " + newRule.child.minCode + "-" + newRule.child.minCode + ">");
            logger.log(AcsLogLevel.DEBUG, buf.toString());
        }
    }
    logger.log(AcsLogLevel.DEBUG, reductionRules.size() + " reduction rules read from CDB");
    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;
    int numls = ls.length;
    for (int a = 0; a < num; a++) {
        AlarmImpl parent = allAlarms[a];
        for (LinkSpec lsb : ls) {
            if (lsb.matchParent(parent)) {
                AlarmRefMatcher childMatcher = lsb.child;
                boolean isMulti = lsb.isMultiplicity();
                for (int c = 0; c < num; c++) {
                    if (a == c) {
                        continue;
                    }
                    AlarmImpl aic = allAlarms[c];
                    if (childMatcher.isMatch(aic)) {
                        if (isMulti) {
                            parent.addMultiplicityChild(aic);
                            logger.log(AcsLogLevel.DEBUG, "Added MULTI RR node child " + aic.getAlarmId() + " to " + parent.getAlarmId());
                        } else {
                            parent.addNodeChild(aic);
                            logger.log(AcsLogLevel.DEBUG, "Added NODE RR node child " + aic.getAlarmId() + " to " + parent.getAlarmId());
                        }
                    }
                }
            }
        }
    }
    if (thresholds != null && thresholds.getThresholdCount() > 0) {
        Threshold[] ta = thresholds.getThreshold();
        for (AlarmImpl alarm : allAlarms) {
            String alarmFF = alarm.getTriplet().getFaultFamily();
            String alarmFM = alarm.getTriplet().getFaultMember();
            Integer alarmFC = alarm.getTriplet().getFaultCode();
            for (Threshold threshold : ta) {
                String thresholdFF = threshold.getAlarmDefinition().getFaultFamily();
                String thresholdFM = threshold.getAlarmDefinition().getFaultMember();
                int thresholdFC = threshold.getAlarmDefinition().getFaultCode();
                int thresholdVal = threshold.getValue();
                if (alarmFF.equals(thresholdFF) && alarmFM.equals(thresholdFM) && alarmFC == thresholdFC) {
                    alarm.setMultiplicityThreshold(thresholdVal);
                    logger.log(AcsLogLevel.DEBUG, "Threshold = " + thresholdVal + " set in alarm " + alarm.getAlarmId());
                }
            }
        }
    }
}
Also used : Parent(alma.alarmsystem.alarmmessage.generated.Parent) ArrayList(java.util.ArrayList) ReductionDefinitions(alma.alarmsystem.alarmmessage.generated.ReductionDefinitions) CDBRecordDoesNotExistEx(alma.cdbErrType.CDBRecordDoesNotExistEx) ReductionLinkType(alma.alarmsystem.alarmmessage.generated.ReductionLinkType) StringReader(java.io.StringReader) Child(alma.alarmsystem.alarmmessage.generated.Child) Threshold(alma.alarmsystem.alarmmessage.generated.Threshold) Thresholds(alma.alarmsystem.alarmmessage.generated.Thresholds) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException) PatternSyntaxException(java.util.regex.PatternSyntaxException) ValidationException(org.exolab.castor.xml.ValidationException) MarshalException(org.exolab.castor.xml.MarshalException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Alarm(cern.laser.business.data.Alarm) AlarmImpl(cern.laser.business.data.AlarmImpl) ReductionLinkDefinitionListType(alma.alarmsystem.alarmmessage.generated.ReductionLinkDefinitionListType)

Example 20 with AlarmImpl

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

the class ReductionManagerTest method testSaveToCDB.

public void testSaveToCDB() {
    boolean exception;
    _alarmSystemManager.loadFromCDB();
    //ReductionManager.getInstance(_daoManager.getAlarmDAO());
    ReductionManager rm = _alarmSystemManager.getReductionManager();
    assertNotNull(rm);
    rm.loadFromCDB();
    exception = false;
    Alarm p = new AlarmImpl();
    Triplet tr = new Triplet("A1", "B1", 1);
    p.setTriplet(tr);
    Alarm c = new AlarmImpl();
    tr = new Triplet("A2", "B2", 2);
    c.setTriplet(tr);
    try {
        rm.addNodeReductionRule(p, c);
    //rm.deleteNodeReductionRule(p, c);
    } catch (IllegalOperationException e) {
        exception = true;
        e.printStackTrace();
    }
    assertFalse(exception);
    rm.saveToCDB();
}
Also used : Triplet(cern.laser.business.data.Triplet) Alarm(cern.laser.business.data.Alarm) AlarmImpl(cern.laser.business.data.AlarmImpl)

Aggregations

AlarmImpl (cern.laser.business.data.AlarmImpl)25 Alarm (cern.laser.business.data.Alarm)13 Triplet (cern.laser.business.data.Triplet)8 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)7 Source (cern.laser.business.data.Source)7 Location (cern.laser.business.data.Location)5 HashSet (java.util.HashSet)5 Category (cern.laser.business.data.Category)4 Building (cern.laser.business.data.Building)3 CategoryImpl (cern.laser.business.data.CategoryImpl)3 StatusImpl (cern.laser.business.data.StatusImpl)3 SourceDefinition (cern.laser.business.definition.data.SourceDefinition)3 MalformedURLException (java.net.MalformedURLException)3 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 Properties (java.util.Properties)3 Contact (alma.acs.alarmsystem.generated.Contact)2 FaultCode (alma.acs.alarmsystem.generated.FaultCode)2 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)2