use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class TrapSinkConsumer method toLog.
private Log toLog(TrapLogDTO messageLog) {
final Log log = new Log();
final Events events = new Events();
log.setEvents(events);
for (TrapDTO eachMessage : messageLog.getMessages()) {
try {
final Event event = eventCreator.createEventFrom(eachMessage, messageLog.getSystemId(), messageLog.getLocation(), messageLog.getTrapAddress());
if (!shouldDiscard(event)) {
if (event.getSnmp() != null) {
trapdInstrumentation.incTrapsReceivedCount(event.getSnmp().getVersion());
}
events.addEvent(event);
} else {
LOG.debug("Trap discarded due to matching event having logmsg dest == discardtraps");
trapdInstrumentation.incDiscardCount();
}
} catch (Throwable e) {
LOG.error("Unexpected error processing trap: {}", eachMessage, e);
trapdInstrumentation.incErrorCount();
}
}
return log;
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class JaxbUtilsTest method testMarshalLog.
@Test
public void testMarshalLog() throws Exception {
final Event e1 = getEvent();
final Event e2 = getEvent();
e2.setDescr("test 2");
final Events events = new Events();
events.addEvent(e1);
events.addEvent(e2);
final Log log = new Log();
log.setEvents(events);
final String xml = JaxbUtils.marshal(log);
LOG.debug("xml = {}", xml);
assertNotNull(xml);
assertTrue(xml.contains("JaxbUtilsTest"));
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class EventIpcManagerDefaultImpl method sendNowSync.
@Override
public void sendNowSync(Event event) {
Objects.requireNonNull(event);
Events events = new Events();
events.addEvent(event);
Log eventLog = new Log();
eventLog.setEvents(events);
sendNowSync(eventLog);
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class SyslogSinkConsumer method toEventLog.
public Log toEventLog(SyslogMessageLogDTO messageLog) {
final Log elog = new Log();
final Events events = new Events();
elog.setEvents(events);
for (SyslogMessageDTO message : messageLog.getMessages()) {
try {
LOG.debug("Converting syslog message into event.");
ConvertToEvent re = new ConvertToEvent(messageLog.getSystemId(), messageLog.getLocation(), messageLog.getSourceAddress(), messageLog.getSourcePort(), message.getBytes(), syslogdConfig);
events.addEvent(re.getEvent());
} catch (final MessageDiscardedException e) {
LOG.info("Message discarded, returning without enqueueing event.", e);
} catch (final Throwable e) {
LOG.error("Unexpected exception while processing SyslogConnection", e);
}
}
return elog;
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class EventIpcManagerDefaultImpl method sendNow.
/**
* {@inheritDoc}
*
* Called by a service to send an event to other listeners.
*/
@Override
public void sendNow(Event event) {
Assert.notNull(event, "event argument cannot be null");
Events events = new Events();
events.addEvent(event);
Log eventLog = new Log();
eventLog.setEvents(events);
sendNow(eventLog);
}
Aggregations