@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); }
protected static RRDv3 convert(RRDv1 jrb) throws IllegalArgumentException { RRDv3 rrd = new RRDv3(); rrd.setStep(jrb.getStep()); rrd.setLastUpdate(jrb.getLastUpdate()); for (org.opennms.netmgt.rrd.model.v1.RRA rrav1 : jrb.getRras()) { org.opennms.netmgt.rrd.model.v3.RRA rrav3 = new org.opennms.netmgt.rrd.model.v3.RRA(); rrav3.setConsolidationFunction(rrav1.getConsolidationFunction().name()); rrav3.setPdpPerRow(rrav1.getPdpPerRow()); rrav3.setRows(rrav1.getRows()); rrav3.getParameters().setXff(rrav1.getXff()); for (org.opennms.netmgt.rrd.model.v1.RRADS rradsv1 : rrav1.getDataSources()) { org.opennms.netmgt.rrd.model.v3.RRADS rradsv3 = new org.opennms.netmgt.rrd.model.v3.RRADS(); rradsv3.setUnknownDataPoints(rradsv1.getUnknownDataPoints()); rradsv3.setValue(rradsv1.getValue()); rrav3.getDataSources().add(rradsv3); } rrd.addRRA(rrav3); } for (org.opennms.netmgt.rrd.model.v1.DS dsv1 : jrb.getDataSources()) { org.opennms.netmgt.rrd.model.v3.DS dsv3 = new org.opennms.netmgt.rrd.model.v3.DS(); dsv3.setName(dsv1.getName()); dsv3.setLastDs(dsv1.getLastDs()); dsv3.setMin(dsv1.getMax()); dsv3.setMax(dsv1.getMax()); dsv3.setMinHeartbeat(dsv1.getMinHeartbeat()); dsv3.setUnknownSec(dsv1.getUnknownSec()); dsv3.setValue(dsv1.getValue()); dsv3.setType(dsv1.getType().value()); rrd.addDataSource(dsv3); } return rrd; }
RrdConvertUtils { protected static RRDv3 convert(RRDv1 jrb) throws IllegalArgumentException { RRDv3 rrd = new RRDv3(); rrd.setStep(jrb.getStep()); rrd.setLastUpdate(jrb.getLastUpdate()); for (org.opennms.netmgt.rrd.model.v1.RRA rrav1 : jrb.getRras()) { org.opennms.netmgt.rrd.model.v3.RRA rrav3 = new org.opennms.netmgt.rrd.model.v3.RRA(); rrav3.setConsolidationFunction(rrav1.getConsolidationFunction().name()); rrav3.setPdpPerRow(rrav1.getPdpPerRow()); rrav3.setRows(rrav1.getRows()); rrav3.getParameters().setXff(rrav1.getXff()); for (org.opennms.netmgt.rrd.model.v1.RRADS rradsv1 : rrav1.getDataSources()) { org.opennms.netmgt.rrd.model.v3.RRADS rradsv3 = new org.opennms.netmgt.rrd.model.v3.RRADS(); rradsv3.setUnknownDataPoints(rradsv1.getUnknownDataPoints()); rradsv3.setValue(rradsv1.getValue()); rrav3.getDataSources().add(rradsv3); } rrd.addRRA(rrav3); } for (org.opennms.netmgt.rrd.model.v1.DS dsv1 : jrb.getDataSources()) { org.opennms.netmgt.rrd.model.v3.DS dsv3 = new org.opennms.netmgt.rrd.model.v3.DS(); dsv3.setName(dsv1.getName()); dsv3.setLastDs(dsv1.getLastDs()); dsv3.setMin(dsv1.getMax()); dsv3.setMax(dsv1.getMax()); dsv3.setMinHeartbeat(dsv1.getMinHeartbeat()); dsv3.setUnknownSec(dsv1.getUnknownSec()); dsv3.setValue(dsv1.getValue()); dsv3.setType(dsv1.getType().value()); rrd.addDataSource(dsv3); } return rrd; } }
RrdConvertUtils { protected static RRDv3 convert(RRDv1 jrb) throws IllegalArgumentException { RRDv3 rrd = new RRDv3(); rrd.setStep(jrb.getStep()); rrd.setLastUpdate(jrb.getLastUpdate()); for (org.opennms.netmgt.rrd.model.v1.RRA rrav1 : jrb.getRras()) { org.opennms.netmgt.rrd.model.v3.RRA rrav3 = new org.opennms.netmgt.rrd.model.v3.RRA(); rrav3.setConsolidationFunction(rrav1.getConsolidationFunction().name()); rrav3.setPdpPerRow(rrav1.getPdpPerRow()); rrav3.setRows(rrav1.getRows()); rrav3.getParameters().setXff(rrav1.getXff()); for (org.opennms.netmgt.rrd.model.v1.RRADS rradsv1 : rrav1.getDataSources()) { org.opennms.netmgt.rrd.model.v3.RRADS rradsv3 = new org.opennms.netmgt.rrd.model.v3.RRADS(); rradsv3.setUnknownDataPoints(rradsv1.getUnknownDataPoints()); rradsv3.setValue(rradsv1.getValue()); rrav3.getDataSources().add(rradsv3); } rrd.addRRA(rrav3); } for (org.opennms.netmgt.rrd.model.v1.DS dsv1 : jrb.getDataSources()) { org.opennms.netmgt.rrd.model.v3.DS dsv3 = new org.opennms.netmgt.rrd.model.v3.DS(); dsv3.setName(dsv1.getName()); dsv3.setLastDs(dsv1.getLastDs()); dsv3.setMin(dsv1.getMax()); dsv3.setMax(dsv1.getMax()); dsv3.setMinHeartbeat(dsv1.getMinHeartbeat()); dsv3.setUnknownSec(dsv1.getUnknownSec()); dsv3.setValue(dsv1.getValue()); dsv3.setType(dsv1.getType().value()); rrd.addDataSource(dsv3); } return rrd; } private  RrdConvertUtils(); }
RrdConvertUtils { protected static RRDv3 convert(RRDv1 jrb) throws IllegalArgumentException { RRDv3 rrd = new RRDv3(); rrd.setStep(jrb.getStep()); rrd.setLastUpdate(jrb.getLastUpdate()); for (org.opennms.netmgt.rrd.model.v1.RRA rrav1 : jrb.getRras()) { org.opennms.netmgt.rrd.model.v3.RRA rrav3 = new org.opennms.netmgt.rrd.model.v3.RRA(); rrav3.setConsolidationFunction(rrav1.getConsolidationFunction().name()); rrav3.setPdpPerRow(rrav1.getPdpPerRow()); rrav3.setRows(rrav1.getRows()); rrav3.getParameters().setXff(rrav1.getXff()); for (org.opennms.netmgt.rrd.model.v1.RRADS rradsv1 : rrav1.getDataSources()) { org.opennms.netmgt.rrd.model.v3.RRADS rradsv3 = new org.opennms.netmgt.rrd.model.v3.RRADS(); rradsv3.setUnknownDataPoints(rradsv1.getUnknownDataPoints()); rradsv3.setValue(rradsv1.getValue()); rrav3.getDataSources().add(rradsv3); } rrd.addRRA(rrav3); } for (org.opennms.netmgt.rrd.model.v1.DS dsv1 : jrb.getDataSources()) { org.opennms.netmgt.rrd.model.v3.DS dsv3 = new org.opennms.netmgt.rrd.model.v3.DS(); dsv3.setName(dsv1.getName()); dsv3.setLastDs(dsv1.getLastDs()); dsv3.setMin(dsv1.getMax()); dsv3.setMax(dsv1.getMax()); dsv3.setMinHeartbeat(dsv1.getMinHeartbeat()); dsv3.setUnknownSec(dsv1.getUnknownSec()); dsv3.setValue(dsv1.getValue()); dsv3.setType(dsv1.getType().value()); rrd.addDataSource(dsv3); } return rrd; } private  RrdConvertUtils(); static RRDv1 dumpJrb(File sourceFile); static RRDv3 dumpRrd(File sourceFile); static void restoreJrb(RRDv1 rrd, File targetFile); static void restoreRrd(RRDv3 rrd, File targetFile); static void convertFromRrdToJrobin(File sourceRrdFile, File targetJrobinFile); static void convertFromJrobinToRrd(File sourceJrobinFile, File targetRrdFile); }
RrdConvertUtils { protected static RRDv3 convert(RRDv1 jrb) throws IllegalArgumentException { RRDv3 rrd = new RRDv3(); rrd.setStep(jrb.getStep()); rrd.setLastUpdate(jrb.getLastUpdate()); for (org.opennms.netmgt.rrd.model.v1.RRA rrav1 : jrb.getRras()) { org.opennms.netmgt.rrd.model.v3.RRA rrav3 = new org.opennms.netmgt.rrd.model.v3.RRA(); rrav3.setConsolidationFunction(rrav1.getConsolidationFunction().name()); rrav3.setPdpPerRow(rrav1.getPdpPerRow()); rrav3.setRows(rrav1.getRows()); rrav3.getParameters().setXff(rrav1.getXff()); for (org.opennms.netmgt.rrd.model.v1.RRADS rradsv1 : rrav1.getDataSources()) { org.opennms.netmgt.rrd.model.v3.RRADS rradsv3 = new org.opennms.netmgt.rrd.model.v3.RRADS(); rradsv3.setUnknownDataPoints(rradsv1.getUnknownDataPoints()); rradsv3.setValue(rradsv1.getValue()); rrav3.getDataSources().add(rradsv3); } rrd.addRRA(rrav3); } for (org.opennms.netmgt.rrd.model.v1.DS dsv1 : jrb.getDataSources()) { org.opennms.netmgt.rrd.model.v3.DS dsv3 = new org.opennms.netmgt.rrd.model.v3.DS(); dsv3.setName(dsv1.getName()); dsv3.setLastDs(dsv1.getLastDs()); dsv3.setMin(dsv1.getMax()); dsv3.setMax(dsv1.getMax()); dsv3.setMinHeartbeat(dsv1.getMinHeartbeat()); dsv3.setUnknownSec(dsv1.getUnknownSec()); dsv3.setValue(dsv1.getValue()); dsv3.setType(dsv1.getType().value()); rrd.addDataSource(dsv3); } return rrd; } private  RrdConvertUtils(); static RRDv1 dumpJrb(File sourceFile); static RRDv3 dumpRrd(File sourceFile); static void restoreJrb(RRDv1 rrd, File targetFile); static void restoreRrd(RRDv3 rrd, File targetFile); static void convertFromRrdToJrobin(File sourceRrdFile, File targetJrobinFile); static void convertFromJrobinToRrd(File sourceJrobinFile, File targetRrdFile);  }