use of org.opennms.netmgt.config.poller.Monitor in project opennms by OpenNMS.
the class PollerConfigServlet method removeMonitor.
/**
* <p>removeMonitor</p>
*
* FIXME: I think that this should be using Iterator.remove()
*
* @param service a {@link java.lang.String} object.
*/
public void removeMonitor(String service) {
// Add the new monitor with the protocol.
Collection<Monitor> monitorColl = pollerConfig.getMonitors();
Monitor newMonitor = new Monitor();
if (monitorColl != null) {
for (Monitor mon : monitorColl) {
if (mon != null) {
if (mon.getService().equals(service)) {
newMonitor.setService(service);
newMonitor.setClassName(mon.getClassName());
newMonitor.setParameters(mon.getParameters());
break;
}
}
}
monitorColl.remove(newMonitor);
}
}
use of org.opennms.netmgt.config.poller.Monitor in project opennms by OpenNMS.
the class PollerConfigManager method addMonitor.
/** {@inheritDoc} */
@Override
public void addMonitor(final String svcName, final String className) {
try {
getWriteLock().lock();
final Monitor monitor = new Monitor();
monitor.setService(svcName);
monitor.setClassName(className);
m_config.addMonitor(monitor);
} finally {
getWriteLock().unlock();
}
}
use of org.opennms.netmgt.config.poller.Monitor in project opennms by OpenNMS.
the class PollerConfigManager method getServiceMonitorLocators.
/** {@inheritDoc} */
@Override
public Collection<ServiceMonitorLocator> getServiceMonitorLocators(final DistributionContext context) {
List<ServiceMonitorLocator> locators = new ArrayList<ServiceMonitorLocator>();
try {
getReadLock().lock();
for (final Monitor monitor : monitors()) {
try {
final Class<? extends ServiceMonitor> mc = findServiceMonitorClass(monitor);
if (isDistributableToContext(mc, context)) {
final ServiceMonitorLocator locator = new DefaultServiceMonitorLocator(monitor.getService(), mc);
locators.add(locator);
}
LOG.debug("Loaded monitor for service: {}, class-name: {}", monitor.getService(), monitor.getClassName());
} catch (final ClassNotFoundException e) {
LOG.warn("Unable to load monitor for service: {}, class-name: {}: {}", monitor.getService(), monitor.getClassName(), e.getMessage());
} catch (ConfigObjectRetrievalFailureException e) {
LOG.warn("{} {}", e.getMessage(), e.getRootCause(), e);
}
}
} finally {
getReadLock().unlock();
}
return locators;
}
Aggregations