Search in sources :

Example 1 with OnmsPollModel

use of org.opennms.netmgt.poller.remote.OnmsPollModel in project opennms by OpenNMS.

the class DefaultPollerBackEnd method createPollerConfiguration.

private SimplePollerConfiguration createPollerConfiguration(String pollingPackageName) {
    final Package pkg = getPollingPackage(pollingPackageName);
    final ServiceSelector selector = m_pollerConfig.getServiceSelectorForPackage(pkg);
    final Collection<OnmsMonitoredService> services = m_monSvcDao.findMatchingServices(selector);
    final List<PolledService> configs = new ArrayList<PolledService>(services.size());
    LOG.debug("Found {} services in polling package {}", services.size(), pollingPackageName);
    for (final OnmsMonitoredService monSvc : services) {
        final Service serviceConfig = m_pollerConfig.getServiceInPackage(monSvc.getServiceName(), pkg);
        final long interval = serviceConfig.getInterval();
        final Map<String, Object> parameters = getParameterMap(serviceConfig);
        if (LOG.isTraceEnabled()) {
            for (Map.Entry<String, Object> entry : parameters.entrySet()) {
                LOG.trace("Service {} has parameter {} with type {} and value: {}", monSvc.getServiceName(), entry.getKey(), entry.getValue() != null ? entry.getValue().getClass().getCanonicalName() : "null", entry.getValue());
            }
        }
        configs.add(new PolledService(monSvc, parameters, new OnmsPollModel(interval)));
    }
    Collections.sort(configs);
    return new SimplePollerConfiguration(getConfigurationTimestamp(), configs.toArray(new PolledService[configs.size()]));
}
Also used : OnmsPollModel(org.opennms.netmgt.poller.remote.OnmsPollModel) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) ArrayList(java.util.ArrayList) PolledService(org.opennms.netmgt.poller.remote.PolledService) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Service(org.opennms.netmgt.config.poller.Service) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) PolledService(org.opennms.netmgt.poller.remote.PolledService) Package(org.opennms.netmgt.config.poller.Package) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Package (org.opennms.netmgt.config.poller.Package)1 Service (org.opennms.netmgt.config.poller.Service)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1 ServiceSelector (org.opennms.netmgt.model.ServiceSelector)1 OnmsPollModel (org.opennms.netmgt.poller.remote.OnmsPollModel)1 PolledService (org.opennms.netmgt.poller.remote.PolledService)1