From: Sasa M. <sa...@us...> - 2004-07-13 11:45:47
|
Update of /cvsroot/jrobin/src/org/jrobin/cmd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21479/org/jrobin/cmd Modified Files: RrdCommander.java Added Files: RrdRestoreCmd.java Log Message: rrdrestore command supported Index: RrdCommander.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/cmd/RrdCommander.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdCommander.java 12 Jul 2004 13:54:03 -0000 1.2 --- RrdCommander.java 13 Jul 2004 11:45:39 -0000 1.3 *************** *** 96,99 **** --- 96,101 ---- *<li><b>dump</b>: returns (very long) java.lang.String representing the content of a RRD file * in XML format. + * <li><b>fetch</b>: returns {@link org.jrobin.core.FetchData} object representing fetched data. + * <li><b>restore</b>: returns java.lang.String containing path to the restored RRD file. * </ul> * @throws IOException thrown in case of I/O error *************** *** 108,112 **** new RrdUpdateCommand(cmdScanner), new RrdDumpCmd(cmdScanner), ! new RrdFetchCmd(cmdScanner) }; for(int i = 0; i < commanders.length; i++) { --- 110,115 ---- new RrdUpdateCommand(cmdScanner), new RrdDumpCmd(cmdScanner), ! new RrdFetchCmd(cmdScanner), ! new RrdRestoreCmd(cmdScanner) }; for(int i = 0; i < commanders.length; i++) { --- NEW FILE: RrdRestoreCmd.java --- package org.jrobin.cmd; import org.jrobin.core.RrdException; import org.jrobin.core.RrdDb; import org.jrobin.core.Datasource; import java.io.IOException; class RrdRestoreCmd extends RrdToolCmd { public RrdRestoreCmd(RrdCmdScanner cmdScanner) { super(cmdScanner); } String getCmdType() { return "restore"; } Object execute() throws RrdException, IOException { boolean check = cmdScanner.getBooleanOption("r", "range-check"); String[] words = cmdScanner.getRemainingWords(); if(words.length != 3) { throw new RrdException("Invalid rrdrestore syntax"); } String xmlPath = words[1]; String rrdPath = words[2]; RrdDb rrdDb = getRrdDbReference(rrdPath, xmlPath); try { if(check) { int dsCount = rrdDb.getHeader().getDsCount(); for(int i = 0; i < dsCount; i++) { Datasource ds = rrdDb.getDatasource(i); double minValue = ds.getMinValue(); double maxValue = ds.getMaxValue(); // this will perform range check ds.setMinMaxValue(minValue, maxValue, true); } } return rrdPath; } finally { releaseRrdDbReference(rrdDb); } } } |