Search in sources :

Example 1 with EventProxy

use of org.opennms.netmgt.events.api.EventProxy in project opennms by OpenNMS.

the class MemoryLeakIT method testMemory.

@Test
@Ignore
public void testMemory() throws Exception {
    EventProxy proxy = new TcpEventProxy(new InetSocketAddress("127.0.0.1", OpenNMSITCase.PROXY_PORT));
    double eventRate = 20.0 / 1000.0;
    long start = System.currentTimeMillis();
    long count = 0;
    while (System.currentTimeMillis() - start < MINS) {
        long now = Math.max(System.currentTimeMillis(), 1);
        double actualRate = ((double) count) / ((double) (now - start));
        if (actualRate < eventRate) {
            sendEvent(proxy, count);
            count++;
        }
        Thread.sleep(30);
        System.err.println(String.format("Expected Rate: %f Actual Rate: %f Events Sent: %d", eventRate, actualRate, count));
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) EventProxy(org.opennms.netmgt.events.api.EventProxy) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with EventProxy

use of org.opennms.netmgt.events.api.EventProxy in project opennms by OpenNMS.

the class SyslogdLoadIT method createEventProxy.

private static EventProxy createEventProxy() throws UnknownHostException {
    /*
         * Rather than defaulting to localhost all the time, give an option in properties
         */
    String proxyHostName = "127.0.0.1";
    String proxyHostPort = "5837";
    String proxyHostTimeout = String.valueOf(TcpEventProxy.DEFAULT_TIMEOUT);
    InetAddress proxyAddr = null;
    EventProxy proxy = null;
    proxyAddr = InetAddressUtils.addr(proxyHostName);
    if (proxyAddr == null) {
        proxy = new TcpEventProxy();
    } else {
        proxy = new TcpEventProxy(new InetSocketAddress(proxyAddr, Integer.parseInt(proxyHostPort)), Integer.parseInt(proxyHostTimeout));
    }
    return proxy;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) InetAddress(java.net.InetAddress) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) EventProxy(org.opennms.netmgt.events.api.EventProxy)

Example 3 with EventProxy

use of org.opennms.netmgt.events.api.EventProxy in project opennms by OpenNMS.

the class SyslogdEventdLoadIT method createEventProxy.

private static EventProxy createEventProxy() throws UnknownHostException {
    /*
         * Rather than defaulting to localhost all the time, give an option in properties
         */
    String proxyHostName = "127.0.0.1";
    String proxyHostPort = "5817";
    String proxyHostTimeout = String.valueOf(TcpEventProxy.DEFAULT_TIMEOUT);
    InetAddress proxyAddr = null;
    EventProxy proxy = null;
    proxyAddr = InetAddressUtils.addr(proxyHostName);
    if (proxyAddr == null) {
        proxy = new TcpEventProxy();
    } else {
        proxy = new TcpEventProxy(new InetSocketAddress(proxyAddr, Integer.parseInt(proxyHostPort)), Integer.parseInt(proxyHostTimeout));
    }
    return proxy;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) InetAddress(java.net.InetAddress) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) EventProxy(org.opennms.netmgt.events.api.EventProxy)

Example 4 with EventProxy

use of org.opennms.netmgt.events.api.EventProxy in project opennms by OpenNMS.

the class SnmpConfigServlet method sendEvent.

/**
 * Sends the given event via the EventProxy to the system. If null no event is send.
 * @param eventToSend The Event to send. If null, no event is send.
 * @return <code>true</code> if the event was send successfully and no exception occured, <code>false</code> if eventToSend is null.
 * @throws ServletException On error.
 */
private boolean sendEvent(Event eventToSend) throws ServletException {
    if (eventToSend == null)
        return false;
    try {
        EventProxy eventProxy = Util.createEventProxy();
        if (eventProxy == null)
            throw new ServletException("Event proxy object is null, unable to send event " + eventToSend.getUei());
        eventProxy.send(eventToSend);
        return true;
    } catch (Throwable e) {
        throw new ServletException("Could not send event " + eventToSend.getUei(), e);
    }
}
Also used : ServletException(javax.servlet.ServletException) EventProxy(org.opennms.netmgt.events.api.EventProxy)

Example 5 with EventProxy

use of org.opennms.netmgt.events.api.EventProxy in project opennms by OpenNMS.

the class EventdMemoryLeakIT method testMemory.

@Test
@Ignore
public void testMemory() throws Exception {
    EventProxy proxy = new TcpEventProxy(new InetSocketAddress("127.0.0.1", 5837));
    double eventRate = 20.0 / 1000.0;
    long start = System.currentTimeMillis();
    long count = 0;
    while (System.currentTimeMillis() - start < MINS) {
        long now = Math.max(System.currentTimeMillis(), 1);
        double actualRate = ((double) count) / ((double) (now - start));
        if (actualRate < eventRate) {
            sendEvent(proxy, count);
            count++;
        }
        Thread.sleep(30);
        System.err.println(String.format("Expected Rate: %f Actual Rate: %f Events Sent: %d", eventRate, actualRate, count));
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) EventProxy(org.opennms.netmgt.events.api.EventProxy) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

EventProxy (org.opennms.netmgt.events.api.EventProxy)11 TcpEventProxy (org.opennms.netmgt.events.api.support.TcpEventProxy)7 InetSocketAddress (java.net.InetSocketAddress)5 Test (org.junit.Test)4 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)4 InetAddress (java.net.InetAddress)3 ServletException (javax.servlet.ServletException)3 RequestDispatcher (javax.servlet.RequestDispatcher)2 Ignore (org.junit.Ignore)2 Event (org.opennms.netmgt.xml.event.Event)2 Events (org.opennms.netmgt.xml.event.Events)2 Log (org.opennms.netmgt.xml.event.Log)2 Transactional (org.springframework.transaction.annotation.Transactional)2 StringWriter (java.io.StringWriter)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 HttpSession (javax.servlet.http.HttpSession)1 CollectionException (org.opennms.netmgt.collection.api.CollectionException)1 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)1