use of org.opennms.netmgt.rrd.model.v1.RRA in project opennms by OpenNMS.
the class RRDv1IT method parseRrdSimple.
/**
* Parses a simple RRD.
*
* @throws Exception the exception
*/
@Test
public void parseRrdSimple() throws Exception {
RRDv1 rrd = JaxbUtils.unmarshal(RRDv1.class, new File("src/test/resources/jrb-dump.xml"));
Assert.assertNotNull(rrd);
Assert.assertEquals(new Long(300), rrd.getStep());
Assert.assertEquals(new Long(1233926670), rrd.getLastUpdate());
// Test Data Source
Assert.assertEquals("ifInDiscards", rrd.getDataSources().get(0).getName());
Assert.assertEquals(DSType.COUNTER, rrd.getDataSources().get(0).getType());
Assert.assertEquals(new Long(0), rrd.getDataSources().get(0).getUnknownSec());
// Test RRA
Assert.assertEquals(CFType.AVERAGE, rrd.getRras().get(0).getConsolidationFunction());
Assert.assertEquals(new Long(1), rrd.getRras().get(0).getPdpPerRow());
Assert.assertEquals(new Long(12), rrd.getRras().get(1).getPdpPerRow());
Assert.assertEquals(new Long(288), rrd.getRras().get(4).getPdpPerRow());
// Test time related functions : getEndTimestamp
Assert.assertEquals(new Long(1233926400), rrd.getEndTimestamp(rrd.getRras().get(0)));
Assert.assertEquals(new Long(1233925200), rrd.getEndTimestamp(rrd.getRras().get(1)));
Assert.assertEquals(new Long(1233878400), rrd.getEndTimestamp(rrd.getRras().get(4)));
// Test time related functions : getStartTimestamp
Assert.assertEquals(new Long(1233321900), rrd.getStartTimestamp(rrd.getRras().get(0)));
Assert.assertEquals(new Long(1228572000), rrd.getStartTimestamp(rrd.getRras().get(1)));
Assert.assertEquals(new Long(1202342400), rrd.getStartTimestamp(rrd.getRras().get(4)));
// Test time related functions : findRowByTimestamp
AbstractRRA rra = rrd.getRras().get(0);
Assert.assertEquals(rra.getRows().get(0), rrd.findRowByTimestamp(rra, new Long(1233321900)));
Assert.assertEquals(rra.getRows().get(5), rrd.findRowByTimestamp(rra, new Long(1233323400)));
// Test time related functions : findTimestampByRow
Assert.assertEquals(new Long(1233321900), rrd.findTimestampByRow(rra, rra.getRows().get(0)));
Assert.assertEquals(new Long(1233323400), rrd.findTimestampByRow(rra, rra.getRows().get(5)));
}
use of org.opennms.netmgt.rrd.model.v1.RRA in project opennms by OpenNMS.
the class RRDv3IT method testSplit.
/**
* Test split and merge
*
* @throws Exception the exception
*/
@Test
public void testSplit() throws Exception {
RRDv3 masterRrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump.xml"));
Assert.assertNotNull(masterRrd);
List<AbstractRRD> rrds = masterRrd.split();
Assert.assertEquals(masterRrd.getDataSources().size(), rrds.size());
RRA masterRRA = masterRrd.getRras().get(0);
for (int i = 0; i < rrds.size(); i++) {
RRDv3 singleRRD = (RRDv3) rrds.get(i);
Assert.assertEquals(1, singleRRD.getDataSources().size());
Assert.assertEquals(masterRrd.getDataSource(i).getName(), singleRRD.getDataSource(0).getName());
RRA singleRRA = singleRRD.getRras().get(0);
Assert.assertEquals(1, singleRRA.getDataSources().size());
Assert.assertEquals(masterRRA.getPdpPerRow(), singleRRA.getPdpPerRow());
Assert.assertEquals(masterRRA.getRows().size(), singleRRA.getRows().size());
Assert.assertEquals(masterRRA.getConsolidationFunction().name(), singleRRA.getConsolidationFunction().name());
for (int j = 0; j < masterRRA.getRows().size(); j++) {
Row masterRow = masterRRA.getRows().get(j);
Row row = singleRRA.getRows().get(j);
Assert.assertEquals(1, row.getValues().size());
Assert.assertEquals(masterRow.getValues().get(i), row.getValues().get(0));
masterRow.getValues().set(i, Double.NaN);
}
}
int dsIndex = 3;
masterRrd.merge(rrds);
for (int j = 0; j < masterRRA.getRows().size(); j++) {
Row masterRow = masterRRA.getRows().get(j);
Row row = rrds.get(dsIndex).getRras().get(0).getRows().get(j);
Assert.assertEquals(1, row.getValues().size());
Assert.assertEquals(masterRow.getValues().get(dsIndex), row.getValues().get(0));
}
}
Aggregations