use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class ConfigurationImpl method buildCommentedAlarmMap.
//
// -- PROTECTED METHODS -------------------------------------------
//
//
// -- PRIVATE METHODS ---------------------------------------------
//
private CommentedAlarmMap buildCommentedAlarmMap(Collection commentedAlarmRefs, boolean removeChanged) throws Exception {
CommentedAlarmMap result = new CommentedAlarmMap();
if ((commentedAlarmRefs == null) || (commentedAlarmRefs.size() == 0)) {
return result;
}
Iterator iterator = commentedAlarmRefs.iterator();
while (iterator.hasNext()) {
CommentedAlarmRef ref = (CommentedAlarmRef) iterator.next();
Alarm alarm = AlarmBrowsingHandler.get(orb, logger).getAlarmById(ref.getAlarmId());
if ((!removeChanged) || (removeChanged && alarm.getStatus().getSourceTimestamp().equals(ref.getSourceTimestamp()))) {
result.put(new CommentedAlarm(alarm, ref.getComment()));
}
}
return result;
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class AlarmTable method changeSelection.
/**
* Override {@link JTable#changeSelection(int, int, boolean, boolean)} to show
* the selected alarm in the detail panel.
*/
@Override
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
super.changeSelection(rowIndex, columnIndex, toggle, extend);
int idx = sorter.convertRowIndexToModel(rowIndex);
AlarmTableEntry alarmEntry = model.getAlarmAt(idx);
panel.showAlarmDetails(alarmEntry);
selectedAlarmId = alarmEntry.getAlarmId();
// to avoid concurrency issues
AlarmSelectionListener listenerCopy = listener;
if (listenerCopy != null) {
Alarm alarm = alarmEntry.getEncapsulatedAlarm();
if (alarm != null) {
listenerCopy.notifyAlarmSelected(alarm);
}
}
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class AlarmContainerTest method testReplaceAlarm.
/**
* Test <code>replaceAlarm()</code>
*
* @throws Exception
*/
public void testReplaceAlarm() throws Exception {
// Add some alarms
Vector<Alarm> alarms = new Vector<Alarm>();
int notReduced = populateContainer(CONTAINER_SIZE / 2, "TEST", alarms, null);
class EDTReader implements Runnable {
// The value to check after reading from EDT
private final int value;
EDTReader(int val) {
value = val;
}
public void run() {
assertEquals("Wrong not reduced size", CONTAINER_SIZE / 2, container.size(false));
assertEquals("Wrong reduced size", value, container.size(true));
}
}
EDTExecutor.instance().executeSync(new EDTReader(notReduced));
// replace the first alarm with another one changing the
// active attribute
Alarm alarmToReplace = alarms.get(0);
assertNotNull(alarmToReplace);
Alarm newAlarm = new TestAlarm(alarmToReplace.getAlarmId(), alarmToReplace.isNodeChild(), alarmToReplace.isNodeParent(), !alarmToReplace.getStatus().isActive(), alarmToReplace.getStatus().isMasked(), alarmToReplace.getStatus().isReduced());
class ReplaceAndCheck implements Runnable {
private final Alarm newAlarm;
ReplaceAndCheck(Alarm newAlarm) {
this.newAlarm = newAlarm;
}
public void run() {
try {
container.replace(new AlarmTableEntry(newAlarm));
} catch (Throwable t) {
System.err.println("Error replacing alarm " + newAlarm.getAlarmId());
t.printStackTrace();
}
AlarmTableEntry entry = container.get(newAlarm.getAlarmId());
assertEquals(newAlarm.getAlarmId(), entry.getAlarmId());
assertEquals(newAlarm.getStatus().isActive(), entry.getStatus().isActive());
}
}
EDTExecutor.instance().executeSync(new ReplaceAndCheck(newAlarm));
// replace the LAST alarm with another one changing the
// active attribute
alarmToReplace = alarms.get(alarms.size() - 1);
assertNotNull(alarmToReplace);
newAlarm = new TestAlarm(alarmToReplace.getAlarmId(), alarmToReplace.isNodeChild(), alarmToReplace.isNodeParent(), !alarmToReplace.getStatus().isActive(), alarmToReplace.getStatus().isMasked(), alarmToReplace.getStatus().isReduced());
EDTExecutor.instance().executeSync(new ReplaceAndCheck(newAlarm));
// replace a middle-list alarm with another one changing the
// active attribute
alarmToReplace = alarms.get(alarms.size() / 2);
assertNotNull(alarmToReplace);
newAlarm = new TestAlarm(alarmToReplace.getAlarmId(), alarmToReplace.isNodeChild(), alarmToReplace.isNodeParent(), !alarmToReplace.getStatus().isActive(), alarmToReplace.getStatus().isMasked(), alarmToReplace.getStatus().isReduced());
EDTExecutor.instance().executeSync(new ReplaceAndCheck(newAlarm));
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class AlarmContainerTest method testRemoveInactivAls.
/**
* Test the removal of inactive alarms
*
* @throws Exception
*/
public void testRemoveInactivAls() throws Exception {
final Vector<Alarm> alarms = new Vector<Alarm>();
int notReduced;
// Stores for each priority the number of inactive alarms
final int[] priorities = new int[AlarmGUIType.values().length - 1];
// The test is done for each AlarmGUIType corresponding to a priority
for (AlarmGUIType alarmType : AlarmGUIType.values()) {
// Add some alarms
alarms.clear();
assertEquals(0, alarms.size());
EDTExecutor.instance().executeSync(new Runnable() {
@Override
public void run() {
container.clear();
assertEquals(0, container.size(false));
}
});
for (int t = 0; t < 4; t++) {
priorities[t] = 0;
}
notReduced = populateContainer(CONTAINER_SIZE / 2, "TEST", alarms, null);
class EDTReader implements Runnable {
// The value to check after reading from EDT
private final int value;
EDTReader(int val) {
value = val;
}
public void run() {
assertEquals("Wrong not reduced size", CONTAINER_SIZE / 2, container.size(false));
assertEquals("Wrong reduced size", value, container.size(true));
}
}
EDTExecutor.instance().executeSync(new EDTReader(notReduced));
for (Alarm al : alarms) {
if (!al.getStatus().isActive()) {
priorities[al.getPriority()]++;
}
}
class Checker implements Runnable {
private final AlarmGUIType alarmType;
public Checker(AlarmGUIType alarmType) {
this.alarmType = alarmType;
}
public void run() {
try {
container.removeInactiveAlarms(alarmType);
} catch (Throwable t) {
System.out.println("Error removing inactive alarms for " + alarmType);
t.printStackTrace();
return;
}
if (alarmType != AlarmGUIType.INACTIVE) {
assertEquals(alarms.size() - priorities[alarmType.ordinal()], container.size(false));
} else {
int newSize = alarms.size() - priorities[0] - priorities[1] - priorities[2] - priorities[3];
assertEquals(newSize, container.size(false));
}
}
}
EDTExecutor.instance().executeSync(new Checker(alarmType));
}
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class SpecialAlarmTest method testSpecialAlarmTest.
public void testSpecialAlarmTest() throws Exception {
Alarm alarm = new SpecialAlarm(family, member, code, true, action, description, cause, consequences, priority, url, email, props);
assertEquals(alarm.getTriplet().getFaultFamily(), family);
assertEquals(alarm.getTriplet().getFaultMember(), member);
assertEquals(alarm.getTriplet().getFaultCode(), Integer.valueOf(code));
assertEquals(alarm.getHelpURL().toString(), url);
assertEquals(alarm.getAction(), action);
assertEquals(alarm.getCause(), cause);
assertEquals(alarm.getConsequence(), consequences);
assertEquals(alarm.getPiquetEmail(), email);
assertEquals(alarm.getProblemDescription(), description);
assertEquals(alarm.getPriority(), Integer.valueOf(priority));
assertEquals(alarm.getStatus().isActive(), true);
assertEquals(family + ":" + member + ":" + code, alarm.getAlarmId());
Properties p = alarm.getStatus().getUserProperties();
assertNotNull(p);
assertTrue(p.size() == 2);
String v1 = p.getProperty(prop1Key);
assertEquals(prop1Val, v1);
String v2 = p.getProperty(prop2Key);
assertEquals(prop2Val, v2);
}
Aggregations