Search in sources :

Example 6 with AttributeStatistic

use of org.opennms.netmgt.model.AttributeStatistic in project opennms by OpenNMS.

the class TopNAttributeStatisticVisitorTest method testVisitGetResults.

public void testVisitGetResults() throws Exception {
    BottomNAttributeStatisticVisitor visitor = new TopNAttributeStatisticVisitor();
    visitor.setCount(20);
    visitor.afterPropertiesSet();
    Map<OnmsAttribute, Double> attributes = new HashMap<OnmsAttribute, Double>();
    attributes.put(new MockAttribute("foo"), 0.0);
    OnmsResource resource = new OnmsResource("1", "Node One", new MockResourceType(), attributes.keySet(), ResourcePath.get("foo"));
    resource.getAttributes();
    for (Entry<OnmsAttribute, Double> entry : attributes.entrySet()) {
        visitor.visit(entry.getKey(), entry.getValue());
    }
    SortedSet<AttributeStatistic> top = visitor.getResults();
    assertNotNull("topN list should not be null", top);
    assertEquals("topN list size", 1, top.size());
    int i = 0;
    for (AttributeStatistic stat : top) {
        assertEquals("topN[" + i + "] value", 0.0, stat.getStatistic());
    }
}
Also used : HashMap(java.util.HashMap) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) OnmsResource(org.opennms.netmgt.model.OnmsResource) AttributeStatistic(org.opennms.netmgt.model.AttributeStatistic) MockResourceType(org.opennms.netmgt.mock.MockResourceType)

Example 7 with AttributeStatistic

use of org.opennms.netmgt.model.AttributeStatistic in project opennms by OpenNMS.

the class StandardOutputReportPersister method persist.

/** {@inheritDoc} */
@Override
public void persist(ReportInstance report) {
    System.out.println("Top " + report.getCount() + " " + report.getAttributeMatch() + " data sources on resources of type " + report.getResourceTypeMatch() + " from " + new Date(report.getStartTime()) + " to " + new Date(report.getEndTime()));
    SortedSet<AttributeStatistic> top = report.getResults();
    for (AttributeStatistic stat : top) {
        System.out.println(stat.getAttribute().getResource().getId() + "/" + stat.getAttribute().getName() + ": " + stat.getStatistic());
    }
    System.out.println("");
}
Also used : AttributeStatistic(org.opennms.netmgt.model.AttributeStatistic) Date(java.util.Date)

Aggregations

AttributeStatistic (org.opennms.netmgt.model.AttributeStatistic)7 HashMap (java.util.HashMap)4 MockResourceType (org.opennms.netmgt.mock.MockResourceType)4 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)4 OnmsResource (org.opennms.netmgt.model.OnmsResource)4 Date (java.util.Date)2 ResourceReference (org.opennms.netmgt.model.ResourceReference)1 StatisticsReport (org.opennms.netmgt.model.StatisticsReport)1 StatisticsReportData (org.opennms.netmgt.model.StatisticsReportData)1