public void addDatasource(String sourcePath, String destPath, DsDef newDatasource) { if (Util.sameFilePath(sourcePath, destPath)) { throw new RrdException("Source and destination paths are the same"); } RrdDb rrdSource = new RrdDb(sourcePath); RrdDef rrdDef = rrdSource.getRrdDef(); rrdDef.setPath(destPath); rrdDef.addDatasource(newDatasource); RrdDb rrdDest = new RrdDb(rrdDef); rrdSource.copyStateTo(rrdDest); rrdSource.close(); rrdDest.close(); }
public void addDatasource(String sourcePath, DsDef newDatasource, boolean saveBackup) { String destPath = Util.getTmpFilename(); addDatasource(sourcePath, destPath, newDatasource); copyFile(destPath, sourcePath, saveBackup); }