/** * Sets datasource name to a new value * * @param newDsName New datasource name * @throws java.io.IOException Thrown in case of I/O error */ public void setDsName(String newDsName) throws IOException { if (parentDb.containsDs(newDsName)) { throw new IllegalArgumentException("Datasource already defined in this RRD: " + newDsName); } this.dsName.set(newDsName); }
/** * Sets datasource name to a new value * * @param newDsName New datasource name * @throws IOException Thrown in case of I/O error */ public void setDsName(String newDsName) throws IOException { if (newDsName != null && newDsName.length() > RrdString.STRING_LENGTH) { throw new IllegalArgumentException("Invalid datasource name specified: " + newDsName); } if (parentDb.containsDs(newDsName)) { throw new IllegalArgumentException("Datasource already defined in this RRD: " + newDsName); } this.dsName.set(newDsName); }
/** * 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); } } }
datasources = rrd.getDatasources(); } else { if (rrd.containsDs(dsName)) { datasources = new Datasource[]{rrd.getDatasource(dsName)}; } else {
datasources = rrd.getDatasources(); } else { if (rrd.containsDs(dsName)) { datasources = new Datasource[]{rrd.getDatasource(dsName)}; } else {