Search in sources :

Example 11 with NorthboundAlarm

use of org.opennms.netmgt.alarmd.api.NorthboundAlarm in project opennms by OpenNMS.

the class NCSNorthbounderIT method alarm.

private NorthboundAlarm alarm(int alarmId) {
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setId(alarmId);
    alarm.setUei("uei.opennms.org/test/httpNorthBounder");
    alarm.setEventParms("componentType=Service(string,text);componentName=NAM" + alarmId + "(string,text);componentForeignSource=FS(string,text);componentForeignId=" + alarmId + "(string,text);cause=17(string,text)");
    alarm.setAlarmType((alarmId + 1) % 2 + 1);
    return new NorthboundAlarm(alarm);
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm)

Example 12 with NorthboundAlarm

use of org.opennms.netmgt.alarmd.api.NorthboundAlarm in project opennms by OpenNMS.

the class AbstractNorthbounderTest method testAlarmForwarding.

/**
     * Test alarm forwarding.
     *
     * @throws InterruptedException the interrupted exception
     */
@Test
public void testAlarmForwarding() throws InterruptedException {
    TestNorthbounder tnb = new TestNorthbounder();
    tnb.setAccepting(true);
    tnb.start();
    NorthboundAlarm a = createNorthboundAlarm(1);
    tnb.onAlarm(a);
    tnb.waitForAcceptsToBeCalled(2000);
    tnb.waitForForwardToBeCalled(2000);
    assertNotNull(tnb.getAlarms());
    assertTrue(tnb.getAlarms().contains(a));
}
Also used : NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm) Test(org.junit.Test)

Example 13 with NorthboundAlarm

use of org.opennms.netmgt.alarmd.api.NorthboundAlarm in project opennms by OpenNMS.

the class AlarmQueueTest method createAlarm.

/**
     * Creates the alarm.
     *
     * @return the northbound alarm
     */
private NorthboundAlarm createAlarm() {
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setId(++alarmNumber);
    alarm.setUei("uei.opennms.org/test/httpNorthBounder");
    return new NorthboundAlarm(alarm);
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm)

Example 14 with NorthboundAlarm

use of org.opennms.netmgt.alarmd.api.NorthboundAlarm in project opennms by OpenNMS.

the class AbstractNorthbounderTest method createNorthboundAlarm.

/**
     * Creates the northbound alarm.
     *
     * @param alarmid the alarmid
     * @return the northbound alarm
     */
private NorthboundAlarm createNorthboundAlarm(int alarmid) {
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setId(alarmid);
    alarm.setUei("uei.opennms.org/test/httpNorthBounder");
    return new NorthboundAlarm(alarm);
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm)

Example 15 with NorthboundAlarm

use of org.opennms.netmgt.alarmd.api.NorthboundAlarm in project opennms by OpenNMS.

the class AbstractNorthbounderTest method testAlarmForwardingWithNagles.

/**
     * Test alarm forwarding with nagles.
     *
     * @throws InterruptedException the interrupted exception
     */
@Test
public void testAlarmForwardingWithNagles() throws InterruptedException {
    TestNorthbounder tnb = new TestNorthbounder();
    tnb.setAccepting(true);
    tnb.setNaglesDelay(500);
    tnb.start();
    NorthboundAlarm a1 = createNorthboundAlarm(1);
    NorthboundAlarm a2 = createNorthboundAlarm(2);
    NorthboundAlarm a3 = createNorthboundAlarm(3);
    tnb.onAlarm(a1);
    Thread.sleep(100);
    tnb.onAlarm(a2);
    Thread.sleep(100);
    tnb.onAlarm(a3);
    tnb.waitForAcceptsToBeCalled(2000);
    tnb.waitForForwardToBeCalled(2000);
    assertNotNull(tnb.getAlarms());
    assertEquals(3, tnb.getAlarms().size());
    assertTrue(tnb.getAlarms().contains(a1));
    assertTrue(tnb.getAlarms().contains(a2));
    assertTrue(tnb.getAlarms().contains(a3));
}
Also used : NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm) Test(org.junit.Test)

Aggregations

NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)27 Test (org.junit.Test)17 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)16 InetAddress (java.net.InetAddress)10 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)10 OnmsNode (org.opennms.netmgt.model.OnmsNode)10 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)7 LinkedList (java.util.LinkedList)6 Message (javax.jms.Message)5 ByteArrayResource (org.springframework.core.io.ByteArrayResource)5 Resource (org.springframework.core.io.Resource)5 ObjectMessage (javax.jms.ObjectMessage)4 TextMessage (javax.jms.TextMessage)4 JmsDestination (org.opennms.netmgt.alarmd.northbounder.jms.JmsDestination)4 JmsNorthbounder (org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounder)4 JmsNorthbounderConfig (org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfig)4 JmsNorthbounderConfigDao (org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfigDao)4 UnknownHostException (java.net.UnknownHostException)3 Date (java.util.Date)3 LinkedHashSet (java.util.LinkedHashSet)3