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