use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.
the class RrdConvertUtilsIT method testConvertAdvRrdIntoJrb1.
/**
* Test convert Advanced RRD into JRB (1).
*
* @throws Exception the exception
*/
@Test(expected = IllegalArgumentException.class)
public void testConvertAdvRrdIntoJrb1() throws Exception {
RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump-compute-ds.xml"));
RRDv1 jrb = RrdConvertUtils.convert(rrd);
Assert.assertNull(jrb);
}
use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.
the class RrdConvertUtilsIT method testConvertJrbIntoRrd.
/**
* Test convert JRB into RRD.
*
* @throws Exception the exception
*/
@Test
public void testConvertJrbIntoRrd() throws Exception {
RRDv1 jrb = RrdConvertUtils.dumpJrb(new File("src/test/resources/tempA.jrb"));
RRDv3 rrd = RrdConvertUtils.convert(jrb);
Assert.assertNotNull(rrd);
}
use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.
the class SnmpInterfaceRrdMigratorOnlineTest method testUpgrade.
/**
* Test upgrade.
*
* @throws Exception the exception
*/
@Test
public void testUpgrade() throws Exception {
// Check Current JRBs
RRDv1 rrd = RrdConvertUtils.dumpJrb(new File("target/home/rrd/1/eth0/ifInOctets.jrb"));
Row r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381500900l);
Assert.assertNotNull(r);
Assert.assertEquals(new Double(-6.0), r.getValues().get(0));
r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381512300l);
Assert.assertNull(r);
rrd = RrdConvertUtils.dumpJrb(new File("target/home/rrd/1/eth0-005056c00008/ifInOctets.jrb"));
r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381500900l);
Assert.assertNotNull(r);
Assert.assertTrue(r.getValues().get(0).isNaN());
r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381512300l);
Assert.assertNotNull(r);
Assert.assertEquals(new Double(12.0), r.getValues().get(0));
// Perform Migration
SnmpInterfaceRrdMigratorOnline obj = new SnmpInterfaceRrdMigratorOnline() {
protected List<SnmpInterfaceUpgrade> getInterfacesToMerge() throws OnmsUpgradeException {
List<SnmpInterfaceUpgrade> interfaces = new ArrayList<>();
interfaces.add(new SnmpInterfaceUpgrade(1, null, null, "eth0", "eth0", "005056c00008", false));
return interfaces;
}
};
obj.preExecute();
obj.execute();
obj.postExecute();
// Verify if the backups have been removed
Assert.assertFalse(new File("target/home/rrd/1/eth0.zip").exists());
Assert.assertFalse(new File("target/home/rrd/1/eth0-005056c00008.zip").exists());
// Check Merged JRB
rrd = RrdConvertUtils.dumpJrb(new File("target/home/rrd/1/eth0-005056c00008/ifInOctets.jrb"));
r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381500900l);
Assert.assertNotNull(r);
Assert.assertEquals(new Double(-6.0), r.getValues().get(0));
r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381512300l);
Assert.assertNotNull(r);
Assert.assertEquals(new Double(12.0), r.getValues().get(0));
}
use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.
the class SnmpInterfaceRrdMigratorOnline method mergeJrb.
/**
* Merge JRBs.
*
* @param source the source JRB
* @param dest the destination JRB
* @throws Exception the exception
*/
protected void mergeJrb(File source, File dest) throws Exception {
log(" merging JRB %s into %s\n", source, dest);
RRDv1 rrdSrc = RrdConvertUtils.dumpJrb(source);
RRDv1 rrdDst = RrdConvertUtils.dumpJrb(dest);
if (rrdSrc == null || rrdDst == null) {
log(" Warning: can't load JRBs (ingoring merge).\n");
return;
}
rrdDst.merge(rrdSrc);
final File outputFile = new File(dest.getCanonicalPath() + ".merged");
RrdConvertUtils.restoreJrb(rrdDst, outputFile);
if (dest.exists()) {
FileUtils.deleteQuietly(dest);
}
FileUtils.moveFile(outputFile, dest);
}
use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.
the class RrdConvertUtils method convertFromRrdToJrobin.
/**
* Convert from RRDtool to JRobin.
*
* @param sourceRrdFile the source RRDtool file
* @param targetJrobinFile the target JRobin file
* @throws IOException Signals that an I/O exception has occurred.
* @throws RrdException the RRD exception
*/
public static void convertFromRrdToJrobin(File sourceRrdFile, File targetJrobinFile) throws IOException, RrdException {
RRDv3 rrd = dumpRrd(sourceRrdFile);
RRDv1 jrb = convert(rrd);
restoreJrb(jrb, targetJrobinFile);
}
Aggregations