From: Sasa M. <sa...@us...> - 2004-09-21 08:42:20
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv324/org/jrobin/core Modified Files: ArcDef.java Archive.java ConsolFuns.java Datasource.java DsDef.java DsTypes.java FetchData.java RrdDataSet.java RrdDb.java RrdDef.java Log Message: Strings like "AVERAGE" or "GAUGE" replaced with constants like ConsolFuns.AVERAGE and DsTypes.GAUGE. This change does not affect existing JRobin-based code (since constants are defined as Strings). Changes made in org.jrobin.core.* and org.jrobin.graph.* packages Index: FetchData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/FetchData.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FetchData.java 20 Sep 2004 15:10:18 -0000 1.9 --- FetchData.java 21 Sep 2004 08:42:09 -0000 1.10 *************** *** 276,281 **** * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are MIN, MAX, LAST and AVERAGE (these string constants ! * are conveniently defined in the {@link ConsolFuns} class). * @return MIN, MAX, LAST or AVERAGE value calculated from the fetched data * for the given datasource name --- 276,281 ---- * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are "MIN", "MAX", "LAST" and "AVERAGE" ! * (these string constants are conveniently defined in the {@link ConsolFuns} class). * @return MIN, MAX, LAST or AVERAGE value calculated from the fetched data * for the given datasource name *************** *** 289,293 **** * Returns aggregated value from the fetched data for a single datasource. * Before applying aggrregation functions, specified RPN expression is applied to fetched ! * data. For example, if you have a gauge datasource named 'foots' but you wont to * find the maximum fetched value in meters use something like:</p> * <code>getAggregate("foots", ConsolFuns.MAX, "value,0.3048,*");</code> --- 289,293 ---- * Returns aggregated value from the fetched data for a single datasource. * Before applying aggrregation functions, specified RPN expression is applied to fetched ! * data. For example, if you have a GAUGE datasource named 'foots' but you wont to * find the maximum fetched value in meters use something like:</p> * <code>getAggregate("foots", ConsolFuns.MAX, "value,0.3048,*");</code> *************** *** 296,301 **** * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are MIN, MAX, LAST and AVERAGE (these string constants ! * are conveniently defined in the {@link ConsolFuns} class) * @return MIN, MAX, LAST or AVERAGE value calculated from the fetched data * for the given datasource name --- 296,301 ---- * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are "MIN", "MAX", "LAST" and "AVERAGE" ! * (these string constants are conveniently defined in the {@link ConsolFuns} class) * @return MIN, MAX, LAST or AVERAGE value calculated from the fetched data * for the given datasource name *************** *** 304,317 **** public double getAggregate(String dsName, String consolFun, String rpnExpression) throws RrdException { ! if(consolFun.equals(MAX)) { return getMax(dsName, rpnExpression); } ! else if(consolFun.equals(MIN)) { return getMin(dsName, rpnExpression); } ! else if(consolFun.equals(LAST)) { return getLast(dsName, rpnExpression); } ! else if(consolFun.equals(AVERAGE)) { return getAverage(dsName, rpnExpression); } --- 304,317 ---- public double getAggregate(String dsName, String consolFun, String rpnExpression) throws RrdException { ! if(consolFun.equals(CF_MAX)) { return getMax(dsName, rpnExpression); } ! else if(consolFun.equals(CF_MIN)) { return getMin(dsName, rpnExpression); } ! else if(consolFun.equals(CF_LAST)) { return getLast(dsName, rpnExpression); } ! else if(consolFun.equals(CF_AVERAGE)) { return getAverage(dsName, rpnExpression); } Index: RrdDataSet.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDataSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdDataSet.java 20 Sep 2004 15:10:18 -0000 1.3 --- RrdDataSet.java 21 Sep 2004 08:42:09 -0000 1.4 *************** *** 128,133 **** * @param dsName Datasource name * @param consolFun Consolidation function to be applied to set datasource values datasource. ! * Valid consolidation functions are MIN, MAX, LAST and AVERAGE (these string constants ! * are conveniently defined in the {@link ConsolFuns} class) * @return MIN, MAX, LAST or AVERAGE value calculated from the dataset for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in the dataset. --- 128,133 ---- * @param dsName Datasource name * @param consolFun Consolidation function to be applied to set datasource values datasource. ! * Valid consolidation functions are "MIN", "MAX", "LAST" and "AVERAGE" ! * (these string constants are conveniently defined in the {@link ConsolFuns} class) * @return MIN, MAX, LAST or AVERAGE value calculated from the dataset for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in the dataset. Index: RrdDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDef.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** RrdDef.java 20 Sep 2004 15:10:18 -0000 1.16 --- RrdDef.java 21 Sep 2004 08:42:09 -0000 1.17 *************** *** 312,316 **** * <a href="../../../../man/rrdcreate.html" target="man">rrdcreate man page</a>.</p> * @param consolFun Consolidation function. Valid values are "AVERAGE", ! * "MIN", "MAX" and "LAST" (these constants are also defined in the * {@link ConsolFuns} class) * @param xff X-files factor. Valid values are between 0 and 1. --- 312,316 ---- * <a href="../../../../man/rrdcreate.html" target="man">rrdcreate man page</a>.</p> * @param consolFun Consolidation function. Valid values are "AVERAGE", ! * "MIN", "MAX" and "LAST" (these constants are conveniently defined in the * {@link ConsolFuns} class) * @param xff X-files factor. Valid values are between 0 and 1. Index: Datasource.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Datasource.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Datasource.java 20 Sep 2004 15:10:18 -0000 1.8 --- Datasource.java 21 Sep 2004 08:42:09 -0000 1.9 *************** *** 208,225 **** if(newTime - oldTime <= heartbeat.get()) { String type = dsType.get(); ! if(type.equals(GAUGE)) { updateValue = newValue; } ! else if(type.equals(ABSOLUTE)) { if(!Double.isNaN(newValue)) { updateValue = newValue / (newTime - oldTime); } } ! else if(type.equals(DERIVE)) { if(!Double.isNaN(newValue) && !Double.isNaN(oldValue)) { updateValue = (newValue - oldValue) / (newTime - oldTime); } } ! else if(type.equals(COUNTER)) { if(!Double.isNaN(newValue) && !Double.isNaN(oldValue)) { double diff = newValue - oldValue; --- 208,225 ---- if(newTime - oldTime <= heartbeat.get()) { String type = dsType.get(); ! if(type.equals(DT_GAUGE)) { updateValue = newValue; } ! else if(type.equals(DT_ABSOLUTE)) { if(!Double.isNaN(newValue)) { updateValue = newValue / (newTime - oldTime); } } ! else if(type.equals(DT_DERIVE)) { if(!Double.isNaN(newValue) && !Double.isNaN(oldValue)) { updateValue = (newValue - oldValue) / (newTime - oldTime); } } ! else if(type.equals(DT_COUNTER)) { if(!Double.isNaN(newValue) && !Double.isNaN(oldValue)) { double diff = newValue - oldValue; Index: ConsolFuns.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/ConsolFuns.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConsolFuns.java 20 Sep 2004 15:10:18 -0000 1.1 --- ConsolFuns.java 21 Sep 2004 08:42:09 -0000 1.2 *************** *** 30,42 **** public interface ConsolFuns { /** Constant to represent AVERAGE consolidation function */ ! public static final String AVERAGE = "AVERAGE"; /** Constant to represent MIN consolidation function */ ! public static final String MIN = "MIN"; /** Constant to represent MAX consolidation function */ ! public static final String MAX = "MAX"; /** Constant to represent LAST consolidation function */ ! public static final String LAST = "LAST"; } --- 30,48 ---- public interface ConsolFuns { /** Constant to represent AVERAGE consolidation function */ ! public static final String CF_AVERAGE = "AVERAGE"; /** Constant to represent MIN consolidation function */ ! public static final String CF_MIN = "MIN"; /** Constant to represent MAX consolidation function */ ! public static final String CF_MAX = "MAX"; /** Constant to represent LAST consolidation function */ ! public static final String CF_LAST = "LAST"; ! ! /** Constant to represent FIRST consolidation function */ ! public static final String CF_FIRST = "FIRST"; ! ! /** Constant to represent TOTAL consolidation function */ ! public static final String CF_TOTAL = "TOTAL"; } Index: DsTypes.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/DsTypes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DsTypes.java 20 Sep 2004 15:10:18 -0000 1.1 --- DsTypes.java 21 Sep 2004 08:42:09 -0000 1.2 *************** *** 30,42 **** public interface DsTypes { /** Constant to represent GAUGE datasource type */ ! public static final String GAUGE = "GAUGE"; /** Constant to represent COUNTER datasource type */ ! public static final String COUNTER = "COUNTER"; /** Constant to represent DERIVE datasource type */ ! public static final String DERIVE = "DERIVE"; /** Constant to represent ABSOLUTE datasource type */ ! public static final String ABSOLUTE = "ABSOLUTE"; } --- 30,42 ---- public interface DsTypes { /** Constant to represent GAUGE datasource type */ ! public static final String DT_GAUGE = "GAUGE"; /** Constant to represent COUNTER datasource type */ ! public static final String DT_COUNTER = "COUNTER"; /** Constant to represent DERIVE datasource type */ ! public static final String DT_DERIVE = "DERIVE"; /** Constant to represent ABSOLUTE datasource type */ ! public static final String DT_ABSOLUTE = "ABSOLUTE"; } Index: DsDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/DsDef.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DsDef.java 20 Sep 2004 15:10:18 -0000 1.8 --- DsDef.java 21 Sep 2004 08:42:09 -0000 1.9 *************** *** 44,48 **** public class DsDef implements DsTypes { /** array of valid source types */ ! public static final String[] DS_TYPES = { GAUGE, COUNTER, DERIVE, ABSOLUTE }; private String dsName, dsType; --- 44,48 ---- public class DsDef implements DsTypes { /** array of valid source types */ ! public static final String[] DS_TYPES = { DT_GAUGE, DT_COUNTER, DT_DERIVE, DT_ABSOLUTE }; private String dsName, dsType; Index: ArcDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/ArcDef.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ArcDef.java 20 Sep 2004 15:10:18 -0000 1.8 --- ArcDef.java 21 Sep 2004 08:42:09 -0000 1.9 *************** *** 45,49 **** public class ArcDef implements ConsolFuns { /** array of valid consolidation function names */ ! public static final String CONSOL_FUNS[] = { AVERAGE, MAX, MIN, LAST }; private String consolFun; --- 45,49 ---- public class ArcDef implements ConsolFuns { /** array of valid consolidation function names */ ! public static final String CONSOL_FUNS[] = { CF_AVERAGE, CF_MAX, CF_MIN, CF_LAST }; private String consolFun; Index: Archive.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Archive.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Archive.java 20 Sep 2004 15:10:18 -0000 1.17 --- Archive.java 21 Sep 2004 08:42:09 -0000 1.18 *************** *** 149,162 **** } else { ! if(consolFun.get().equals(MIN)) { state.setAccumValue(Util.min(state.getAccumValue(), value)); } ! else if(consolFun.get().equals(MAX)) { state.setAccumValue(Util.max(state.getAccumValue(), value)); } ! else if(consolFun.get().equals(LAST)) { state.setAccumValue(value); } ! else if(consolFun.get().equals(AVERAGE)) { state.setAccumValue(Util.sum(state.getAccumValue(), value)); } --- 149,162 ---- } else { ! if(consolFun.get().equals(CF_MIN)) { state.setAccumValue(Util.min(state.getAccumValue(), value)); } ! else if(consolFun.get().equals(CF_MAX)) { state.setAccumValue(Util.max(state.getAccumValue(), value)); } ! else if(consolFun.get().equals(CF_LAST)) { state.setAccumValue(value); } ! else if(consolFun.get().equals(CF_AVERAGE)) { state.setAccumValue(Util.sum(state.getAccumValue(), value)); } *************** *** 172,176 **** double accumValue = state.getAccumValue(); if(nanSteps <= arcXff * arcSteps && !Double.isNaN(accumValue)) { ! if(consolFun.get().equals(AVERAGE)) { accumValue /= (arcSteps - nanSteps); } --- 172,176 ---- double accumValue = state.getAccumValue(); if(nanSteps <= arcXff * arcSteps && !Double.isNaN(accumValue)) { ! if(consolFun.get().equals(CF_AVERAGE)) { accumValue /= (arcSteps - nanSteps); } Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** RrdDb.java 20 Sep 2004 15:10:18 -0000 1.29 --- RrdDb.java 21 Sep 2004 08:42:09 -0000 1.30 *************** *** 106,119 **** * // create new RRD definition * RrdDef def = new RrdDef("test.rrd", 300); ! * def.addDatasource("input", DsTypes.COUNTER, 600, 0, Double.NaN); ! * def.addDatasource("output", DsTypes.COUNTER, 600, 0, Double.NaN); ! * def.addArchive(ConsolFuns.AVERAGE, 0.5, 1, 600); ! * def.addArchive(ConsolFuns.AVERAGE, 0.5, 6, 700); ! * def.addArchive(ConsolFuns.AVERAGE, 0.5, 24, 797); ! * def.addArchive(ConsolFuns.AVERAGE, 0.5, 288, 775); ! * def.addArchive(ConsolFuns.MAX, 0.5, 1, 600); ! * def.addArchive(ConsolFuns.MAX, 0.5, 6, 700); ! * def.addArchive(ConsolFuns.MAX, 0.5, 24, 797); ! * def.addArchive(ConsolFuns.MAX, 0.5, 288, 775); * * // RRD definition is now completed, create the database! --- 106,119 ---- * // create new RRD definition * RrdDef def = new RrdDef("test.rrd", 300); ! * def.addDatasource("input", DsTypes.DT_COUNTER, 600, 0, Double.NaN); ! * def.addDatasource("output", DsTypes.DT_COUNTER, 600, 0, Double.NaN); ! * def.addArchive(ConsolFuns.CF_AVERAGE, 0.5, 1, 600); ! * def.addArchive(ConsolFuns.CF_AVERAGE, 0.5, 6, 700); ! * def.addArchive(ConsolFuns.CF_AVERAGE, 0.5, 24, 797); ! * def.addArchive(ConsolFuns.CF_AVERAGE, 0.5, 288, 775); ! * def.addArchive(ConsolFuns.CF_MAX, 0.5, 1, 600); ! * def.addArchive(ConsolFuns.CF_MAX, 0.5, 6, 700); ! * def.addArchive(ConsolFuns.CF_MAX, 0.5, 24, 797); ! * def.addArchive(ConsolFuns.CF_MAX, 0.5, 288, 775); * * // RRD definition is now completed, create the database! |