use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.
the class DefaultPollerBackEnd method getParameterMap.
protected static Map<String, Object> getParameterMap(final Service serviceConfig) {
final Map<String, Object> paramMap = new HashMap<String, Object>();
for (final Parameter serviceParm : serviceConfig.getParameters()) {
String value = serviceParm.getValue();
if (value == null) {
final Object o = serviceParm.getAnyObject();
if (o == null) {
value = "";
} else if (o instanceof PageSequence) {
// The PageSequenceMonitor uses PageSequence type parameters in the service definition
// These need to be marshalled to XML before being sent to the PollerFrontEnd
value = JaxbUtils.marshal(o);
} else {
value = o.toString();
}
}
paramMap.put(serviceParm.getKey(), value);
}
return paramMap;
}
use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.
the class PollableServiceConfig method createParameterMap.
private Map<String, Object> createParameterMap(final Service svc) {
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
for (final Parameter p : svc.getParameters()) {
Object val = p.getValue();
if (val == null) {
val = (p.getAnyObject() == null ? "" : p.getAnyObject());
}
m.put(p.getKey(), val);
}
return m;
}
use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.
the class PollerConfigWithPSMIT method testPSM.
@Test
public void testPSM() throws Exception {
InputStream is = new FileInputStream(new File("src/test/resources/etc/psm-poller-configuration.xml"));
PollerConfigFactory factory = new PollerConfigFactory(0, is, "localhost", false);
PollerConfigFactory.setInstance(factory);
IOUtils.closeQuietly(is);
ServiceMonitor monitor = PollerConfigFactory.getInstance().getServiceMonitor("MQ_API_DirectRte_v2");
Assert.assertNotNull(monitor);
Package pkg = PollerConfigFactory.getInstance().getPackage("MapQuest");
Assert.assertNotNull(pkg);
Service svc = PollerConfigFactory.getInstance().getServiceInPackage("MQ_API_DirectRte_v2", pkg);
Assert.assertNotNull(svc);
Map<String, Object> parameters = new HashMap<String, Object>();
for (Parameter p : svc.getParameters()) {
parameters.put(p.getKey(), p.getValue() == null ? p.getAnyObject() : p.getValue());
}
PollStatus status = monitor.poll(new MockMonitoredService(1, "www.mapquest.com", InetAddress.getByName("www.mapquest.com"), "MQ_API_DirectRte_v2"), parameters);
Assert.assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
Aggregations