Search in sources :

Example 6 with Alarm

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

the class AlarmDefinitionServiceImpl method createMultiplicityLinkInternal.

private void createMultiplicityLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
    Alarm[] parent_child = validateReductionLink(link);
    //alarmDAO.findAlarm(link.getParent().getAlarmId());
    Alarm parent = parent_child[0];
    //alarmDAO.findAlarm(link.getChild().getAlarmId());
    Alarm child = parent_child[1];
    if (((AlarmImpl) parent).getMultiplicityChildrenIds().contains(child.getAlarmId())) {
        throw new LaserDefinitionDuplicationException("reduction child " + link.getChild().getAlarmId() + " does not exist");
    }
    AdminUser admin_user = adminUserDAO.findAdminUser(userId);
    LOGGER.info("user " + admin_user.getName() + " creating multiplicity link : " + link);
    parent.addMultiplicityChild(child);
    alarmDAO.updateAlarm(parent);
    LOGGER.info("multiplicity link created");
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser) LaserDefinitionDuplicationException(cern.laser.business.definition.LaserDefinitionDuplicationException)

Example 7 with Alarm

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

the class AlarmMessageProcessorImpl method notifyNodeChildren.

private void notifyNodeChildren(Alarm alarm) throws Exception {
    String[] children = alarm.getNodeChildren();
    for (int i = 0; i < children.length; i++) {
        Alarm child = alarmCache.getCopy(children[i]);
        logger.log(AcsLogLevel.DEBUG, "notifying node child " + child.getTriplet());
        if (hasActiveNodeParents(child)) {
            if (child.getStatus().getReduced().equals(Boolean.FALSE)) {
                logger.log(AcsLogLevel.DEBUG, "reducing node child " + child.getTriplet());
                child.getStatus().setReduced(Boolean.TRUE);
                alarmCache.put(child);
            }
        } else {
            if (child.getStatus().getReduced().equals(Boolean.TRUE)) {
                logger.log(AcsLogLevel.DEBUG, "unreducing node child " + child.getTriplet());
                child.getStatus().setReduced(Boolean.FALSE);
                alarmCache.put(child);
            }
        }
    }
}
Also used : Alarm(cern.laser.business.data.Alarm)

Example 8 with Alarm

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

the class AlarmMessageProcessorImpl method processChange.

public void processChange(FaultState faultState, String sourceName, String sourceHostname, Timestamp sourceTimestamp) throws Exception {
    alarmCache.acquire();
    try {
        logger.log(AcsLogLevel.DEBUG, "processing fault state: " + faultState.getFamily() + ":" + faultState.getMember() + ":" + faultState.getCode() + ", Descriptor=" + faultState.getDescriptor() + "\n");
        Timestamp system_timestamp = new Timestamp(System.currentTimeMillis());
        Alarm alarm = alarmCache.getCopy(Triplet.toIdentifier(faultState.getFamily(), faultState.getMember(), Integer.valueOf(faultState.getCode())));
        // process the change
        String defined_source_name = alarm.getSource().getName();
        if (!defined_source_name.equals(sourceName)) {
            logger.log(AcsLogLevel.ERROR, "source name mismatch : received " + sourceName + ", should be " + defined_source_name + ".\nFault State was discarded :\n" + faultState);
        } else {
            Status current_status = alarm.getStatus();
            boolean ordered = true;
            // check if fault state changes were received in the right order
            if ((current_status.getUserTimestamp() != null) && (faultState.getUserTimestamp() != null)) {
                if (faultState.getUserTimestamp().before(current_status.getUserTimestamp())) {
                    logger.log(AcsLogLevel.ERROR, "user timestamp not ordered : received " + faultState.getUserTimestamp() + ", was " + current_status.getUserTimestamp() + ".\nFault State was discarded :\n" + faultState);
                    ordered = false;
                }
            } else {
                if (sourceTimestamp.before(current_status.getSourceTimestamp())) {
                    logger.log(AcsLogLevel.ERROR, "source timestamp not ordered : received " + sourceTimestamp + ", was " + current_status.getSourceTimestamp() + ".\nFault State was discarded :\n" + faultState);
                    ordered = false;
                }
            }
            if (ordered) {
                //        StatusImpl new_status = null;
                //        StatusImpl alarm_status = alarm.getStatus();
                boolean notify_reduction_relatives = false;
                boolean alarm_updated = false;
                if (alarm.getInstant().booleanValue()) {
                    if (faultState.getDescriptor().equalsIgnoreCase(FaultState.INSTANT)) {
                        // process INSTANT fault state
                        updateStatus(faultState, current_status, Boolean.TRUE, sourceHostname, sourceTimestamp, system_timestamp);
                        alarm_updated = true;
                    //            new_status = new StatusImpl(Boolean.TRUE, current_status.getMasked(), current_status.getReduced(), new
                    // Boolean(
                    //                faultState.getActivatedByBackup()), new Boolean(faultState.getTerminatedByBackup()), sourceHostname,
                    //                sourceTimestamp, faultState.getUserTimestamp(), system_timestamp, faultState.getUserProperties());
                    } else {
                        logger.log(AcsLogLevel.ERROR, "invalid fault descriptor : received " + faultState.getDescriptor() + "  while expecting " + FaultState.INSTANT + ".\nFault State was discarded :\n" + faultState);
                    }
                } else {
                    if (faultState.getDescriptor().equalsIgnoreCase(FaultState.ACTIVE)) {
                        // process ACTIVE fault state
                        if (alarm.getStatus().getActive().equals(Boolean.FALSE)) {
                            updateStatus(faultState, current_status, Boolean.TRUE, sourceHostname, sourceTimestamp, system_timestamp);
                            //              new_status = new StatusImpl(Boolean.TRUE, current_status.getMasked(), current_status.getReduced(),
                            //                  new Boolean(faultState.getActivatedByBackup()), new Boolean(faultState.getTerminatedByBackup()),
                            //                  sourceHostname, sourceTimestamp, faultState.getUserTimestamp(), system_timestamp, faultState
                            //                      .getUserProperties());
                            notify_reduction_relatives = true;
                            alarm_updated = true;
                        } else {
                            logger.log(AcsLogLevel.WARNING, "Alarm already active: Fault State " + alarm.getAlarmId() + " discarded");
                        }
                    } else if (faultState.getDescriptor().equalsIgnoreCase(FaultState.TERMINATE)) {
                        // process TERMINATE fault state
                        if (alarm.getStatus().getActive().equals(Boolean.TRUE)) {
                            updateStatus(faultState, current_status, Boolean.FALSE, sourceHostname, sourceTimestamp, system_timestamp);
                            //              new_status = new StatusImpl(Boolean.FALSE, current_status.getMasked(), current_status.getReduced(),
                            //                  new Boolean(faultState.getActivatedByBackup()), new Boolean(faultState.getTerminatedByBackup()),
                            //                  sourceHostname, sourceTimestamp, faultState.getUserTimestamp(), system_timestamp, faultState
                            //                      .getUserProperties());
                            notify_reduction_relatives = true;
                            alarm_updated = true;
                        } else {
                            logger.log(AcsLogLevel.WARNING, "Alarm already terminated: Fault State " + alarm.getAlarmId() + " discarded");
                        }
                    } else if (faultState.getDescriptor().equalsIgnoreCase(FaultState.CHANGE)) {
                        // process CHANGE fault state
                        if (alarm.getStatus().getActive().equals(Boolean.FALSE)) {
                            logger.log(AcsLogLevel.ERROR, "changed alarm was terminated : " + alarm.getAlarmId());
                            notify_reduction_relatives = true;
                        } else {
                            updateStatus(faultState, current_status, Boolean.TRUE, sourceHostname, sourceTimestamp, system_timestamp);
                            //            new_status = new StatusImpl(Boolean.TRUE, current_status.getMasked(), current_status.getReduced(), new
                            // Boolean(
                            //                faultState.getActivatedByBackup()), new Boolean(faultState.getTerminatedByBackup()), sourceHostname,
                            //                sourceTimestamp, faultState.getUserTimestamp(), system_timestamp, faultState.getUserProperties());
                            alarm_updated = true;
                        }
                    } else {
                        logger.log(AcsLogLevel.ERROR, "invalid fault descriptor : received " + faultState.getDescriptor() + "  while expecting " + FaultState.ACTIVE + "|" + FaultState.TERMINATE + "|" + FaultState.CHANGE + ".\nFault State was discarded :\n" + faultState);
                    }
                }
                //        if (new_status != null) {
                if (alarm_updated) {
                    //          alarm.setStatus(new_status);
                    logger.log(AcsLogLevel.DEBUG, "applying change...");
                    if (alarm.getSource() != null && sourceHostname != null) {
                        alarm.getSource().setHostName(sourceHostname.toLowerCase());
                    }
                    alarmCache.put(alarm);
                    if (notify_reduction_relatives) {
                        notifyReductionRelatives(alarm);
                    }
                }
            }
        }
    } finally {
        alarmCache.release();
        logger.log(AcsLogLevel.DEBUG, "processed fault state:" + faultState.getFamily() + ":" + faultState.getMember() + ":" + faultState.getCode() + ", Descriptor=" + faultState.getDescriptor() + "\n");
    }
}
Also used : Status(cern.laser.business.data.Status) Alarm(cern.laser.business.data.Alarm) Timestamp(java.sql.Timestamp)

Example 9 with Alarm

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

the class AlarmDefinitionServiceImpl method removeMultiplicityLinkInternal.

private void removeMultiplicityLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
    Alarm[] parent_child = validateReductionLink(link);
    AdminUser admin_user = adminUserDAO.findAdminUser(userId);
    LOGGER.info("user " + admin_user.getName() + " removing multiplicity link : " + link);
    //alarmDAO.findAlarm(link.getParent().getAlarmId());
    Alarm parent = parent_child[0];
    //alarmDAO.findAlarm(link.getChild().getAlarmId());
    Alarm child = parent_child[1];
    parent.removeMultiplicityChild(child);
    alarmDAO.updateAlarm(parent);
    LOGGER.info("multiplicity link removed");
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser)

Example 10 with Alarm

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

the class AlarmDefinitionServiceImpl method removeNodeLinkInternal.

private void removeNodeLinkInternal(String userId, ReductionLink link) throws LaserDefinitionException {
    Alarm[] parent_child = validateReductionLink(link);
    AdminUser admin_user = adminUserDAO.findAdminUser(userId);
    LOGGER.info("user " + admin_user.getName() + " removing node link : " + link);
    //alarmDAO.findAlarm(link.getParent().getAlarmId());
    Alarm parent = parent_child[0];
    //alarmDAO.findAlarm(link.getChild().getAlarmId());
    Alarm child = parent_child[1];
    parent.removeNodeChild(child);
    alarmDAO.updateAlarm(parent);
    LOGGER.info("node link removed");
}
Also used : Alarm(cern.laser.business.data.Alarm) AdminUser(cern.laser.business.data.AdminUser)

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