use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class MockEventUtil method createNodeDownEventBuilder.
/**
* <p>createNodeDownEventBuilder</p>
*
* @param source a {@link java.lang.String} object.
* @param node a {@link org.opennms.netmgt.mock.MockNode} object.
* @return a {@link org.opennms.netmgt.model.events.EventBuilder} object.
*/
public static EventBuilder createNodeDownEventBuilder(String source, OnmsNode node) {
EventBuilder event = createNodeEventBuilder(source, EventConstants.NODE_DOWN_EVENT_UEI, node);
event.setSeverity(OnmsSeverity.MAJOR.getLabel());
// <alarm-data reduction-key="%uei%:%dpname%:%nodeid%" alarm-type="1" auto-clean="false" />
AlarmData alarmData = new AlarmData();
alarmData.setReductionKey("%uei%:%dpname%:%nodeid%");
alarmData.setAlarmType(1);
alarmData.setAutoClean(false);
event.setAlarmData(alarmData);
return event;
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmLifecycleEventsIT method sendNodeDownEvent.
private void sendNodeDownEvent(long nodeId) {
EventBuilder builder = new EventBuilder(EventConstants.NODE_DOWN_EVENT_UEI, "test");
Date currentTime = new Date();
builder.setTime(currentTime);
builder.setNodeid(nodeId);
builder.setSeverity("Major");
AlarmData data = new AlarmData();
data.setAlarmType(1);
data.setReductionKey(String.format("%s:%d", EventConstants.NODE_DOWN_EVENT_UEI, nodeId));
builder.setAlarmData(data);
builder.setLogDest("logndisplay");
builder.setLogMessage("testing");
m_eventMgr.sendNow(builder.getEvent());
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method sendNodeDownEventWithUpdateFieldSeverity.
private void sendNodeDownEventWithUpdateFieldSeverity(String reductionKey, MockNode node, OnmsSeverity severity) throws SQLException {
EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);
if (reductionKey != null) {
AlarmData data = new AlarmData();
data.setAlarmType(1);
data.setReductionKey(reductionKey);
List<UpdateField> fields = new ArrayList<UpdateField>();
UpdateField field = new UpdateField();
field.setFieldName("Severity");
field.setUpdateOnReduction(Boolean.TRUE);
fields.add(field);
data.setUpdateField(fields);
event.setAlarmData(data);
} else {
event.setAlarmData(null);
}
event.setLogDest("logndisplay");
event.setLogMessage("testing");
event.setSeverity(severity.getLabel());
m_eventdIpcMgr.sendNow(event.getEvent());
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method testNoLogmsg.
@Test
public void testNoLogmsg() throws Exception {
EventBuilder bldr = new EventBuilder("testNoLogmsg", "AlarmdTest");
bldr.setAlarmData(new AlarmData());
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalArgumentException("Incoming event has an illegal dbid (0), aborting"));
try {
m_alarmd.getPersister().persist(bldr.getEvent());
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method sendNodeDownEventDontChangeLogMsg.
//Supporting method for test
private void sendNodeDownEventDontChangeLogMsg(String reductionKey, MockNode node, String logMsg) {
EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);
if (reductionKey != null) {
AlarmData data = new AlarmData();
data.setAlarmType(1);
data.setReductionKey(reductionKey);
List<UpdateField> fields = new ArrayList<UpdateField>();
UpdateField field = new UpdateField();
field.setFieldName("logMsg");
field.setUpdateOnReduction(Boolean.FALSE);
fields.add(field);
data.setUpdateField(fields);
event.setAlarmData(data);
} else {
event.setAlarmData(null);
}
event.setLogDest("logndisplay");
event.setLogMessage(logMsg);
m_eventdIpcMgr.sendNow(event.getEvent());
}
Aggregations