@Test public void testUpgradeSingleMetric() throws Exception { FileUtils.copyDirectory(new File("src/test/resources/rrd"), new File("target/home/rrd")); JmxRrdMigratorOffline jmxMigrator = executeMigrator(); File rrdDir = new File("target/home/rrd/1/opennms-jvm/"); for (File file : getFiles(rrdDir, ".jrb")) { RrdDb jrb = new RrdDb(file, true); String ds = jrb.getDsNames()[0]; jrb.close(); Assert.assertFalse(ds.contains(".")); Assert.assertEquals(file.getName(), ds + ".jrb"); Assert.assertEquals(ds, jmxMigrator.getFixedDsName(ds)); } for (File file : getFiles(rrdDir, ".meta")) { String ds = file.getName().replaceFirst("\\.meta", ""); Properties p = new Properties(); p.load(new FileReader(file)); for (Object o : p.keySet()) { String key = (String) o; Assert.assertTrue(key.endsWith(ds)); Assert.assertEquals(ds, p.getProperty(key)); } } }
protected String getFixedDsName(String dsName) { if (dsName.contains(".")) { String parts[] = dsName.split("\\."); return parts[0] + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1); } return dsName; }
JmxRrdMigratorOffline extends AbstractOnmsUpgrade { protected String getFixedDsName(String dsName) { if (dsName.contains(".")) { String parts[] = dsName.split("\\."); return parts[0] + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1); } return dsName; } }
JmxRrdMigratorOffline extends AbstractOnmsUpgrade { protected String getFixedDsName(String dsName) { if (dsName.contains(".")) { String parts[] = dsName.split("\\."); return parts[0] + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1); } return dsName; } JmxRrdMigratorOffline(); }
JmxRrdMigratorOffline extends AbstractOnmsUpgrade { protected String getFixedDsName(String dsName) { if (dsName.contains(".")) { String parts[] = dsName.split("\\."); return parts[0] + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1); } return dsName; } JmxRrdMigratorOffline(); @Override int getOrder(); @Override String getDescription(); @Override boolean requiresOnmsRunning(); @Override void preExecute(); @Override void postExecute(); @Override void rollback(); @Override void execute(); }
JmxRrdMigratorOffline extends AbstractOnmsUpgrade { protected String getFixedDsName(String dsName) { if (dsName.contains(".")) { String parts[] = dsName.split("\\."); return parts[0] + parts[1].substring(0, 1).toUpperCase() + parts[1].substring(1); } return dsName; } JmxRrdMigratorOffline(); @Override int getOrder(); @Override String getDescription(); @Override boolean requiresOnmsRunning(); @Override void preExecute(); @Override void postExecute(); @Override void rollback(); @Override void execute();  }