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