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