From: Sasa M. <sa...@us...> - 2004-11-19 13:44:10
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27170/org/jrobin/core Modified Files: FetchData.java FetchDataStats.java Log Message: Added split() method to the RrdToolkit class to split single RRD file into several new ones. Each new file contains only a single datasource. All archived values are preserved. Index: FetchData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/FetchData.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FetchData.java 18 Nov 2004 13:27:58 -0000 1.11 --- FetchData.java 19 Nov 2004 13:43:52 -0000 1.12 *************** *** 318,324 **** * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are "MIN", "MAX", "LAST", "AVERAGE" and "TOTAL" * (these string constants are conveniently defined in the {@link ConsolFuns} class) ! * @return MIN, MAX, LAST, AVERAGE or TOTAL value calculated from the fetched data * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. --- 318,324 ---- * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are "MIN", "MAX", "LAST", "FIRST", "AVERAGE" and "TOTAL" * (these string constants are conveniently defined in the {@link ConsolFuns} class) ! * @return MIN, MAX, LAST, FIRST, AVERAGE or TOTAL value calculated from the fetched data * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. *************** *** 337,340 **** --- 337,343 ---- return stats.getLast(); } + else if (consolFun.equals(CF_FIRST)) { + return stats.getFirst(); + } else if (consolFun.equals(CF_AVERAGE)) { return stats.getAverage(); *************** *** 352,356 **** * * @param dsName Datasource name ! * @return Object containing MIN, MAX, LAST, AVERAGE and TOTAL values calculated from the fetched data * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. --- 355,359 ---- * * @param dsName Datasource name ! * @return Object containing MIN, MAX, LAST, FIRST, AVERAGE and TOTAL values calculated from the fetched data * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. *************** *** 372,376 **** * * @param dsName Datasource name ! * @return Object containing MIN, MAX, LAST, AVERAGE and TOTAL values calculated from the fetched data * for the given datasource name and a given RPN expression * @throws RrdException Thrown if the given datasource name cannot be found in fetched data --- 375,379 ---- * * @param dsName Datasource name ! * @return Object containing MIN, MAX, LAST, FIRST, AVERAGE and TOTAL values calculated from the fetched data * for the given datasource name and a given RPN expression * @throws RrdException Thrown if the given datasource name cannot be found in fetched data *************** *** 379,383 **** double[] values = getValues(dsName); long totalSecs = 0; ! double totalValue = 0.0, min = Double.NaN, max = Double.NaN, last = Double.NaN; RpnCalculator rpnCalculator = null; if (rpnExpression != null) { --- 382,386 ---- double[] values = getValues(dsName); long totalSecs = 0; ! double totalValue = 0.0, min = Double.NaN, max = Double.NaN; RpnCalculator rpnCalculator = null; if (rpnExpression != null) { *************** *** 399,406 **** min = Util.min(min, value); max = Util.max(max, value); - last = value; } FetchDataStats stats = new FetchDataStats(); ! stats.setLast(last); stats.setMax(max); stats.setMin(min); --- 402,409 ---- min = Util.min(min, value); max = Util.max(max, value); } FetchDataStats stats = new FetchDataStats(); ! stats.setFirst(values[1]); ! stats.setLast(values[values.length - 1]); stats.setMax(max); stats.setMin(min); Index: FetchDataStats.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/FetchDataStats.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FetchDataStats.java 18 Nov 2004 13:27:58 -0000 1.1 --- FetchDataStats.java 19 Nov 2004 13:43:52 -0000 1.2 *************** *** 32,36 **** public class FetchDataStats implements ConsolFuns { private long seconds; ! private double total, min, max, last; FetchDataStats() { --- 32,36 ---- public class FetchDataStats implements ConsolFuns { private long seconds; ! private double total, min, max, last, first; FetchDataStats() { *************** *** 58,61 **** --- 58,65 ---- } + void setFirst(double first) { + this.first = first; + } + /** * Returns TOTAL of the fetched data *************** *** 91,94 **** --- 95,106 ---- /** + * Returns FIRST of the fetched data + * @return FIRST of the fetched data + */ + public double getFirst() { + return first; + } + + /** * Returns AVERAGE of the fetched data * @return AVERAGE of the fetched data *************** *** 135,138 **** --- 147,151 ---- "MAX: " + Util.formatDouble(getMax(), true) + "\n" + "LAST: " + Util.formatDouble(getLast(), true) + "\n" + + "FIRST: " + Util.formatDouble(getFirst(), true) + "\n" + "TOTAL: " + Util.formatDouble(getTotal(), true); } |