/** * Renames single datasource in the given RRD file. * * @param sourcePath Path to a RRD file * @param oldDsName Old datasource name * @param newDsName New datasource name * @throws IOException Thrown in case of I/O error */ public static void renameDatasource(String sourcePath, String oldDsName, String newDsName) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { if (rrd.containsDs(oldDsName)) { Datasource datasource = rrd.getDatasource(oldDsName); datasource.setDsName(newDsName); } else { throw new IllegalArgumentException("Could not find datasource [" + oldDsName + "] in file " + sourcePath); } } finally { rrd.close(); } }
/** * Renames single datasource in the given RRD file. * * @param sourcePath Path to a RRD file * @param oldDsName Old datasource name * @param newDsName New datasource name * @throws java.io.IOException Thrown in case of I/O error */ public static void renameDatasource(String sourcePath, String oldDsName, String newDsName) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { if (rrd.containsDs(oldDsName)) { Datasource datasource = rrd.getDatasource(oldDsName); datasource.setDsName(newDsName); } else { throw new IllegalArgumentException("Could not find datasource [" + oldDsName + "] in file " + sourcePath); } } }
String currentDsName = datasource.getName(); if (!currentDsName.endsWith(DsDef.FORCE_ZEROS_FOR_NANS_SUFFIX)) { datasource.setDsName(currentDsName + DsDef.FORCE_ZEROS_FOR_NANS_SUFFIX); count++;
String currentDsName = datasource.getName(); if (!currentDsName.endsWith(DsDef.FORCE_ZEROS_FOR_NANS_SUFFIX)) { datasource.setDsName(currentDsName + DsDef.FORCE_ZEROS_FOR_NANS_SUFFIX); count++;