Search in sources :

Example 11 with Events

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));
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events) Event(org.opennms.netmgt.xml.event.Event) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) EventProxy(org.opennms.netmgt.events.api.EventProxy) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with Events

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);
}
Also used : Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events)

Example 13 with Events

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());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) Events(org.opennms.netmgt.xml.event.Events) Log(org.opennms.netmgt.xml.event.Log) Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test)

Example 14 with Events

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;
}
Also used : Header(org.opennms.netmgt.xml.event.Header) Events(org.opennms.netmgt.xml.event.Events) Log(org.opennms.netmgt.xml.event.Log) Event(org.opennms.netmgt.xml.event.Event)

Aggregations

Events (org.opennms.netmgt.xml.event.Events)14 Log (org.opennms.netmgt.xml.event.Log)14 Event (org.opennms.netmgt.xml.event.Event)9 Test (org.junit.Test)4 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)4 EventProxy (org.opennms.netmgt.events.api.EventProxy)2 TcpEventProxy (org.opennms.netmgt.events.api.support.TcpEventProxy)2 Transactional (org.springframework.transaction.annotation.Transactional)2 PostConstruct (javax.annotation.PostConstruct)1 MessageConsumer (org.opennms.core.ipc.sink.api.MessageConsumer)1 MessageConsumerManager (org.opennms.core.ipc.sink.api.MessageConsumerManager)1 SinkModule (org.opennms.core.ipc.sink.api.SinkModule)1 Logging (org.opennms.core.logging.Logging)1 InetAddressUtils (org.opennms.core.utils.InetAddressUtils)1 InetAddressUtils.addr (org.opennms.core.utils.InetAddressUtils.addr)1 TrapdConfig (org.opennms.netmgt.config.TrapdConfig)1 EventConfDao (org.opennms.netmgt.config.api.EventConfDao)1 DistPollerDao (org.opennms.netmgt.dao.api.DistPollerDao)1 InterfaceToNodeCache (org.opennms.netmgt.dao.api.InterfaceToNodeCache)1 EventForwarder (org.opennms.netmgt.events.api.EventForwarder)1