use of org.opennms.netmgt.config.statsd.model.Report in project opennms by OpenNMS.
the class ReportDefinitionBuilder method buildReportDefinitions.
/**
* Builds and schedules all reports enabled in the statsd-configuration.
* This method has the capability to throw a ton of exceptions, just generically throwing <code>Exception</code>
*
* @return a <code>Collection</code> of enabled reports from the statsd-configuration.
* @throws java.lang.Exception if any.
*/
public Collection<ReportDefinition> buildReportDefinitions() throws Exception {
Set<ReportDefinition> reportDefinitions = new HashSet<>();
for (StatsdPackage pkg : m_statsdConfigDao.getPackages()) {
for (PackageReport packageReport : pkg.getReports()) {
Report report = packageReport.getReport();
if (!packageReport.isEnabled()) {
LOG.debug("skipping report '{}' in package '{}' because the report is not enabled", report.getName(), pkg.getName());
continue;
}
Class<? extends AttributeStatisticVisitorWithResults> clazz;
try {
clazz = createClassForReport(report);
} catch (ClassNotFoundException e) {
throw new DataAccessResourceFailureException("Could not find class '" + report.getClassName() + "'; nested exception: " + e, e);
}
Assert.isAssignable(AttributeStatisticVisitorWithResults.class, clazz, "the class specified by class-name in the '" + report.getName() + "' report does not implement the interface " + AttributeStatisticVisitorWithResults.class.getName() + "; ");
ReportDefinition reportDef = new ReportDefinition();
reportDef.setReport(packageReport);
reportDef.setReportClass(clazz);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(reportDef);
try {
bw.setPropertyValues(packageReport.getAggregateParameters());
} catch (BeansException e) {
LOG.error("Could not set properties on report definition: {}", e.getMessage(), e);
}
reportDef.afterPropertiesSet();
reportDefinitions.add(reportDef);
}
}
return reportDefinitions;
}
use of org.opennms.netmgt.config.statsd.model.Report in project opennms by OpenNMS.
the class DefaultStatisticsDaemonConfigDaoTest method testGetReports.
public void testGetReports() throws Exception {
DefaultStatisticsDaemonConfigDao dao = new DefaultStatisticsDaemonConfigDao();
InputStream in = ConfigurationTestUtils.getInputStreamForConfigFile("statsd-configuration.xml");
dao.setConfigResource(new InputStreamResource(in));
dao.afterPropertiesSet();
List<Report> reports = dao.getReports();
assertNotNull("reports list should not be null", reports);
assertTrue("at least two reports should be present but found " + reports.size(), reports.size() > 1);
assertNotNull("first report should non-null", reports.get(0));
}
Aggregations