use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class SyslogdLoadIT method testEventd.
@Test
@Transactional
public void testEventd() throws Exception {
m_eventd.start();
EventProxy ep = createEventProxy();
Log eventLog = new Log();
Events events = new Events();
eventLog.setEvents(events);
int eventCount = 10000;
m_eventCounter.setAnticipated(eventCount);
for (int i = 0; i < eventCount; i++) {
int eventNum = Double.valueOf(Math.random() * 300).intValue();
String expectedUei = "uei.example.org/syslog/loadTest/foo" + eventNum;
final EventBuilder eb = new EventBuilder(expectedUei, "SyslogdLoadTest");
Event thisEvent = eb.setInterface(addr("127.0.0.1")).setLogDest("logndisplay").setLogMessage("A load test has been received as a Syslog Message").getEvent();
// LOG.debug("event = {}", thisEvent);
events.addEvent(thisEvent);
}
long start = System.currentTimeMillis();
ep.send(eventLog);
long mid = System.currentTimeMillis();
// wait up to 2 minutes for the events to come through
m_eventCounter.waitForFinish(120000);
long end = System.currentTimeMillis();
m_eventd.stop();
final long total = (end - start);
final double eventsPerSecond = (eventCount * 1000.0 / total);
System.err.println(String.format("total time: %d, wait time: %d, events per second: %8.4f", total, (end - mid), eventsPerSecond));
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class TcpEventProxy method send.
/**
* {@inheritDoc}
*
* This method is called to send the event out
* @exception UndeclaredThrowableException
* thrown if the send fails for any reason
*/
@Override
public void send(Event event) throws EventProxyException {
Log elog = new Log();
Events events = new Events();
events.addEvent(event);
elog.setEvents(events);
send(elog);
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class HibernateEventWriterTest method testSingleTransactionCreated.
/**
* Verifies that a transaction is opened when at least of
* of the events in the log need to be persisted.
*/
@Test
public void testSingleTransactionCreated() throws EventProcessorException {
// A log with a single event that marked as 'logndisplay'
EventBuilder bldr = new EventBuilder("testUei", "testSource");
bldr.setLogDest(HibernateEventWriter.LOG_MSG_DEST_LOG_AND_DISPLAY);
eventWriter.process(bldr.getLog());
verify(transactionManager, times(1)).execute(any());
reset(transactionManager);
// A log with a multiple events that marked as 'logndisplay'
bldr = new EventBuilder("testUei", "testSource");
bldr.setLogDest(HibernateEventWriter.LOG_MSG_DEST_LOG_AND_DISPLAY);
Event e1 = bldr.getEvent();
bldr = new EventBuilder("testUei", "testSource");
bldr.setLogDest(HibernateEventWriter.LOG_MSG_DEST_LOG_AND_DISPLAY);
Event e2 = bldr.getEvent();
Events events = new Events();
events.setEvent(new Event[] { e1, e2 });
Log log = new Log();
log.setEvents(events);
eventWriter.process(log);
verify(transactionManager, times(1)).execute(any());
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class EventBuilder method getLog.
public Log getLog() {
Event event = getEvent();
Events events = new Events();
events.setEvent(new Event[] { event });
Header header = new Header();
header.setCreated(StringUtils.toStringEfficiently(event.getCreationTime()));
Log log = new Log();
log.setHeader(header);
log.setEvents(events);
return log;
}
Aggregations