Search in sources :

Example 1 with Reader

use of org.opennms.netmgt.config.ackd.Reader in project opennms by OpenNMS.

the class DefaultAckdConfigurationDao method getReader.

/** {@inheritDoc} */
@Override
public Reader getReader(String readerName) {
    Reader readerByName = null;
    List<Reader> readers = getConfig().getReaders();
    for (Reader reader : readers) {
        if (readerName.equals(reader.getReaderName())) {
            readerByName = reader;
        }
    }
    return readerByName;
}
Also used : Reader(org.opennms.netmgt.config.ackd.Reader)

Example 2 with Reader

use of org.opennms.netmgt.config.ackd.Reader in project opennms by OpenNMS.

the class DefaultAckdConfigurationDao method getReaderSchedule.

/** {@inheritDoc} */
@Override
public ReaderSchedule getReaderSchedule(String readerName) {
    ReaderSchedule schedule = null;
    Reader reader = getReader(readerName);
    if (reader != null) {
        schedule = reader.getReaderSchedule();
    }
    return schedule;
}
Also used : Reader(org.opennms.netmgt.config.ackd.Reader) ReaderSchedule(org.opennms.netmgt.config.ackd.ReaderSchedule)

Example 3 with Reader

use of org.opennms.netmgt.config.ackd.Reader in project opennms by OpenNMS.

the class AckdIT method testRestartReaders.

@Test
public void testRestartReaders() throws Exception {
    AckReader reader = m_daemon.getAckReaders().get(0);
    Reader readerConfig = m_daemon.getConfigDao().getReader("JavaMailReader");
    readerConfig.setEnabled(true);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.STOPPED.equals(reader.getState()));
    m_daemon.restartReaders(false);
    Thread.sleep(30);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.STARTED.equals(reader.getState()));
    m_daemon.pauseReaders();
    Thread.sleep(30);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.PAUSED.equals(reader.getState()));
    m_daemon.resumeReaders();
    Thread.sleep(30);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.RESUMED.equals(reader.getState()));
    readerConfig.setEnabled(false);
    m_daemon.restartReaders(true);
    Thread.sleep(300);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.STOPPED.equals(reader.getState()));
    m_daemon.resumeReaders();
    Thread.sleep(30);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.STOPPED.equals(reader.getState()));
    readerConfig.setEnabled(true);
    m_daemon.startReaders();
    Thread.sleep(300);
    Assert.assertTrue("Unexpected reader state: " + reader.getState(), AckReaderState.STARTED.equals(reader.getState()));
    m_daemon.destroy();
}
Also used : Reader(org.opennms.netmgt.config.ackd.Reader) Test(org.junit.Test)

Example 4 with Reader

use of org.opennms.netmgt.config.ackd.Reader in project opennms by OpenNMS.

the class HypericAckProcessorIT method createAckdConfigDao.

private AckdConfigurationDao createAckdConfigDao() {
    class AckdConfigDao extends DefaultAckdConfigurationDao {

        @Override
        public AckdConfiguration getConfig() {
            AckdConfiguration config = new AckdConfiguration();
            config.setAckExpression("~(?i)^AcK$");
            config.setAlarmidMatchExpression("~(?i).*alarmid:([0-9]+).*");
            config.setAlarmSync(true);
            config.setClearExpression("~(?i)^(Resolve|cleaR)$");
            config.setEscalateExpression("~(?i)^esc$");
            config.setNotifyidMatchExpression("~(?i).*RE:.*Notice #([0-9]+).*");
            config.setUnackExpression("~(?i)^unAck$");
            final List<Reader> readers = new ArrayList<>();
            {
                Reader reader = new Reader();
                reader.setEnabled(false);
                reader.setReaderName("JavaMailReader");
                Parameter hypericHosts = new Parameter();
                hypericHosts.setKey("readmail-config");
                hypericHosts.setValue("localhost");
                reader.addParameter(hypericHosts);
                org.opennms.netmgt.config.ackd.ReaderSchedule hypericSchedule = new org.opennms.netmgt.config.ackd.ReaderSchedule();
                hypericSchedule.setInterval(60);
                hypericSchedule.setUnit("s");
                readers.add(reader);
            }
            {
                Reader reader = new Reader();
                reader.setEnabled(true);
                reader.setReaderName(HypericAckProcessor.READER_NAME_HYPERIC);
                Parameter hypericHosts = new Parameter();
                hypericHosts.setKey(HypericAckProcessor.PARAMETER_PREFIX_HYPERIC_SOURCE + "HQ-Datacenter");
                hypericHosts.setValue("http://hqadmin:hqadmin@127.0.0.1:7081/hqu/opennms/alertStatus/list.hqu");
                reader.addParameter(hypericHosts);
                hypericHosts = new Parameter();
                hypericHosts.setKey(HypericAckProcessor.PARAMETER_PREFIX_HYPERIC_SOURCE + "HQ-Corporate-IT");
                hypericHosts.setValue("http://hqadmin:hqadmin@127.0.0.1:7081/hqu/opennms/alertStatus/list.hqu");
                reader.addParameter(hypericHosts);
                org.opennms.netmgt.config.ackd.ReaderSchedule hypericSchedule = new org.opennms.netmgt.config.ackd.ReaderSchedule();
                hypericSchedule.setInterval(3);
                hypericSchedule.setUnit("s");
                reader.setReaderSchedule(hypericSchedule);
                readers.add(reader);
            }
            config.setReaders(readers);
            return config;
        }
    }
    return new AckdConfigDao();
}
Also used : ArrayList(java.util.ArrayList) Reader(org.opennms.netmgt.config.ackd.Reader) LineNumberReader(java.io.LineNumberReader) InputStreamReader(java.io.InputStreamReader) AckdConfiguration(org.opennms.netmgt.config.ackd.AckdConfiguration) DefaultAckdConfigurationDao(org.opennms.netmgt.dao.jaxb.DefaultAckdConfigurationDao) Parameter(org.opennms.netmgt.config.ackd.Parameter)

Example 5 with Reader

use of org.opennms.netmgt.config.ackd.Reader in project opennms by OpenNMS.

the class DefaultAckdConfigurationDao method isReaderEnabled.

/** {@inheritDoc} */
@Override
public boolean isReaderEnabled(String readerName) {
    boolean enabled = false;
    Reader reader = getReader(readerName);
    if (reader != null) {
        enabled = reader.getEnabled();
    }
    return enabled;
}
Also used : Reader(org.opennms.netmgt.config.ackd.Reader)

Aggregations

Reader (org.opennms.netmgt.config.ackd.Reader)5 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 AckdConfiguration (org.opennms.netmgt.config.ackd.AckdConfiguration)1 Parameter (org.opennms.netmgt.config.ackd.Parameter)1 ReaderSchedule (org.opennms.netmgt.config.ackd.ReaderSchedule)1 DefaultAckdConfigurationDao (org.opennms.netmgt.dao.jaxb.DefaultAckdConfigurationDao)1