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));
}
}
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;
}
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;
}
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));
}
}
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;
}
Aggregations