use of org.opennms.netmgt.config.threshd.Package in project opennms by OpenNMS.
the class ThreshdConfigManager method createPackageIpListMap.
/**
* This method is used to establish package against an iplist iplist mapping,
* with which, the iplist is selected per package via the configured filter
* rules from the database.
*/
protected void createPackageIpListMap() {
m_pkgIpMap = new HashMap<Package, List<InetAddress>>();
for (final org.opennms.netmgt.config.threshd.Package pkg : m_config.getPackages()) {
//
// Get a list of ipaddress per package agaist the filter rules from
// database and populate the package, IP list map.
//
final StringBuffer filterRules = new StringBuffer();
if (pkg.getFilter().getContent().isPresent()) {
filterRules.append(pkg.getFilter().getContent().get());
}
try {
if (m_verifyServer) {
if (filterRules.length() > 0) {
filterRules.append(" & ");
}
filterRules.append("(serverName == ");
filterRules.append('\"');
filterRules.append(m_localServer);
filterRules.append('\"');
filterRules.append(")");
}
LOG.debug("createPackageIpMap: package is {}. filer rules are {}", filterRules, pkg.getName());
FilterDaoFactory.getInstance().flushActiveIpAddressListCache();
List<InetAddress> ipList = FilterDaoFactory.getInstance().getActiveIPAddressList(filterRules.toString());
if (ipList.size() > 0) {
m_pkgIpMap.put(pkg, ipList);
}
} catch (Throwable t) {
LOG.error("createPackageIpMap: failed to map package: {} to an IP List with filter \"{}\"", pkg.getName(), pkg.getFilter().getContent(), t);
}
}
}
use of org.opennms.netmgt.config.threshd.Package in project opennms by OpenNMS.
the class ThresholdingVisitorIT method testBug3390.
/*
* This test uses this files from src/test/resources:
* - threshd-configuration-bug3390.xml
* - test-thresholds-bug3390.xml
*
* The idea is to define many threshold-group parameters on a service inside a package
*/
@Test
public void testBug3390() throws Exception {
initFactories("/threshd-configuration-bug3390.xml", "/test-thresholds-bug3390.xml");
// Validating threshd-configuration.xml
ThreshdConfigManager configManager = ThreshdConfigFactory.getInstance();
final List<Package> packages = configManager.getConfiguration().getPackages();
assertEquals(1, packages.size());
org.opennms.netmgt.config.threshd.Package pkg = packages.get(0);
final List<Service> services = pkg.getServices();
assertEquals(1, services.size());
org.opennms.netmgt.config.threshd.Service svc = services.get(0);
final List<Parameter> parameters = svc.getParameters();
assertEquals(5, parameters.size());
int count = 0;
for (org.opennms.netmgt.config.threshd.Parameter parameter : parameters) {
if (parameter.getKey().equals("thresholding-group"))
count++;
}
assertEquals(5, count);
// Validating Thresholding Set
ThresholdingVisitor visitor = createVisitor();
assertEquals(5, visitor.getThresholdGroups().size());
}
Aggregations