Search in sources :

Example 61 with Alarm

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

the class CoreServiceImpl method getAlarmsByCategory.

/*
   * (non-Javadoc)
   * 
   * @see cern.laser.business.ejb.CoreServiceSessionEJB#getAlarmsByCategory(java.lang.Integer)
   */
public Collection getAlarmsByCategory(Integer categoryId) {
    Collection result = null;
    //    Category category = categoryDAO.getCategory(categoryId);
    //    if (category != null) {
    String[] alarms = categoryDAO.getAlarms(categoryId);
    result = new ArrayList(alarms.length);
    for (int i = 0; i < alarms.length; i++) {
        Alarm alarm;
        try {
            alarm = alarmCache.getReference(alarms[i]);
        } catch (AlarmCacheException e) {
            LOGGER.error("unable to get alarm " + alarms[i] + " from cache", e);
            throw new LaserRuntimeException("unable to get alarm " + alarms[i] + " from cache", e);
        }
        result.add(alarm);
    }
    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)

Example 62 with Alarm

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

the class ACSAlarmCacheImpl method getReference.

/**
	 * Get a reference to the alarm with the passed identifier.
	 * The alarm is searched in the configuration database delegating
	 * to the {@link ACSAlarmDAOImpl}.
	 * <P>
	 * If the alarm is not found then an alarm is built to be sent to the client
	 * but it is marked with a special property to identify it as a misconfigured 
	 * alarm. In the case of the alarm panel, such alarms will be displayed in a 
	 * dedicated tab.
	 * 
	 * @param identifier The ID of the alarm to get from the cache
	 */
public Alarm getReference(String identifier) throws AlarmCacheException {
    lock.lock();
    Alarm retAl;
    try {
        // Check the integrity of internal data structs
        if (alarms == null || dao == null) {
            System.err.println("*** ACSAlarmCache internal data corrupted!");
            throw new AlarmCacheException("ACSAlarmCache internal data corrupted!");
        }
        if (!alarms.containsKey(identifier)) {
            // Get the alarm from the database
            try {
                retAl = (Alarm) dao.findAlarm(identifier);
            } catch (LaserObjectNotFoundException lonfe) {
                // The alarm is not in the configuration database
                //
                // Built an alarm to be sent to the clients 
                // with an special property
                logger.finer(identifier + " is not in TM/CDB: building an unconfigured alarm");
                retAl = buildUnconfiguredAlarm(identifier);
            } catch (Throwable t) {
                System.err.println("*** Exception reading from CDB " + t.getMessage());
                throw new AlarmCacheException(t.getMessage());
            }
            if (retAl == null) {
                System.err.println("*** Alarm not found in database");
                throw new AlarmCacheException("Alarm not found in database");
            } else {
                // Add the alarm to the cache
                alarms.put(identifier, retAl);
            }
        } else {
            // Get the alarm from the cache
            retAl = alarms.get(identifier);
        }
        if (retAl == null) {
            System.err.println("*** Invalid Alarm");
            throw new AlarmCacheException("Invalid Alarm");
        }
        return retAl;
    } finally {
        lock.unlock();
    }
}
Also used : Alarm(cern.laser.business.data.Alarm) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) LaserObjectNotFoundException(cern.laser.business.LaserObjectNotFoundException)

Example 63 with Alarm

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

the class ACSAlarmDAOImpl method findAlarmIdsByPriority.

public String[] findAlarmIdsByPriority(Integer priority) {
    int p = priority.intValue();
    ArrayList<String> result = null;
    Iterator<Entry<String, Alarm>> i = alarmDefs.entrySet().iterator();
    while (i.hasNext()) {
        Entry<String, Alarm> e = i.next();
        String id = e.getKey().toString();
        AlarmImpl ai = (AlarmImpl) e.getValue();
        if (ai.getPriority().intValue() == p) {
            if (result == null)
                result = new ArrayList<String>();
            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 : Entry(java.util.Map.Entry) Alarm(cern.laser.business.data.Alarm) AlarmImpl(cern.laser.business.data.AlarmImpl) ArrayList(java.util.ArrayList)

Example 64 with Alarm

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

the class ACSAlarmDAOImpl method dumpAlarmCache.

private void dumpAlarmCache() {
    Vector<String> keys = new Vector<String>(alarmDefs.keySet());
    Collections.sort(keys);
    System.out.println("VVVVV ACSAlarmDAOImpl:: Alarms in cache VVVVV");
    System.out.println("Number of alarms in cache: " + keys.size());
    for (String key : keys) {
        Alarm alarm = alarmDefs.get(key);
        System.out.print("\t" + key);
        System.out.print(" active=" + alarm.getStatus().getActive());
        System.out.print(" masked=" + alarm.getStatus().getMasked());
        System.out.println(" reduced=" + alarm.getStatus().getReduced());
    }
    System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^");
}
Also used : Alarm(cern.laser.business.data.Alarm) Vector(java.util.Vector)

Example 65 with Alarm

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

the class CoreServiceImpl method select.

//
// -- PRIVATE METHODS ---------------------------------------------
//
/*
   * (non-Javadoc)
   * 
   * @see cern.laser.business.ejb.CoreServiceSessionEJB#select(java.lang.Integer, java.lang.String)
   */
private void select(Integer categoryId, String clientId) throws LaserProcessingException {
    System.out.println("*** CoreServiceImpl::select: selecting category " + categoryId.toString() + " for client " + clientId);
    ProcessingController processingController = ProcessingController.getInstance();
    if (!processingController.isProcessing()) {
        throw new LaserProcessingException("server not initialized");
    }
    try {
        if (LOGGER.isInfoEnabled()) {
            Category category = categoryDAO.findCategory(categoryId);
            String category_path = category.getPath();
            LOGGER.info("requested category : " + category_path);
        }
        String destination = getClientRootTopic() + "." + clientId;
        CategoryActiveList active_list = alarmCache.getActiveListReference(categoryId);
        String[] active_alarms = active_list.getActiveAlarms();
        if (active_alarms.length > 0) {
            Collection init_alarms = new HashSet(active_alarms.length);
            for (int i = 0; i < active_alarms.length; i++) {
                Alarm alarm = alarmCache.getReference(active_alarms[i]);
                init_alarms.add(alarm);
            }
            LOGGER.info("found " + init_alarms.size() + " matching alarm(s)");
            alarmPublisher.sendInit(init_alarms, destination);
        }
    } catch (AlarmCacheException e) {
        System.err.println("*** Got an exception! " + e.getMessage());
        e.printStackTrace(System.out);
        System.err.println("*** Exception masked");
    //throw new EJBException("unable to select alarms", e);
    }
}
Also used : LaserProcessingException(cern.laser.business.LaserProcessingException) Category(cern.laser.business.data.Category) ProcessingController(cern.laser.business.ProcessingController) CategoryActiveList(cern.laser.business.data.CategoryActiveList) Alarm(cern.laser.business.data.Alarm) Collection(java.util.Collection) AlarmCacheException(cern.laser.business.cache.AlarmCacheException) HashSet(java.util.HashSet)

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