use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.
the class UserPropsTest method send_alarm.
/**
* Push an alarm
*
* @param active If true the alarm is active
*/
private void send_alarm(String family, String member, int code, boolean active, Properties props) throws Exception {
ACSAlarmSystemInterface alarmSource;
alarmSource = ACSAlarmSystemInterfaceFactory.createSource(member);
ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(family, member, code);
if (active) {
fs.setDescriptor(FaultState.ACTIVE);
} else {
fs.setDescriptor(FaultState.TERMINATE);
}
fs.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
if (props != null && props.size() > 0) {
fs.setUserProperties((Properties) props.clone());
}
alarmSource.push(fs);
}
use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.
the class CategoryClientTest method send_alarm.
/**
* Push an alarm
*
* @param active If true the alarm is active
*/
private void send_alarm(String family, String member, int code, boolean active) throws Exception {
ACSAlarmSystemInterface alarmSource;
alarmSource = ACSAlarmSystemInterfaceFactory.createSource(member);
ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(family, member, code);
if (active) {
fs.setDescriptor(FaultState.ACTIVE);
} else {
fs.setDescriptor(FaultState.TERMINATE);
}
fs.setUserTimestamp(new Timestamp(System.currentTimeMillis()));
alarmSource.push(fs);
}
use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.
the class SendTest method testStress.
// Send 20K alarms
public void testStress() throws Exception {
ACSAlarmSystemInterface alarmSource;
try {
alarmSource = ACSAlarmSystemInterfaceFactory.createSource();
assertNotNull("Error instantiating the source", alarmSource);
ACSFaultState[] faultStates = new ACSFaultState[ITERATIONS];
for (int t = 0; t < ITERATIONS; t++) {
faultStates[t] = ACSAlarmSystemInterfaceFactory.createFaultState(faultFamily + t, faultMember + t, t);
assertNotNull("Error instantiating a fault state", faultStates[t]);
if (t % 2 == 0) {
faultStates[t].setDescriptor(ACSFaultState.ACTIVE);
} else {
faultStates[t].setDescriptor(ACSFaultState.TERMINATE);
}
Properties props = new Properties();
props.setProperty(ACSFaultState.ASI_PREFIX_PROPERTY, "prefix");
props.setProperty(ACSFaultState.ASI_SUFFIX_PROPERTY, "suffix");
faultStates[t].setUserProperties(props);
faultStates[t].setUserTimestamp(new Timestamp(System.currentTimeMillis()));
}
m_logger.info("all alarm messages are prepared.");
for (int t = 0; t < ITERATIONS; t++) {
m_logger.info("alarm message #" + t + " will be sent now.");
alarmSource.push(faultStates[t]);
try {
// HSO: if alarm system needs 10 ms sleep, then this should be enforced in the alarm classes, not in the test!
Thread.sleep(10);
} catch (Exception e) {
}
}
try {
Thread.sleep(10000);
} catch (Exception e) {
}
} catch (Exception e) {
System.out.println("Exception caught while pushing" + e.getMessage());
System.out.println("Cause: " + e.getCause());
e.printStackTrace();
throw e;
} finally {
assertNull(receiverError);
}
}
use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.
the class MultiSourceStressTest method send.
/**
* Send a fault state to the NC.
* It uses the global source or build a new one depending on the
* parameter
*
* @param mfs The fault state to publish
* @param sameSource If true the same source is used to send the alarm
* if true a new source is built and the fault state is
* sent using this new source
*/
private void send(MiniFaultState mfs, boolean sameSource) throws Exception {
assertNotNull(mfs);
ACSFaultState fs = ACSAlarmSystemInterfaceFactory.createFaultState(mfs.FF, mfs.FM, mfs.FC);
assertNotNull("Error instantiating the FS", fs);
fs.setDescriptor(mfs.description);
fs.setUserTimestamp(mfs.timestamp);
if (sameSource) {
alarmSource.push(fs);
} else {
ACSAlarmSystemInterface newSource = ACSAlarmSystemInterfaceFactory.createSource();
assertNotNull(newSource);
newSource.push(fs);
}
}
use of alma.alarmsystem.source.ACSAlarmSystemInterface in project ACS by ACS-Community.
the class ObjectsTest method testSourceType.
public void testSourceType() throws Exception {
ACSAlarmSystemInterface source;
String sourceName = this.getName();
try {
source = ACSAlarmSystemInterfaceFactory.createSource(sourceName);
} catch (Exception e) {
System.out.println("Error creating the source: " + e.getMessage());
e.printStackTrace();
throw e;
}
assertNotNull("Error creating the source", source);
assertTrue("The source has wrong class type", source instanceof AlarmSystemInterfaceProxy);
}
Aggregations