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);
}
}
}
}
}
}
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();
}
}
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;
}
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;
}
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");
}
Aggregations