Search in sources :

Example 16 with RRDv3

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);
}
Also used : RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) File(java.io.File) Test(org.junit.Test)

Example 17 with RRDv3

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();
}
Also used : FileWriter(java.io.FileWriter) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 18 with RRDv3

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));
    }
}
Also used : RRA(org.opennms.netmgt.rrd.model.v3.RRA) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) AbstractRRD(org.opennms.netmgt.rrd.model.AbstractRRD) Row(org.opennms.netmgt.rrd.model.Row) File(java.io.File) Test(org.junit.Test)

Example 19 with RRDv3

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);
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) File(java.io.File) Test(org.junit.Test)

Example 20 with RRDv3

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);
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) File(java.io.File) Test(org.junit.Test)

Aggregations

RRDv3 (org.opennms.netmgt.rrd.model.v3.RRDv3)21 File (java.io.File)15 Test (org.junit.Test)14 RRDv1 (org.opennms.netmgt.rrd.model.v1.RRDv1)8 ArrayList (java.util.ArrayList)5 Row (org.opennms.netmgt.rrd.model.Row)4 List (java.util.List)3 RRA (org.opennms.netmgt.rrd.model.v3.RRA)3 FileWriter (java.io.FileWriter)2 Map (java.util.Map)2 NavigableMap (java.util.NavigableMap)2 SortedMap (java.util.SortedMap)2 AbstractRRD (org.opennms.netmgt.rrd.model.AbstractRRD)2 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 SAXSource (javax.xml.transform.sax.SAXSource)1 FileUtils (org.apache.commons.io.FileUtils)1 RrdException (org.jrobin.core.RrdException)1