Search in sources :

Example 1 with TcpEventProxy

use of org.opennms.netmgt.events.api.support.TcpEventProxy 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 TcpEventProxy

use of org.opennms.netmgt.events.api.support.TcpEventProxy 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 TcpEventProxy

use of org.opennms.netmgt.events.api.support.TcpEventProxy 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 TcpEventProxy

use of org.opennms.netmgt.events.api.support.TcpEventProxy 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)

Example 5 with TcpEventProxy

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

the class Util method createEventProxy.

/**
 * <p>createEventProxy</p>
 *
 * @deprecated Use dependency injection to wire in an instance of the {@link EventProxy} instead
 *
 * @return a {@link org.opennms.netmgt.events.api.EventProxy} object.
 */
public static EventProxy createEventProxy() {
    /*
         * Rather than defaulting to localhost all the time, give an option in properties
         */
    final String vaultHost = Vault.getProperty("opennms.rtc.event.proxy.host");
    final String vaultPort = Vault.getProperty("opennms.rtc.event.proxy.port");
    final String vaultTimeout = Vault.getProperty("opennms.rtc.event.proxy.timeout");
    final String proxyHostName = vaultHost == null ? "127.0.0.1" : vaultHost;
    final String proxyHostPort = vaultPort == null ? Integer.toString(TcpEventProxy.DEFAULT_PORT) : vaultPort;
    final String proxyHostTimeout = vaultTimeout == null ? Integer.toString(TcpEventProxy.DEFAULT_TIMEOUT) : vaultTimeout;
    InetAddress proxyAddr = null;
    EventProxy proxy = null;
    proxyAddr = InetAddressUtils.addr(proxyHostName);
    if (proxyAddr == null) {
        try {
            proxy = new TcpEventProxy();
        } catch (final UnknownHostException e) {
            // XXX Ewwww!  We should just let the first UnknownException bubble up.
            throw new UndeclaredThrowableException(e);
        }
    } else {
        proxy = new TcpEventProxy(new InetSocketAddress(proxyAddr, Integer.parseInt(proxyHostPort)), Integer.parseInt(proxyHostTimeout));
    }
    return proxy;
}
Also used : UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) 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)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)5 EventProxy (org.opennms.netmgt.events.api.EventProxy)5 TcpEventProxy (org.opennms.netmgt.events.api.support.TcpEventProxy)5 InetAddress (java.net.InetAddress)3 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 UnknownHostException (java.net.UnknownHostException)1