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