use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.
the class RRDv3IT method parseRrdWithComputedDs.
/**
* Parses the RRD with computed DS.
*
* @throws Exception the exception
*/
@Test
public void parseRrdWithComputedDs() throws Exception {
RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump-compute-ds.xml"));
Assert.assertNotNull(rrd);
}
use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.
the class RRDv3IT method testMerge.
/**
* Test merge.
*
* @throws Exception the exception
*/
@Test
public void testMerge() throws Exception {
File sourceFile = new File("src/test/resources/rrd-temp-multids-rrd.xml");
File targetFile = new File("target/multimetric.xml");
RRDv3 multimetric = JaxbUtils.unmarshal(RRDv3.class, sourceFile);
Assert.assertNotNull(multimetric);
Assert.assertEquals("tempA", multimetric.getDataSource(0).getName());
Assert.assertEquals("tempB", multimetric.getDataSource(1).getName());
multimetric.reset();
List<RRDv3> singleMetricArray = new ArrayList<>();
RRDv3 tempA = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-tempA-rrd.xml"));
Assert.assertNotNull(tempA);
Assert.assertEquals("tempA", tempA.getDataSource(0).getName());
singleMetricArray.add(tempA);
RRDv3 tempB = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-tempB-rrd.xml"));
Assert.assertNotNull(tempB);
Assert.assertEquals("tempB", tempB.getDataSource(0).getName());
singleMetricArray.add(tempB);
multimetric.merge(singleMetricArray);
JaxbUtils.marshal(multimetric, new FileWriter(targetFile));
Assert.assertTrue(FileUtils.contentEquals(sourceFile, targetFile));
targetFile.delete();
}
use of org.opennms.netmgt.rrd.model.v3.RRDv3 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));
}
}
use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.
the class RrdConvertUtilsIT method testConvertAdvRrdIntoJrb2.
/**
* Test convert Advanced RRD into JRB (2).
*
* @throws Exception the exception
*/
@Test(expected = IllegalArgumentException.class)
public void testConvertAdvRrdIntoJrb2() throws Exception {
RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump-aberrant-behavior-detection.xml"));
RRDv1 jrb = RrdConvertUtils.convert(rrd);
Assert.assertNull(jrb);
}
use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.
the class RrdConvertUtilsIT method testConvertRrdIntoJrb.
/**
* Test convert RRD into JRB.
*
* @throws Exception the exception
*/
@Test
public void testConvertRrdIntoJrb() throws Exception {
RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump.xml"));
RRDv1 jrb = RrdConvertUtils.convert(rrd);
Assert.assertNotNull(jrb);
}
Aggregations