Search in sources :

Example 11 with ServiceCollector

use of org.opennms.netmgt.collection.api.ServiceCollector in project opennms by OpenNMS.

the class CollectdTest method setupCollector.

private void setupCollector(String svcName, ServiceCollector svcCollector) throws CollectionInitializationException {
    MockServiceCollector.setDelegate(svcCollector);
    // Tell the config to use the MockServiceCollector for the specified service
    Collector collector = new Collector();
    collector.setService(svcName);
    collector.setClassName(MockServiceCollector.class.getName());
    m_collectdConfigFactory = m_easyMockUtils.createMock(CollectdConfigFactory.class);
    m_collectdConfig = m_easyMockUtils.createMock(CollectdConfiguration.class);
    expect(m_collectdConfigFactory.getCollectdConfig()).andReturn(m_collectdConfig).anyTimes();
    expect(m_collectdConfig.getCollectors()).andReturn(Collections.singletonList(collector)).anyTimes();
    expect(m_collectdConfig.getThreads()).andReturn(1).anyTimes();
    m_collectd.setCollectdConfigFactory(m_collectdConfigFactory);
}
Also used : CollectdConfiguration(org.opennms.netmgt.config.collectd.CollectdConfiguration) ServiceCollector(org.opennms.netmgt.collection.api.ServiceCollector) Collector(org.opennms.netmgt.config.collectd.Collector) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory)

Example 12 with ServiceCollector

use of org.opennms.netmgt.collection.api.ServiceCollector in project opennms by OpenNMS.

the class CollectorClientRpcModule method execute.

@Override
public CompletableFuture<CollectorResponseDTO> execute(CollectorRequestDTO request) {
    final String className = request.getClassName();
    final ServiceCollector collector = serviceCollectorRegistry.getCollectorByClassName(className);
    if (collector == null) {
        throw new IllegalArgumentException("No collector found with class name '" + className + "'.");
    }
    return CompletableFuture.supplyAsync(new Supplier<CollectorResponseDTO>() {

        @Override
        public CollectorResponseDTO get() {
            Logging.putPrefix("collectd");
            final CollectionAgent agent = request.getAgent();
            final Map<String, Object> parameters = request.getParameters(collector);
            return new CollectorResponseDTO(collector.collect(agent, parameters));
        }
    }, executor);
}
Also used : ServiceCollector(org.opennms.netmgt.collection.api.ServiceCollector) CollectionAgent(org.opennms.netmgt.collection.api.CollectionAgent) Map(java.util.Map)

Example 13 with ServiceCollector

use of org.opennms.netmgt.collection.api.ServiceCollector in project opennms by OpenNMS.

the class CollectdTest method setupCollector.

private void setupCollector(String svcName, boolean successfulInit) throws CollectionInitializationException {
    ServiceCollector svcCollector = m_easyMockUtils.createMock(ServiceCollector.class);
    svcCollector.initialize();
    MockServiceCollector.setDelegate(svcCollector);
    // Tell the config to use the MockServiceCollector for the specified service
    Collector collector = new Collector();
    collector.setService(svcName);
    collector.setClassName(MockServiceCollector.class.getName());
    m_collectdConfigFactory = m_easyMockUtils.createMock(CollectdConfigFactory.class);
    m_collectdConfig = m_easyMockUtils.createMock(CollectdConfiguration.class);
    expect(m_collectdConfigFactory.getCollectdConfig()).andReturn(m_collectdConfig).anyTimes();
    expect(m_collectdConfig.getCollectors()).andReturn(Collections.singletonList(collector)).anyTimes();
    expect(m_collectdConfig.getThreads()).andReturn(1).anyTimes();
    m_collectd.setCollectdConfigFactory(m_collectdConfigFactory);
}
Also used : CollectdConfiguration(org.opennms.netmgt.config.collectd.CollectdConfiguration) ServiceCollector(org.opennms.netmgt.collection.api.ServiceCollector) Collector(org.opennms.netmgt.config.collectd.Collector) ServiceCollector(org.opennms.netmgt.collection.api.ServiceCollector) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory)

Aggregations

ServiceCollector (org.opennms.netmgt.collection.api.ServiceCollector)13 CollectionAgent (org.opennms.netmgt.collection.api.CollectionAgent)8 HashMap (java.util.HashMap)5 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)5 Map (java.util.Map)4 Test (org.junit.Test)4 Collector (org.opennms.netmgt.config.collectd.Collector)4 CollectionInitializationException (org.opennms.netmgt.collection.api.CollectionInitializationException)3 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)3 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 DefaultCollectionAgent (org.opennms.netmgt.collection.core.DefaultCollectionAgent)2 CollectionAgentDTO (org.opennms.netmgt.collection.dto.CollectionAgentDTO)2 CollectdConfigFactory (org.opennms.netmgt.config.CollectdConfigFactory)2 CollectdConfiguration (org.opennms.netmgt.config.collectd.CollectdConfiguration)2 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1