Search in sources :

Example 26 with Alarm

use of cern.laser.business.data.Alarm 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 27 with Alarm

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

the class ACSAlarmCacheImpl method put.

public void put(Alarm alarm) throws AlarmCacheException {
    lock.lock();
    try {
        if (alarm == null) {
            throw new IllegalArgumentException("Inserting a null alarm is not allowed");
        }
        Alarm oldAl = alarms.put(alarm.getTriplet().toIdentifier(), alarm);
        dao.updateAlarm(alarm);
        updateCategoryActiveLists(alarm);
        sendMsgToListener(alarm, oldAl);
    //dumpAlarmsCache(false);
    } finally {
        lock.unlock();
    }
}
Also used : Alarm(cern.laser.business.data.Alarm)

Example 28 with Alarm

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

the class CoreServiceImpl method getAlarmsByPriority.

/*
   * (non-Javadoc)
   * 
   * @see cern.laser.business.ejb.CoreServiceSessionEJB#getAlarmsByPriority(java.lang.Integer)
   */
public Collection getAlarmsByPriority(Integer priority) {
    Collection result = null;
    try {
        String[] alarm_ids = alarmDAO.findAlarmIdsByPriority(priority);
        result = new ArrayList(alarm_ids.length);
        for (int i = 0; i < alarm_ids.length; i++) {
            Alarm alarm = alarmCache.getReference(alarm_ids[i]);
            result.add(alarm);
        }
    } catch (Exception e) {
        LOGGER.error("unable to get alarms by priority " + priority, e);
    //throw new EJBException("unable to get alarms by priority " + priority, e);
    }
    return result;
}
Also used : Alarm(cern.laser.business.data.Alarm) ArrayList(java.util.ArrayList) Collection(java.util.Collection) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserProcessingException(cern.laser.business.LaserProcessingException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 29 with Alarm

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

the class CoreServiceImpl method getMultiplicityChildren.

/*
   * (non-Javadoc)
   * 
   * @see cern.laser.business.ejb.CoreServiceSessionEJB#getMultiplicityChildren(java.lang.Integer)
   */
public Collection getMultiplicityChildren(String parentId) {
    Collection result = null;
    try {
        Alarm parent = alarmCache.getReference(parentId);
        String[] children = parent.getMultiplicityChildren();
        result = new ArrayList(children.length);
        for (int i = 0; i < children.length; i++) {
            Alarm alarm = alarmCache.getReference(children[i]);
            result.add(alarm);
        }
    } catch (AlarmCacheException onf) {
        LOGGER.warn("multiplicity parent " + parentId + " not found");
        result = new ArrayList();
    } catch (Exception e) {
        LOGGER.error("unable to get multiplicity children for " + parentId, e);
    //throw new EJBException("unable to get multiplicity children for " + parentId, e);
    }
    return result;
}
Also used : Alarm(cern.laser.business.data.Alarm) ArrayList(java.util.ArrayList) Collection(java.util.Collection) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) LaserRuntimeException(cern.laser.business.LaserRuntimeException) LaserProcessingException(cern.laser.business.LaserProcessingException) AlarmCacheException(cern.laser.business.cache.AlarmCacheException)

Example 30 with Alarm

use of cern.laser.business.data.Alarm 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)

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