Search in sources :

Example 1 with EventIpcManager

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

the class EventIpcManagerFactoryTest method testSetIpcManager.

public void testSetIpcManager() {
    EventIpcManager manager = createMock(EventIpcManager.class);
    EventIpcManagerFactory.setIpcManager(manager);
    assertNotNull("manager should not be null", EventIpcManagerFactory.getIpcManager());
    assertEquals("manager", manager, EventIpcManagerFactory.getIpcManager());
}
Also used : EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager)

Example 2 with EventIpcManager

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

the class PassiveStatusd method onInit.

/**
 * <p>onInit</p>
 */
@Override
protected void onInit() {
    EventIpcManagerFactory.init();
    EventIpcManager mgr = EventIpcManagerFactory.getIpcManager();
    PassiveStatusKeeper keeper = getPassiveStatusKeeper();
    keeper.setEventManager(mgr);
    keeper.setDataSource(DataSourceFactory.getInstance());
    keeper.init();
}
Also used : EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) PassiveStatusKeeper(org.opennms.netmgt.passive.PassiveStatusKeeper)

Example 3 with EventIpcManager

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

the class EventTranslator method onInit.

/**
 * <p>onInit</p>
 */
@Override
protected void onInit() {
    try {
        EventTranslatorConfigFactory.init();
    } catch (IOException e) {
        LOG.error("IOException: ", e);
        throw new UndeclaredThrowableException(e);
    } catch (ClassNotFoundException e) {
        LOG.error("Unable to initialize database", e);
        throw new UndeclaredThrowableException(e);
    } catch (SQLException e) {
        LOG.error("SQLException: ", e);
        throw new UndeclaredThrowableException(e);
    } catch (PropertyVetoException e) {
        LOG.error("PropertyVetoException: ", e);
        throw new UndeclaredThrowableException(e);
    }
    EventIpcManagerFactory.init();
    EventIpcManager mgr = EventIpcManagerFactory.getIpcManager();
    org.opennms.netmgt.translator.EventTranslator keeper = getEventTranslator();
    keeper.setConfig(EventTranslatorConfigFactory.getInstance());
    keeper.setEventManager(mgr);
    keeper.setDataSource(DataSourceFactory.getInstance());
    keeper.init();
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) SQLException(java.sql.SQLException) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) IOException(java.io.IOException)

Example 4 with EventIpcManager

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

the class Vacuumd method init.

/*
     * (non-Javadoc)
     * 
     * @see org.opennms.netmgt.vacuumd.jmx.VacuumdMBean#init()
     */
/**
 * <p>init</p>
 */
@Override
public void init() {
    EventIpcManagerFactory.init();
    EventIpcManager mgr = EventIpcManagerFactory.getIpcManager();
    getVacuumd().setEventManager(mgr);
    getVacuumd().init();
}
Also used : EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager)

Example 5 with EventIpcManager

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

the class CollectdTest method setUp.

@Before
public void setUp() throws Exception {
    EventIpcManager m_eventIpcManager;
    NodeDao m_nodeDao;
    MockLogAppender.setupLogging();
    Resource threshdResource = new ClassPathResource("/etc/thresholds.xml");
    File homeDir = threshdResource.getFile().getParentFile().getParentFile();
    System.setProperty("opennms.home", homeDir.getAbsolutePath());
    // Test setup
    m_eventIpcManager = m_easyMockUtils.createMock(EventIpcManager.class);
    EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
    m_nodeDao = m_easyMockUtils.createMock(NodeDao.class);
    m_ipIfDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    m_scheduler = new MockScheduler();
    m_eventIpcManager.addEventListener(isA(EventListener.class));
    expectLastCall().anyTimes();
    m_eventIpcManager.addEventListener(isA(EventListener.class), isACollection(String.class));
    expectLastCall().anyTimes();
    m_eventIpcManager.addEventListener(isA(EventListener.class), isA(String.class));
    expectLastCall().anyTimes();
    m_eventIpcManager.removeEventListener(isA(EventListener.class));
    expectLastCall().anyTimes();
    // Mock the FilterDao without using EasyMockUtils so that it can be verified separately
    m_filterDao = EasyMock.createMock(FilterDao.class);
    List<InetAddress> allIps = new ArrayList<>();
    allIps.add(addr("192.168.1.1"));
    allIps.add(addr("192.168.1.2"));
    allIps.add(addr("192.168.1.3"));
    allIps.add(addr("192.168.1.4"));
    allIps.add(addr("192.168.1.5"));
    expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(allIps).anyTimes();
    expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE 1.1.1.1")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
    EasyMock.replay(m_filterDao);
    FilterDaoFactory.setInstance(m_filterDao);
    // This call will also ensure that the poll-outages.xml file can parse IPv4
    // and IPv6 addresses.
    Resource resource = new ClassPathResource("etc/poll-outages.xml");
    PollOutagesConfigFactory factory = new PollOutagesConfigFactory(resource);
    factory.afterPropertiesSet();
    PollOutagesConfigFactory.setInstance(factory);
    final MockTransactionTemplate transTemplate = new MockTransactionTemplate();
    transTemplate.afterPropertiesSet();
    m_collectd = new Collectd();
    m_collectd.setEventIpcManager(m_eventIpcManager);
    m_collectd.setNodeDao(m_nodeDao);
    m_collectd.setIpInterfaceDao(m_ipIfDao);
    m_collectd.setFilterDao(m_filterDao);
    m_collectd.setScheduler(m_scheduler);
    m_collectd.setTransactionTemplate(transTemplate);
    m_collectd.setPersisterFactory(new MockPersisterFactory());
    m_collectd.setServiceCollectorRegistry(new DefaultServiceCollectorRegistry());
    m_collectd.setLocationAwareCollectorClient(CollectorTestUtils.createLocationAwareCollectorClient());
    ThresholdingConfigFactory.setInstance(new ThresholdingConfigFactory(ConfigurationTestUtils.getInputStreamForConfigFile("thresholds.xml")));
}
Also used : MockScheduler(org.opennms.netmgt.poller.mock.MockScheduler) DefaultServiceCollectorRegistry(org.opennms.netmgt.collection.support.DefaultServiceCollectorRegistry) PollOutagesConfigFactory(org.opennms.netmgt.config.PollOutagesConfigFactory) Resource(org.springframework.core.io.Resource) ClassPathResource(org.springframework.core.io.ClassPathResource) ArrayList(java.util.ArrayList) MockTransactionTemplate(org.opennms.netmgt.dao.mock.MockTransactionTemplate) ClassPathResource(org.springframework.core.io.ClassPathResource) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) NodeDao(org.opennms.netmgt.dao.api.NodeDao) FilterDao(org.opennms.netmgt.filter.api.FilterDao) EventIpcManager(org.opennms.netmgt.events.api.EventIpcManager) EventListener(org.opennms.netmgt.events.api.EventListener) MockPersisterFactory(org.opennms.netmgt.mock.MockPersisterFactory) File(java.io.File) InetAddress(java.net.InetAddress) ThresholdingConfigFactory(org.opennms.netmgt.config.ThresholdingConfigFactory) Before(org.junit.Before)

Aggregations

EventIpcManager (org.opennms.netmgt.events.api.EventIpcManager)6 File (java.io.File)2 Before (org.junit.Before)2 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)2 FilterDao (org.opennms.netmgt.filter.api.FilterDao)2 PropertyVetoException (java.beans.PropertyVetoException)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 BigInteger (java.math.BigInteger)1 InetAddress (java.net.InetAddress)1 SQLException (java.sql.SQLException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 DefaultServiceCollectorRegistry (org.opennms.netmgt.collection.support.DefaultServiceCollectorRegistry)1 ThresholdingConfigFactory (org.opennms.netmgt.config.ThresholdingConfigFactory)1 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)1 NodeDao (org.opennms.netmgt.dao.api.NodeDao)1