You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(11) |
Oct
(60) |
Nov
(68) |
Dec
(10) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(10) |
Feb
(15) |
Mar
(30) |
Apr
(20) |
May
(32) |
Jun
(30) |
Jul
(61) |
Aug
(13) |
Sep
(14) |
Oct
(13) |
Nov
(28) |
Dec
(10) |
2005 |
Jan
(7) |
Feb
(5) |
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(15) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(20) |
Aug
(35) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(14) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
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! |
From: Sasa M. <sa...@us...> - 2004-09-21 08:42:19
|
Update of /cvsroot/jrobin/src/org/jrobin/demo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv324/org/jrobin/demo Modified Files: ComplexDemo.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 |
From: Sasa M. <sa...@us...> - 2004-09-20 15:10:31
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23449/org/jrobin/core Modified Files: ArcDef.java Archive.java Datasource.java DsDef.java FetchData.java RrdDataSet.java RrdDb.java RrdDef.java Added Files: ConsolFuns.java DsTypes.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) Index: FetchData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/FetchData.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FetchData.java 12 Jul 2004 13:35:16 -0000 1.8 --- FetchData.java 20 Sep 2004 15:10:18 -0000 1.9 *************** *** 54,58 **** * the values returned with {@link #getTimestamps() getTimestamps()} method.<p> */ ! public class FetchData implements RrdDataSet { private FetchRequest request; private Archive matchingArchive; --- 54,58 ---- * the values returned with {@link #getTimestamps() getTimestamps()} method.<p> */ ! public class FetchData implements RrdDataSet, ConsolFuns { private FetchRequest request; private Archive matchingArchive; *************** *** 276,280 **** * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are MIN, MAX, LAST and AVERAGE * @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 *************** *** 290,299 **** * 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", "MAX", "value,0.3048,*");</code> * Note that 'value' in the RPN expression is a reserved word and stands for the * original value (value fetched from RRD)</p> * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. ! * Valid consolidation functions are MIN, MAX, LAST and AVERAGE * @return MIN, MAX, LAST or AVERAGE value calculated from the fetched data * for the given datasource name --- 291,301 ---- * 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> * Note that 'value' in the RPN expression is a reserved word and stands for the * original value (value fetched from RRD)</p> * @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 *************** *** 302,315 **** 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(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); } Index: RrdDataSet.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDataSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdDataSet.java 10 Jul 2004 00:06:29 -0000 1.2 --- RrdDataSet.java 20 Sep 2004 15:10:18 -0000 1.3 *************** *** 128,132 **** * @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 * @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.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RrdDef.java 18 Aug 2004 08:02:17 -0000 1.15 --- RrdDef.java 20 Sep 2004 15:10:18 -0000 1.16 *************** *** 197,201 **** * @param dsName Data source name. * @param dsType Data source type. Valid types are "COUNTER", ! * "GAUGE", "DERIVE" and "ABSOLUTE". * @param heartbeat Data source heartbeat. * @param minValue Minimal acceptable value. Use <code>Double.NaN</code> if unknown. --- 197,202 ---- * @param dsName Data source name. * @param dsType Data source type. Valid types are "COUNTER", ! * "GAUGE", "DERIVE" and "ABSOLUTE" (these string constants are conveniently defined in ! * the {@link DsTypes} class). * @param heartbeat Data source heartbeat. * @param minValue Minimal acceptable value. Use <code>Double.NaN</code> if unknown. *************** *** 311,315 **** * <a href="../../../../man/rrdcreate.html" target="man">rrdcreate man page</a>.</p> * @param consolFun Consolidation function. Valid values are "AVERAGE", ! * "MIN", "MAX" and "LAST" * @param xff X-files factor. Valid values are between 0 and 1. * @param steps Number of archive steps --- 312,317 ---- * <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. * @param steps Number of archive steps Index: Datasource.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Datasource.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Datasource.java 22 Jul 2004 09:34:10 -0000 1.7 --- Datasource.java 20 Sep 2004 15:10:18 -0000 1.8 *************** *** 39,43 **** */ ! public class Datasource implements RrdUpdater { private RrdDb parentDb; // definition --- 39,43 ---- */ ! public class Datasource implements RrdUpdater, DsTypes { private RrdDb parentDb; // definition *************** *** 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(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; --- NEW FILE: ConsolFuns.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.jrobin.org * Project Lead: Sasa Markovic (sa...@jr...); * * (C) Copyright 2003, by Sasa Markovic. * * Developers: Sasa Markovic (sa...@jr...) * Arne Vandamme (cob...@jr...) * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ package org.jrobin.core; /** * Simple interface to represent available consolidation functions */ 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"; } --- NEW FILE: DsTypes.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.jrobin.org * Project Lead: Sasa Markovic (sa...@jr...); * * (C) Copyright 2003, by Sasa Markovic. * * Developers: Sasa Markovic (sa...@jr...) * Arne Vandamme (cob...@jr...) * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ package org.jrobin.core; /** * Simple interface to represent available datasource types. */ 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"; } Index: DsDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/DsDef.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DsDef.java 19 Aug 2004 10:53:52 -0000 1.7 --- DsDef.java 20 Sep 2004 15:10:18 -0000 1.8 *************** *** 42,48 **** * @author <a href="mailto:sa...@jr...">Sasa Markovic</a> */ ! public class DsDef { /** array of valid source types */ ! public static final String[] DS_TYPES = { "GAUGE", "COUNTER", "DERIVE", "ABSOLUTE" }; private String dsName, dsType; --- 42,48 ---- * @author <a href="mailto:sa...@jr...">Sasa Markovic</a> */ ! public class DsDef implements DsTypes { /** array of valid source types */ ! public static final String[] DS_TYPES = { GAUGE, COUNTER, DERIVE, ABSOLUTE }; private String dsName, dsType; *************** *** 52,57 **** /** * <p>Creates new data source definition object. This object should be passed as argument ! * to {@link org.jrobin.core.RrdDef#addDatasource(org.jrobin.core.DsDef) addDatasource()} method of ! * {@link org.jrobin.core.RrdDb RrdDb} object.</p> * * <p>For the complete explanation of all source definition parameters, see RRDTool's --- 52,57 ---- /** * <p>Creates new data source definition object. This object should be passed as argument ! * to {@link org.jrobin.core.RrdDef#addDatasource(org.jrobin.core.DsDef) addDatasource()} ! * method of {@link org.jrobin.core.RrdDb RrdDb} object.</p> * * <p>For the complete explanation of all source definition parameters, see RRDTool's *************** *** 60,64 **** * @param dsName Data source name. * @param dsType Data source type. Valid values are "COUNTER", "GAUGE", "DERIVE" ! * and "ABSOLUTE" * @param heartbeat Hearbeat * @param minValue Minimal value. Use <code>Double.NaN</code> if unknown. --- 60,65 ---- * @param dsName Data source name. * @param dsType Data source type. Valid values are "COUNTER", "GAUGE", "DERIVE" ! * and "ABSOLUTE" (these string constants are conveniently defined in the ! * {@link DsTypes} class). * @param heartbeat Hearbeat * @param minValue Minimal value. Use <code>Double.NaN</code> if unknown. Index: ArcDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/ArcDef.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ArcDef.java 20 Jul 2004 08:21:01 -0000 1.7 --- ArcDef.java 20 Sep 2004 15:10:18 -0000 1.8 *************** *** 43,49 **** */ ! public class ArcDef { /** array of valid consolidation function names */ ! public static final String CONSOL_FUNS[] = { "AVERAGE", "MAX", "MIN", "LAST" }; private String consolFun; --- 43,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; *************** *** 60,64 **** * * @param consolFun Consolidation function. Allowed values are "AVERAGE", "MIN", ! * "MAX" and "LAST". * @param xff X-files factor, between 0 and 1. * @param steps Number of archive steps. --- 60,65 ---- * * @param consolFun Consolidation function. Allowed values are "AVERAGE", "MIN", ! * "MAX" and "LAST" (these string constants are conveniently defined in the ! * {@link ConsolFuns} class). * @param xff X-files factor, between 0 and 1. * @param steps Number of archive steps. Index: Archive.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Archive.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Archive.java 22 Jul 2004 09:34:10 -0000 1.16 --- Archive.java 20 Sep 2004 15:10:18 -0000 1.17 *************** *** 39,43 **** * @author <a href="mailto:sa...@jr...">Sasa Markovic</a> */ ! public class Archive implements RrdUpdater { private RrdDb parentDb; // definition --- 39,43 ---- * @author <a href="mailto:sa...@jr...">Sasa Markovic</a> */ ! public class Archive implements RrdUpdater, ConsolFuns { private RrdDb parentDb; // definition *************** *** 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(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)); } *************** *** 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(AVERAGE)) { accumValue /= (arcSteps - nanSteps); } *************** *** 185,189 **** /** ! * Returns archive consolidation function (AVERAGE, MIN, MAX or LAST). * @return Archive consolidation function. * @throws IOException Thrown in case of I/O error. --- 185,189 ---- /** ! * Returns archive consolidation function ("AVERAGE", "MIN", "MAX" or "LAST"). * @return Archive consolidation function. * @throws IOException Thrown in case of I/O error. Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** RrdDb.java 18 Aug 2004 12:49:46 -0000 1.28 --- RrdDb.java 20 Sep 2004 15:10:18 -0000 1.29 *************** *** 106,119 **** * // create new RRD definition * RrdDef def = new RrdDef("test.rrd", 300); ! * def.addDatasource("input", "COUNTER", 600, 0, Double.NaN); ! * def.addDatasource("output", "COUNTER", 600, 0, Double.NaN); ! * def.addArchive("AVERAGE", 0.5, 1, 600); ! * def.addArchive("AVERAGE", 0.5, 6, 700); ! * def.addArchive("AVERAGE", 0.5, 24, 797); ! * def.addArchive("AVERAGE", 0.5, 288, 775); ! * def.addArchive("MAX", 0.5, 1, 600); ! * def.addArchive("MAX", 0.5, 6, 700); ! * def.addArchive("MAX", 0.5, 24, 797); ! * def.addArchive("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.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! *************** *** 514,518 **** * method to actually fetch data from the RRD file.</p> * @param consolFun Consolidation function to be used in fetch request. Allowed values are ! * "AVERAGE", "MIN", "MAX" and "LAST". * @param fetchStart Starting timestamp for fetch request. * @param fetchEnd Ending timestamp for fetch request. --- 514,519 ---- * method to actually fetch data from the RRD file.</p> * @param consolFun Consolidation function to be used in fetch request. Allowed values are ! * "AVERAGE", "MIN", "MAX" and "LAST" (these constants are conveniently defined in the ! * {@link ConsolFuns} class). * @param fetchStart Starting timestamp for fetch request. * @param fetchEnd Ending timestamp for fetch request. *************** *** 538,542 **** * * @param consolFun Consolidation function to be used in fetch request. Allowed values are ! * "AVERAGE", "MIN", "MAX" and "LAST". * @param fetchStart Starting timestamp for fetch request. * @param fetchEnd Ending timestamp for fetch request. --- 539,544 ---- * * @param consolFun Consolidation function to be used in fetch request. Allowed values are ! * "AVERAGE", "MIN", "MAX" and "LAST" (these constants are conveniently defined in the ! * {@link ConsolFuns} class). * @param fetchStart Starting timestamp for fetch request. * @param fetchEnd Ending timestamp for fetch request. |
From: Sasa M. <sa...@us...> - 2004-09-18 12:10:44
|
Update of /cvsroot/jrobin/src/org/jrobin/inspector In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8709/org/jrobin/inspector Modified Files: GraphFrame.java Log Message: major improvements on RrdInspector archive plot frame Index: GraphFrame.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/GraphFrame.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GraphFrame.java 31 Aug 2004 14:23:10 -0000 1.1 --- GraphFrame.java 18 Sep 2004 12:10:29 -0000 1.2 *************** *** 31,37 **** import javax.swing.*; import java.awt.*; ! import java.awt.event.WindowAdapter; ! import java.awt.event.WindowEvent; import java.io.IOException; import java.io.File; --- 31,37 ---- import javax.swing.*; + import javax.swing.filechooser.FileFilter; import java.awt.*; ! import java.awt.event.*; import java.io.IOException; import java.io.File; *************** *** 40,50 **** class GraphFrame extends JFrame { private static final Color COLOR = Color.RED; ! private static final int WIDTH = 350, HEIGHT = 200; private GraphPanel graphPanel = new GraphPanel(); private RrdGraph rrdGraph; ! private String sourcePath, dsName, consolFun; ! private int dsIndex, arcIndex, arcSteps; private long t1, t2; --- 40,52 ---- class GraphFrame extends JFrame { private static final Color COLOR = Color.RED; ! private static final int WIDTH = 400, HEIGHT = 240; + private Color color = COLOR; private GraphPanel graphPanel = new GraphPanel(); + private JComboBox graphCombo = new JComboBox(); private RrdGraph rrdGraph; ! private String sourcePath, dsName; ! private int dsIndex, arcIndex; private long t1, t2; *************** *** 53,57 **** this.dsIndex = dsIndex; this.arcIndex = arcIndex; ! readRrdFile(); constructUI(); pack(); --- 55,60 ---- this.dsIndex = dsIndex; this.arcIndex = arcIndex; ! createRrdGraph(); ! fillGraphCombo(); constructUI(); pack(); *************** *** 60,64 **** } ! private void readRrdFile() { try { RrdDb rrdDb = new RrdDb(sourcePath, true); --- 63,67 ---- } ! private void createRrdGraph() { try { RrdDb rrdDb = new RrdDb(sourcePath, true); *************** *** 67,72 **** Robin robin = arc.getRobin(dsIndex); dsName = ds.getDsName(); - consolFun = arc.getConsolFun(); - arcSteps = arc.getSteps(); t1 = arc.getStartTime(); t2 = arc.getEndTime(); --- 70,73 ---- *************** *** 78,89 **** } double[] values = robin.getValues(); rrdDb.close(); ! RrdGraphDef def = new RrdGraphDef(t1, t2); ! // def.datasource(dsName, sourcePath, dsName, consolFun); LinearInterpolator linearInterpolator = new LinearInterpolator(timestamps, values); linearInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_RIGHT); ! def.datasource(dsName, linearInterpolator); ! def.area(dsName, COLOR, dsName + "@r"); ! rrdGraph = new RrdGraph(def); rrdGraph.specifyImageSize(true); } catch (IOException e) { --- 79,94 ---- } double[] values = robin.getValues(); + RrdDef rrdDef = rrdDb.getRrdDef(); rrdDb.close(); ! RrdGraphDef rrdGraphDef = new RrdGraphDef(t1, t2); ! rrdGraphDef.setTitle(rrdDef.getDsDefs()[dsIndex].dump() + " " + ! rrdDef.getArcDefs()[arcIndex].dump()); LinearInterpolator linearInterpolator = new LinearInterpolator(timestamps, values); linearInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_RIGHT); ! rrdGraphDef.datasource(dsName, linearInterpolator); ! rrdGraphDef.area(dsName, color, dsName + "@r"); ! rrdGraphDef.comment("START: " + new Date(t1 * 1000L) + "@r"); ! rrdGraphDef.comment("END: " + new Date(t2 * 1000L) + "@r"); ! rrdGraph = new RrdGraph(rrdGraphDef); rrdGraph.specifyImageSize(true); } catch (IOException e) { *************** *** 94,110 **** } private void constructUI() { JPanel content = (JPanel) getContentPane(); ! Box box = Box.createVerticalBox(); graphPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); ! box.add(graphPanel); ! box.add(Box.createVerticalStrut(3)); ! String s1 = "START: " + t1 + " (" + new Date(t1 * 1000L) + ")"; ! box.add(new JLabel(s1)); ! String s2 = "END : " + t2 + " (" + new Date(t2 * 1000L) + ")"; ! box.add(new JLabel(s2)); ! content.add(box); ! // finalize ! setTitle(new File(sourcePath).getName() + ":" + dsName + ":" + consolFun + ":" + arcSteps); setDefaultCloseOperation(DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { --- 99,156 ---- } + private void fillGraphCombo() { + try { + RrdDb rrdDb = new RrdDb(sourcePath, true); + RrdDef rrdDef = rrdDb.getRrdDef(); + final DsDef[] dsDefs = rrdDef.getDsDefs(); + final ArcDef[] arcDefs = rrdDef.getArcDefs(); + GraphComboItem[] items = new GraphComboItem[rrdDef.getDsCount() * rrdDef.getArcCount()]; + int selectedItem = -1; + for(int i = 0, k = 0; i < rrdDef.getDsCount(); i++) { + for(int j = 0; j < rrdDef.getArcCount(); k++, j++) { + String description = dsDefs[i].dump() + " " + arcDefs[j].dump(); + items[k] = new GraphComboItem(description, i, j); + if(i == dsIndex && j == arcIndex) { + selectedItem = k; + } + } + } + graphCombo.setModel(new DefaultComboBoxModel(items)); + graphCombo.setSelectedIndex(selectedItem); + } + catch (IOException e) { + Util.error(this, e); + } + catch (RrdException e) { + Util.error(this, e); + } + } + private void constructUI() { + setTitle(new File(sourcePath).getName()); JPanel content = (JPanel) getContentPane(); ! content.setLayout(new BorderLayout(3, 3)); ! content.add(graphCombo, BorderLayout.NORTH); graphPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); ! content.add(graphPanel, BorderLayout.CENTER); ! JPanel southPanel = new JPanel(); ! southPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); ! JButton colorButton = new JButton("Change graph color"); ! southPanel.add(colorButton); ! colorButton.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! changeColor(); ! } ! }); ! JButton saveButton = new JButton("Save graph"); ! saveButton.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! saveGraph(); ! } ! }); ! southPanel.add(Box.createHorizontalStrut(3)); ! southPanel.add(saveButton); ! content.add(southPanel, BorderLayout.SOUTH); ! // EVENT HANDLERS setDefaultCloseOperation(DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { *************** *** 113,116 **** --- 159,173 ---- } }); + graphCombo.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange() == ItemEvent.SELECTED) { + GraphComboItem item = (GraphComboItem) e.getItem(); + dsIndex = item.getDsIndex(); + arcIndex = item.getArcIndex(); + createRrdGraph(); + graphPanel.repaint(); + } + } + }); } *************** *** 119,122 **** --- 176,233 ---- } + private void changeColor() { + final JColorChooser picker = new JColorChooser(color); + ActionListener okListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + color = picker.getColor(); + createRrdGraph(); + graphPanel.repaint(); + } + }; + JColorChooser.createDialog(this, "Select color", true, picker, okListener, null).show(); + } + + private void saveGraph() { + JFileChooser chooser = new JFileChooser(); + FileFilter filter = new FileFilter() { + public boolean accept(File f) { + return f.isDirectory()? true: + f.getAbsolutePath().toLowerCase().endsWith(".png"); + } + public String getDescription() { + return "PNG images"; + } + }; + chooser.setFileFilter(filter); + int returnVal = chooser.showSaveDialog(this); + if(returnVal == JFileChooser.APPROVE_OPTION) { + try { + File selectedFile = chooser.getSelectedFile(); + String path = selectedFile.getAbsolutePath(); + if(!path.toLowerCase().endsWith(".png")) { + path += ".png"; + selectedFile = new File(path); + } + if(selectedFile.exists()) { + // ask user to overwrite + String message = "File [" + selectedFile.getName() + + "] already exists. Do you want to overwrite it?"; + int answer = JOptionPane.showConfirmDialog(this, + message, "File exists", JOptionPane.YES_NO_OPTION); + if(answer == JOptionPane.NO_OPTION) { + return; + } + } + rrdGraph.saveAsPNG(selectedFile.getAbsolutePath(), + graphPanel.getWidth(), graphPanel.getHeight()); + } catch (IOException e) { + Util.error(this, "Could not save graph to file:\n" + e); + } + catch (RrdException e) { + Util.error(this, "Could not save graph to file:\n" + e); + } + } + } + class GraphPanel extends JPanel { public void paintComponent(Graphics g) { *************** *** 130,132 **** --- 241,266 ---- } } + + class GraphComboItem { + private String description; + private int dsIndex, arcIndex; + + GraphComboItem(String description, int dsIndex, int arcIndex) { + this.description = description; + this.dsIndex = dsIndex; + this.arcIndex = arcIndex; + } + + public String toString() { + return description; + } + + int getDsIndex() { + return dsIndex; + } + + int getArcIndex() { + return arcIndex; + } + } } |
From: Sasa M. <sa...@us...> - 2004-09-02 14:23:23
|
Update of /cvsroot/jrobin/src/org/jrobin/demo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12163/org/jrobin/demo Modified Files: ComplexDemo.java Added Files: AppletDemo.java Log Message: AppletDemo added --- NEW FILE: AppletDemo.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.jrobin.org * Project Lead: Sasa Markovic (sa...@jr...); * * (C) Copyright 2003, by Sasa Markovic. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * Developers: Sasa Markovic (sa...@jr...) * Arne Vandamme (cob...@jr...) * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ package org.jrobin.demo; import org.jrobin.core.*; import org.jrobin.graph.RrdGraphDef; import org.jrobin.graph.RrdGraph; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class AppletDemo extends JApplet { public static final String RRD_PATH = "random"; static { try { RrdDb.setDefaultFactory("MEMORY"); } catch (Exception e) { e.printStackTrace(); } } private RrdGraphDef rrdGraphDef; private RrdDef rrdDef; private long startTime = Util.getTime(); private UpdaterThread updater; public void init() { // UI JPanel contentPane = (JPanel) getContentPane(); contentPane.add(new GraphPanel(), BorderLayout.CENTER); JButton restartButton = new JButton("Restart"); restartButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { restart(); } }); contentPane.add(restartButton, BorderLayout.SOUTH); // RRD try { rrdDef = new RrdDef(RRD_PATH, startTime - 1, 300); rrdDef.addDatasource("a", "GAUGE", 600, Double.NaN, Double.NaN); rrdDef.addArchive("AVERAGE", 0.5, 1, 300); rrdDef.addArchive("MIN", 0.5, 12, 300); rrdDef.addArchive("MAX", 0.5, 12, 300); rrdGraphDef = new RrdGraphDef(startTime, startTime + 86400); rrdGraphDef.setTitle("JRobin MIN/MAX demo"); rrdGraphDef.setLowerLimit(0); rrdGraphDef.datasource("a", RRD_PATH, "a", "AVERAGE"); rrdGraphDef.datasource("b", RRD_PATH, "a", "MIN"); rrdGraphDef.datasource("c", RRD_PATH, "a", "MAX"); rrdGraphDef.area("a", new Color(0, 0xb6, 0xe4), "real"); rrdGraphDef.line("b", new Color(0, 0x22, 0xe9), "min", 2); rrdGraphDef.line("c", new Color(0, 0xee, 0x22), "max", 2); } catch (Exception e) { e.printStackTrace(); } } private void restart() { updater.terminate(); start(); } public void start() { updater = new UpdaterThread(); updater.start(); } public void stop() { updater.terminate(); } class GraphPanel extends JPanel { protected void paintComponent(Graphics g) { try { RrdGraph graph = new RrdGraph(rrdGraphDef); graph.specifyImageSize(true); graph.renderImage((Graphics2D) g, getWidth(), getHeight()); } catch (Exception e) { e.printStackTrace(); } } } class UpdaterThread extends Thread { public static final int DELAY = 100; public static final int STEPS_PER_REPAINT = 5; private boolean shouldStop = false; private RrdDb rrdDb; public UpdaterThread() { try { this.rrdDb = new RrdDb(rrdDef); } catch (Exception e) { e.printStackTrace(); } } public void run() { try { int steps = 0; for(long t = startTime; t < startTime + 300 * 300 && !shouldStop; t += 300) { double value = Math.sin(t / 3000.0) * 50.0 + 50.0; rrdDb.createSample().setTime(t).setValue(0, value).update(); if(steps++ % STEPS_PER_REPAINT == 0) { repaint(); } Thread.sleep(DELAY); } repaint(); } catch (Exception e) { e.printStackTrace(); } } void terminate() { shouldStop = true; while(isAlive()) { try { Thread.sleep(DELAY); } catch (Exception e) { e.printStackTrace(); } } } } } Index: ComplexDemo.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/demo/ComplexDemo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ComplexDemo.java 9 Jun 2004 12:09:23 -0000 1.1 --- ComplexDemo.java 2 Sep 2004 14:23:14 -0000 1.2 *************** *** 1,4 **** - package org.jrobin.demo; - /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality --- 1,2 ---- *************** *** 26,29 **** --- 24,29 ---- */ + package org.jrobin.demo; + import java.awt.Color; import java.util.Date; |
From: Sasa M. <sa...@us...> - 2004-09-02 11:36:17
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16811/org/jrobin/core Modified Files: Util.java Log Message: minor changes Index: Util.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Util.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Util.java 22 Jul 2004 08:10:19 -0000 1.22 --- Util.java 2 Sep 2004 11:36:08 -0000 1.23 *************** *** 262,273 **** } - private static final File homeDirFile; - private static final String homeDirPath; - - static { - homeDirPath = getUserHomeDirectory() + JROBIN_DIR + getFileSeparator(); - homeDirFile = new File(homeDirPath); - } - /** * Returns path to directory used for placement of JRobin demo graphs and creates it --- 262,265 ---- *************** *** 277,280 **** --- 269,274 ---- */ public static String getJRobinDemoDirectory() { + String homeDirPath = getUserHomeDirectory() + JROBIN_DIR + getFileSeparator(); + File homeDirFile = new File(homeDirPath); return (homeDirFile.exists() || homeDirFile.mkdirs())? homeDirPath: null; } |
From: Sasa M. <sa...@us...> - 2004-09-01 08:00:03
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23147/org/jrobin/core Modified Files: RrdDbPool.java Log Message: Minor speed improvements (excessive debug info removed) Index: RrdDbPool.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDbPool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RrdDbPool.java 31 Aug 2004 15:08:47 -0000 1.12 --- RrdDbPool.java 1 Sep 2004 07:59:54 -0000 1.13 *************** *** 173,177 **** reportUsage(canonicalPath, rrdEntry); poolHitsCount++; ! debug("CACHED: " + rrdEntry.dump()); return rrdEntry.getRrdDb(); } --- 173,177 ---- reportUsage(canonicalPath, rrdEntry); poolHitsCount++; ! // debug("CACHED: " + rrdEntry.dump()); return rrdEntry.getRrdDb(); } *************** *** 181,185 **** rrdEntry = new RrdEntry(rrdDb); addRrdEntry(canonicalPath, rrdEntry); ! debug("ADDED: " + rrdEntry.dump()); return rrdDb; } --- 181,185 ---- rrdEntry = new RrdEntry(rrdDb); addRrdEntry(canonicalPath, rrdEntry); ! // debug("ADDED: " + rrdEntry.dump()); return rrdDb; } *************** *** 238,242 **** RrdEntry newRrdEntry = new RrdEntry(rrdDb); addRrdEntry(canonicalPath, newRrdEntry); ! debug("ADDED: " + newRrdEntry.dump()); return rrdDb; } --- 238,242 ---- RrdEntry newRrdEntry = new RrdEntry(rrdDb); addRrdEntry(canonicalPath, newRrdEntry); ! // debug("ADDED: " + newRrdEntry.dump()); return rrdDb; } *************** *** 302,306 **** } else { // open but released... safe to close it ! debug("WILL BE RECREATED: " + rrdEntry.dump()); removeRrdEntry(canonicalPath, rrdEntry); } --- 302,306 ---- } else { // open but released... safe to close it ! // debug("WILL BE RECREATED: " + rrdEntry.dump()); removeRrdEntry(canonicalPath, rrdEntry); } *************** *** 311,315 **** rrdMap.remove(canonicalPath); rrdIdleMap.remove(canonicalPath); ! debug("REMOVED: " + rrdEntry.dump()); } --- 311,315 ---- rrdMap.remove(canonicalPath); rrdIdleMap.remove(canonicalPath); ! // debug("REMOVED: " + rrdEntry.dump()); } *************** *** 336,340 **** RrdEntry rrdEntry = (RrdEntry) rrdMap.get(canonicalPath); reportRelease(canonicalPath, rrdEntry); ! debug("RELEASED: " + rrdEntry.dump()); } else { throw new RrdException("RRD file " + rrdDb.getPath() + " not in the pool"); --- 336,340 ---- RrdEntry rrdEntry = (RrdEntry) rrdMap.get(canonicalPath); reportRelease(canonicalPath, rrdEntry); ! // debug("RELEASED: " + rrdEntry.dump()); } else { throw new RrdException("RRD file " + rrdDb.getPath() + " not in the pool"); *************** *** 352,356 **** */ public void run() { ! debug("GC: started"); for (; ;) { synchronized (this) { --- 352,356 ---- */ public void run() { ! // debug("GC: started"); for (; ;) { synchronized (this) { *************** *** 359,363 **** String canonicalPath = (String) rrdIdleMap.keySet().iterator().next(); RrdEntry rrdEntry = (RrdEntry) rrdIdleMap.get(canonicalPath); ! debug("GC: closing " + rrdEntry.dump()); removeRrdEntry(canonicalPath, rrdEntry); } catch (IOException e) { --- 359,363 ---- String canonicalPath = (String) rrdIdleMap.keySet().iterator().next(); RrdEntry rrdEntry = (RrdEntry) rrdIdleMap.get(canonicalPath); ! // debug("GC: closing " + rrdEntry.dump()); removeRrdEntry(canonicalPath, rrdEntry); } catch (IOException e) { *************** *** 368,376 **** else { try { ! debug("GC: waiting: " + rrdMap.size() + " open, " + rrdIdleMap.size() + ! " released, " + "capacity = " + capacity + ", " + "hits = " + ! poolHitsCount + ", " + "requests = " + poolRequestsCount); wait(); ! debug("GC: running"); } catch (InterruptedException e) { e.printStackTrace(); --- 368,374 ---- else { try { ! // debug("GC: waiting"); wait(); ! // debug("GC: running"); } catch (InterruptedException e) { e.printStackTrace(); *************** *** 378,382 **** } } - // Thread.yield(); } } --- 376,379 ---- *************** *** 399,403 **** rrdMap.clear(); rrdIdleMap.clear(); ! debug("Nothing left in the pool"); } --- 396,400 ---- rrdMap.clear(); rrdIdleMap.clear(); ! // debug("Pool cleared"); } *************** *** 406,410 **** } ! private static void debug(String msg) { if (DEBUG) { System.out.println("POOL: " + msg); --- 403,407 ---- } ! static void debug(String msg) { if (DEBUG) { System.out.println("POOL: " + msg); *************** *** 483,487 **** public synchronized void setCapacity(int capacity) { this.capacity = capacity; ! debug("Capacity set to: " + capacity); } --- 480,484 ---- public synchronized void setCapacity(int capacity) { this.capacity = capacity; ! // debug("Capacity set to: " + capacity); } *************** *** 529,533 **** String dump() throws IOException { ! String canonicalPath = rrdDb.getCanonicalPath(); return canonicalPath + " [" + usageCount + "]"; } --- 526,530 ---- String dump() throws IOException { ! String canonicalPath = getCanonicalPath(rrdDb.getPath()); return canonicalPath + " [" + usageCount + "]"; } |
From: Sasa M. <sa...@us...> - 2004-08-31 14:23:20
|
Update of /cvsroot/jrobin/src/org/jrobin/inspector In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3979/org/jrobin/inspector Added Files: GraphFrame.java Log Message: Added RRDInspector graph frame to plot all data values from a single archive --- NEW FILE: GraphFrame.java --- /* ============================================================ * JRobin : Pure java implementation of RRDTool's functionality * ============================================================ * * Project Info: http://www.jrobin.org * Project Lead: Sasa Markovic (sa...@jr...); * * (C) Copyright 2003, by Sasa Markovic. * * Developers: Sasa Markovic (sa...@jr...) * Arne Vandamme (cob...@jr...) * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ package org.jrobin.inspector; import org.jrobin.core.*; import org.jrobin.graph.RrdGraphDef; import org.jrobin.graph.RrdGraph; import org.jrobin.graph.LinearInterpolator; import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.IOException; import java.io.File; import java.util.Date; class GraphFrame extends JFrame { private static final Color COLOR = Color.RED; private static final int WIDTH = 350, HEIGHT = 200; private GraphPanel graphPanel = new GraphPanel(); private RrdGraph rrdGraph; private String sourcePath, dsName, consolFun; private int dsIndex, arcIndex, arcSteps; private long t1, t2; GraphFrame(String sourcePath, int dsIndex, int arcIndex) { this.sourcePath = sourcePath; this.dsIndex = dsIndex; this.arcIndex = arcIndex; readRrdFile(); constructUI(); pack(); Util.placeWindow(this); setVisible(true); } private void readRrdFile() { try { RrdDb rrdDb = new RrdDb(sourcePath, true); Datasource ds = rrdDb.getDatasource(dsIndex); Archive arc = rrdDb.getArchive(arcIndex); Robin robin = arc.getRobin(dsIndex); dsName = ds.getDsName(); consolFun = arc.getConsolFun(); arcSteps = arc.getSteps(); t1 = arc.getStartTime(); t2 = arc.getEndTime(); long step = arc.getArcStep(); int count = robin.getSize(); long[] timestamps = new long[count]; for(int i = 0; i < count; i++) { timestamps[i] = t1 + i * step; } double[] values = robin.getValues(); rrdDb.close(); RrdGraphDef def = new RrdGraphDef(t1, t2); // def.datasource(dsName, sourcePath, dsName, consolFun); LinearInterpolator linearInterpolator = new LinearInterpolator(timestamps, values); linearInterpolator.setInterpolationMethod(LinearInterpolator.INTERPOLATE_RIGHT); def.datasource(dsName, linearInterpolator); def.area(dsName, COLOR, dsName + "@r"); rrdGraph = new RrdGraph(def); rrdGraph.specifyImageSize(true); } catch (IOException e) { Util.error(this, e); } catch (RrdException e) { Util.error(this, e); } } private void constructUI() { JPanel content = (JPanel) getContentPane(); Box box = Box.createVerticalBox(); graphPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); box.add(graphPanel); box.add(Box.createVerticalStrut(3)); String s1 = "START: " + t1 + " (" + new Date(t1 * 1000L) + ")"; box.add(new JLabel(s1)); String s2 = "END : " + t2 + " (" + new Date(t2 * 1000L) + ")"; box.add(new JLabel(s2)); content.add(box); // finalize setTitle(new File(sourcePath).getName() + ":" + dsName + ":" + consolFun + ":" + arcSteps); setDefaultCloseOperation(DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { closeWindow(); } }); } private void closeWindow() { Util.dismissWindow(this); } class GraphPanel extends JPanel { public void paintComponent(Graphics g) { try { rrdGraph.renderImage((Graphics2D) g, getWidth(), getHeight()); } catch (RrdException e) { Util.error(this, e); } catch (IOException e) { Util.error(this, e); } } } } |
From: Sasa M. <sa...@us...> - 2004-08-31 07:20:28
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26888/org/jrobin/core Modified Files: RrdDbPool.java Log Message: major improvements, should run considerably faster Index: RrdDbPool.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDbPool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RrdDbPool.java 21 Jul 2004 08:27:40 -0000 1.10 --- RrdDbPool.java 31 Aug 2004 07:20:17 -0000 1.11 *************** *** 30,34 **** /** * Class to represent the pool of open RRD files.<p> ! * * To open already existing RRD file with JRobin, you have to create a * {@link org.jrobin.core.RrdDb RrdDb} object by specifying RRD file path --- 30,34 ---- /** * Class to represent the pool of open RRD files.<p> ! * <p/> * To open already existing RRD file with JRobin, you have to create a * {@link org.jrobin.core.RrdDb RrdDb} object by specifying RRD file path *************** *** 36,40 **** * especially with large RRD files with many datasources and * several long archives.<p> ! * * In a multithreaded environment you might probably need a reference to the * same RRD file from two different threads (RRD file updates are performed in --- 36,40 ---- * especially with large RRD files with many datasources and * several long archives.<p> ! * <p/> * In a multithreaded environment you might probably need a reference to the * same RRD file from two different threads (RRD file updates are performed in *************** *** 42,65 **** * the RrdDb construction process more efficient it might be convenient to open all * RRD files in a centralized place. That's the purpose of RrdDbPool class.<p> ! * * How does it work? The typical usage scenario goes like this:<p> ! * * <pre> * // obtain instance to RrdDbPool object * RrdDbPool pool = RrdDbPool.getInstance(); ! * * // request a reference to RrdDb object * String path = "some_relative_or_absolute_path_to_any_RRD_file"; * RrdDb rrdDb = RrdDbPool.requestRrdDb(path); ! * * // reference obtained, do whatever you want with it... * ... * ... ! * * // once you don't need the reference, release it. * // DO NOT CALL rrdDb.close() - files no longer in use are eventually closed by the pool * pool.release(rrdDb); ! *</pre> ! * * It's that simple. When the reference is requested for * the first time, RrdDbPool will open the RRD file --- 42,65 ---- * the RrdDb construction process more efficient it might be convenient to open all * RRD files in a centralized place. That's the purpose of RrdDbPool class.<p> ! * <p/> * How does it work? The typical usage scenario goes like this:<p> ! * <p/> * <pre> * // obtain instance to RrdDbPool object * RrdDbPool pool = RrdDbPool.getInstance(); ! * <p/> * // request a reference to RrdDb object * String path = "some_relative_or_absolute_path_to_any_RRD_file"; * RrdDb rrdDb = RrdDbPool.requestRrdDb(path); ! * <p/> * // reference obtained, do whatever you want with it... * ... * ... ! * <p/> * // once you don't need the reference, release it. * // DO NOT CALL rrdDb.close() - files no longer in use are eventually closed by the pool * pool.release(rrdDb); ! * </pre> ! * <p/> * It's that simple. When the reference is requested for * the first time, RrdDbPool will open the RRD file *************** *** 68,77 **** * reference will be returned, and its usage count will be increased by one. When the * reference is released its usage count will be decremented by one.<p> ! * * When the reference count drops to zero, RrdDbPool will not close the underlying * RRD file immediatelly. Instead of it, it will be marked as 'eligible for closing'. * If someone request the same RRD file again (before it gets closed), the same * reference will be returned again.<p> ! * * RrdDbPool has a 'garbage collector' which runs in a separate * thread and gets activated only when the number of RRD files kept in the --- 68,77 ---- * reference will be returned, and its usage count will be increased by one. When the * reference is released its usage count will be decremented by one.<p> ! * <p/> * When the reference count drops to zero, RrdDbPool will not close the underlying * RRD file immediatelly. Instead of it, it will be marked as 'eligible for closing'. * If someone request the same RRD file again (before it gets closed), the same * reference will be returned again.<p> ! * <p/> * RrdDbPool has a 'garbage collector' which runs in a separate * thread and gets activated only when the number of RRD files kept in the *************** *** 81,99 **** * RrdDbPool object keeps track of the time when each RRD file * becomes eligible for closing so that the oldest RRD file gets closed first.<p> ! * * Initial RrdDbPool capacity is set to {@link #INITIAL_CAPACITY}. Use {@link #setCapacity(int)} method to * change it at any time.<p> ! * * <b>WARNING:</b>Never use close() method on the reference returned from the pool. * When the reference is no longer needed, return it to the pool with the * {@link #release(RrdDb) release()} method.<p> ! * * However, you are not forced to use RrdDbPool methods to obtain RrdDb references * to RRD files, 'ordinary' RrdDb constructors are still available. But RrdDbPool class * offers serious performance improvement especially in complex applications with many * threads and many simultaneously open RRD files.<p> ! * * The pool is thread-safe.<p> ! * * <b>WARNING:</b> The pool cannot be used to manipulate RrdDb objects * with {@link RrdBackend backends} different from default.<p> --- 81,99 ---- * RrdDbPool object keeps track of the time when each RRD file * becomes eligible for closing so that the oldest RRD file gets closed first.<p> ! * <p/> * Initial RrdDbPool capacity is set to {@link #INITIAL_CAPACITY}. Use {@link #setCapacity(int)} method to * change it at any time.<p> ! * <p/> * <b>WARNING:</b>Never use close() method on the reference returned from the pool. * When the reference is no longer needed, return it to the pool with the * {@link #release(RrdDb) release()} method.<p> ! * <p/> * However, you are not forced to use RrdDbPool methods to obtain RrdDb references * to RRD files, 'ordinary' RrdDb constructors are still available. But RrdDbPool class * offers serious performance improvement especially in complex applications with many * threads and many simultaneously open RRD files.<p> ! * <p/> * The pool is thread-safe.<p> ! * <p/> * <b>WARNING:</b> The pool cannot be used to manipulate RrdDb objects * with {@link RrdBackend backends} different from default.<p> *************** *** 107,120 **** * which still does not force garbage collector (the process which closes RRD files) to run. */ ! public static final int INITIAL_CAPACITY = 100; ! private int capacity = INITIAL_CAPACITY; ! private Map rrdMap = new HashMap(); ! private List rrdGcList = new LinkedList(); private RrdBackendFactory factory; ! private int poolHitsCount, poolRequestsCount; /** * Returns an instance to RrdDbPool object. Only one such object may exist in each JVM. * @return Instance to RrdDbPool object. */ --- 107,127 ---- * which still does not force garbage collector (the process which closes RRD files) to run. */ ! public static final int INITIAL_CAPACITY = 500; ! private int capacity = INITIAL_CAPACITY, maxUsedCapacity; ! /** ! * Constant to represent the priority of the background thread which closes excessive RRD files ! * which are no longer in use. ! */ ! public static final int GC_THREAD_PRIORITY = /** Thread.NORM_PRIORITY - */ 1; ! ! private HashMap rrdMap = new HashMap(INITIAL_CAPACITY); ! private LinkedHashMap rrdIdleMap = new LinkedHashMap(INITIAL_CAPACITY); private RrdBackendFactory factory; ! private int poolHitsCount = 0, poolRequestsCount = 0; /** * Returns an instance to RrdDbPool object. Only one such object may exist in each JVM. + * * @return Instance to RrdDbPool object. */ *************** *** 128,135 **** --- 135,144 ---- private RrdDbPool() { + // just to satisfy the singleton pattern } private void startGarbageCollector() { Thread gcThread = new Thread(this); + gcThread.setPriority(GC_THREAD_PRIORITY); gcThread.setDaemon(true); gcThread.start(); *************** *** 143,167 **** * @param path Relative or absolute path to a RRD file. * @return Reference to a RrdDb object (RRD file). ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized RrdDb requestRrdDb(String path) throws IOException, RrdException { ! String keypath = getCanonicalPath(path); ! RrdDb rrdDbRequested; ! if (rrdMap.containsKey(keypath)) { // already open ! RrdEntry rrdEntry = (RrdEntry) rrdMap.get(keypath); ! reportUsage(rrdEntry); ! debug("EXISTING: " + rrdEntry.dump()); ! rrdDbRequested = rrdEntry.getRrdDb(); poolHitsCount++; } else { // not found, open it RrdDb rrdDb = new RrdDb(path, getFactory()); ! addRrdEntry(keypath, rrdDb); ! rrdDbRequested = rrdDb; } ! poolRequestsCount++; ! return rrdDbRequested; } --- 152,175 ---- * @param path Relative or absolute path to a RRD file. * @return Reference to a RrdDb object (RRD file). ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized RrdDb requestRrdDb(String path) throws IOException, RrdException { ! poolRequestsCount++; ! String canonicalPath = getCanonicalPath(path); ! RrdEntry rrdEntry = (RrdEntry) rrdMap.get(canonicalPath); ! if (rrdEntry != null) { // already open ! reportUsage(canonicalPath, rrdEntry); ! debug("CACHED: " + rrdEntry.dump()); poolHitsCount++; } else { // not found, open it RrdDb rrdDb = new RrdDb(path, getFactory()); ! rrdEntry = new RrdEntry(rrdDb); ! addRrdEntry(canonicalPath, rrdEntry); ! debug("ADDED: " + rrdEntry.dump()); } ! return rrdEntry.getRrdDb(); } *************** *** 170,186 **** * relative or absolute path, and its contents will be provided from the specified * XML file (RRDTool comaptible). ! * @param path Relative or absolute path to a new RRD file. * @param xmlPath Relative or absolute path to an existing XML dump file (RRDTool comaptible) * @return Reference to a RrdDb object (RRD file). ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized RrdDb requestRrdDb(String path, String xmlPath) ! throws IOException, RrdException { ! String keypath = getCanonicalPath(path); ! prooveInactive(keypath); ! RrdDb rrdDb = new RrdDb(path, xmlPath, getFactory()); ! addRrdEntry(keypath, rrdDb); poolRequestsCount++; return rrdDb; } --- 178,197 ---- * relative or absolute path, and its contents will be provided from the specified * XML file (RRDTool comaptible). ! * ! * @param path Relative or absolute path to a new RRD file. * @param xmlPath Relative or absolute path to an existing XML dump file (RRDTool comaptible) * @return Reference to a RrdDb object (RRD file). ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized RrdDb requestRrdDb(String path, String xmlPath) ! throws IOException, RrdException { poolRequestsCount++; + String canonicalPath = getCanonicalPath(path); + prooveInactive(canonicalPath); + RrdDb rrdDb = new RrdDb(path, xmlPath, getFactory()); + RrdEntry rrdEntry = new RrdEntry(rrdDb); + addRrdEntry(canonicalPath, rrdEntry); + debug("ADDED: " + rrdEntry.dump()); return rrdDb; } *************** *** 189,251 **** * Returns a reference to a new RRD file. The new file will be created based on the * definition contained in a RrdDef object. * @param rrdDef RRD definition object * @return Reference to a RrdDb object (RRD file). ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized RrdDb requestRrdDb(RrdDef rrdDef) throws IOException, RrdException { - String path = rrdDef.getPath(); - String keypath = getCanonicalPath(path); - prooveInactive(keypath); - RrdDb rrdDb = new RrdDb(rrdDef, getFactory()); - addRrdEntry(keypath, rrdDb); poolRequestsCount++; return rrdDb; } ! private void reportUsage(RrdEntry rrdEntry) { ! if(rrdEntry.reportUsage() == 1) { // must not be garbage collected ! rrdGcList.remove(rrdEntry); } } ! private void reportRelease(RrdEntry rrdEntry) { ! if(rrdEntry.reportRelease() == 0) { // ready to be garbage collected ! rrdGcList.add(rrdEntry); } } ! private void addRrdEntry(String keypath, RrdDb rrdDb) throws IOException { ! RrdEntry newEntry = new RrdEntry(rrdDb); ! reportUsage(newEntry); ! debug("NEW: " + newEntry.dump()); ! rrdMap.put(keypath, newEntry); // notify garbage collector notify(); } ! private void prooveInactive(String keypath) throws RrdException, IOException { ! if(rrdMap.containsKey(keypath)) { // already open, check if active (not released) ! RrdEntry rrdEntry = (RrdEntry) rrdMap.get(keypath); ! if(rrdEntry.isInUse()) { // not released, not allowed here throw new RrdException("VALIDATOR: Cannot create new RrdDb file. " + ! "File " + keypath + " already active in pool"); ! } ! else { // open but released... safe to close it debug("WILL BE RECREATED: " + rrdEntry.dump()); ! removeRrdEntry(rrdEntry); } } } ! private void removeRrdEntry(RrdEntry rrdEntry) throws IOException { rrdEntry.closeRrdDb(); ! rrdMap.values().remove(rrdEntry); ! rrdGcList.remove(rrdEntry); debug("REMOVED: " + rrdEntry.dump()); } --- 200,261 ---- * Returns a reference to a new RRD file. The new file will be created based on the * definition contained in a RrdDef object. + * * @param rrdDef RRD definition object * @return Reference to a RrdDb object (RRD file). ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized RrdDb requestRrdDb(RrdDef rrdDef) throws IOException, RrdException { poolRequestsCount++; + String canonicalPath = getCanonicalPath(rrdDef.getPath()); + prooveInactive(canonicalPath); + RrdDb rrdDb = new RrdDb(rrdDef, getFactory()); + RrdEntry rrdEntry = new RrdEntry(rrdDb); + addRrdEntry(canonicalPath, rrdEntry); + debug("ADDED: " + rrdEntry.dump()); return rrdDb; } ! private void reportUsage(String canonicalPath, RrdEntry rrdEntry) { ! if (rrdEntry.reportUsage() == 1) { // must not be garbage collected ! rrdIdleMap.remove(canonicalPath); } } ! private void reportRelease(String canonicalPath, RrdEntry rrdEntry) { ! if (rrdEntry.reportRelease() == 0) { // ready to be garbage collected ! rrdIdleMap.put(canonicalPath, rrdEntry); } } ! private void addRrdEntry(String canonicalPath, RrdEntry newRrdEntry) { ! rrdMap.put(canonicalPath, newRrdEntry); ! maxUsedCapacity = Math.max(rrdMap.size(), maxUsedCapacity); // notify garbage collector notify(); } ! private void prooveInactive(String canonicalPath) throws RrdException, IOException { ! if (rrdMap.containsKey(canonicalPath)) { // already open, check if active (not released) ! RrdEntry rrdEntry = (RrdEntry) rrdMap.get(canonicalPath); ! if (rrdEntry.isInUse()) { // not released, not allowed here throw new RrdException("VALIDATOR: Cannot create new RrdDb file. " + ! "File " + canonicalPath + " already active in pool"); ! } else { // open but released... safe to close it debug("WILL BE RECREATED: " + rrdEntry.dump()); ! removeRrdEntry(canonicalPath, rrdEntry); } } } ! private void removeRrdEntry(String canonicalPath, RrdEntry rrdEntry) throws IOException { rrdEntry.closeRrdDb(); ! rrdMap.remove(canonicalPath); ! rrdIdleMap.remove(canonicalPath); debug("REMOVED: " + rrdEntry.dump()); } *************** *** 256,279 **** * closing'. It will be eventually closed by the pool when the number of open RRD files * becomes too big. Most recently released files will be closed last. * @param rrdDb Reference to RRD file that is no longer needed. ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized void release(RrdDb rrdDb) throws IOException, RrdException { ! if(rrdDb == null) { // we don't want NullPointerException return; } ! if(rrdDb.isClosed()) { ! throw new RrdException("Cannot release: already closed"); } ! String keypath = rrdDb.getCanonicalPath(); ! if(rrdMap.containsKey(keypath)) { ! RrdEntry rrdEntry = (RrdEntry) rrdMap.get(keypath); ! reportRelease(rrdEntry); debug("RELEASED: " + rrdEntry.dump()); ! } ! else { ! throw new RrdException("RRD file " + keypath + " not in the pool"); } // notify garbage collector --- 266,289 ---- * closing'. It will be eventually closed by the pool when the number of open RRD files * becomes too big. Most recently released files will be closed last. + * * @param rrdDb Reference to RRD file that is no longer needed. ! * @throws IOException Thrown in case of I/O error. * @throws RrdException Thrown in case of JRobin specific error. */ public synchronized void release(RrdDb rrdDb) throws IOException, RrdException { ! if (rrdDb == null) { // we don't want NullPointerException return; } ! if (rrdDb.isClosed()) { ! throw new RrdException("File " + rrdDb.getPath() + " already closed"); } ! String canonicalPath = getCanonicalPath(rrdDb.getPath()); ! if (rrdMap.containsKey(canonicalPath)) { ! RrdEntry rrdEntry = (RrdEntry) rrdMap.get(canonicalPath); ! reportRelease(canonicalPath, rrdEntry); debug("RELEASED: " + rrdEntry.dump()); ! } else { ! throw new RrdException("RRD file " + rrdDb.getPath() + " not in the pool"); } // notify garbage collector *************** *** 290,317 **** public void run() { debug("GC: started"); ! synchronized (this) { ! for (; ;) { ! while (rrdMap.size() > capacity && rrdGcList.size() > 0) { try { ! RrdEntry oldestRrdEntry = (RrdEntry) rrdGcList.get(0); ! debug("GC: closing " + oldestRrdEntry.dump()); ! removeRrdEntry(oldestRrdEntry); } catch (IOException e) { e.printStackTrace(); } } ! ! try { ! debug("GC: waiting: " + ! rrdMap.size() + " open, " + ! rrdGcList.size() + " released, " + ! "capacity = " + capacity + ", " + ! "hits = " + poolHitsCount + ", " + ! "requests = " + poolRequestsCount); ! wait(); ! debug("GC: running"); ! } catch (InterruptedException e) { } } } } --- 300,328 ---- public void run() { debug("GC: started"); ! for (; ;) { ! synchronized (this) { ! if (rrdMap.size() > capacity && rrdIdleMap.size() > 0) { try { ! String canonicalPath = (String) rrdIdleMap.keySet().iterator().next(); ! RrdEntry rrdEntry = (RrdEntry) rrdIdleMap.get(canonicalPath); ! debug("GC: closing " + rrdEntry.dump()); ! removeRrdEntry(canonicalPath, rrdEntry); } catch (IOException e) { e.printStackTrace(); } } ! else { ! try { ! debug("GC: waiting: " + rrdMap.size() + " open, " + rrdIdleMap.size() + ! " released, " + "capacity = " + capacity + ", " + "hits = " + ! poolHitsCount + ", " + "requests = " + poolRequestsCount); ! wait(); ! debug("GC: running"); ! } catch (InterruptedException e) { ! e.printStackTrace(); ! } } } + Thread.yield(); } } *************** *** 323,336 **** /** * Clears the internal state of the pool entirely. All open RRD files are closed. * @throws IOException Thrown in case of I/O related error. */ public synchronized void reset() throws IOException { Iterator it = rrdMap.values().iterator(); ! while(it.hasNext()) { ! RrdEntry rrdEntry = (RrdEntry) it.next(); rrdEntry.closeRrdDb(); } rrdMap.clear(); ! rrdGcList.clear(); debug("Nothing left in the pool"); } --- 334,348 ---- /** * Clears the internal state of the pool entirely. All open RRD files are closed. + * * @throws IOException Thrown in case of I/O related error. */ public synchronized void reset() throws IOException { Iterator it = rrdMap.values().iterator(); ! while (it.hasNext()) { ! RrdEntry rrdEntry = (RrdEntry) it.next(); rrdEntry.closeRrdDb(); } rrdMap.clear(); ! rrdIdleMap.clear(); debug("Nothing left in the pool"); } *************** *** 341,345 **** private static void debug(String msg) { ! if(DEBUG) { System.out.println("POOL: " + msg); } --- 353,357 ---- private static void debug(String msg) { ! if (DEBUG) { System.out.println("POOL: " + msg); } *************** *** 348,362 **** /** * Returns the internal state of the pool. Useful for debugging purposes. * @return Internal pool state (list of open RRD files, with the number of usages for ! * each one). * @throws IOException Thrown in case of I/O error. */ public synchronized String dump() throws IOException { StringBuffer buff = new StringBuffer(); Iterator it = rrdMap.values().iterator(); ! while(it.hasNext()) { ! RrdEntry rrdEntry = (RrdEntry) it.next(); ! buff.append(rrdEntry.dump()); ! buff.append("\n"); } return buff.toString(); --- 360,378 ---- /** * Returns the internal state of the pool. Useful for debugging purposes. + * * @return Internal pool state (list of open RRD files, with the number of usages for ! * each one). * @throws IOException Thrown in case of I/O error. */ public synchronized String dump() throws IOException { StringBuffer buff = new StringBuffer(); + buff.append("POOL DUMP: " + rrdMap.size() + " open, " + rrdIdleMap.size() + " released\n"); + buff.append("capacity=" + capacity + ", " + "maxUsedCapacity=" + maxUsedCapacity + "\n"); + buff.append("hits=" + poolHitsCount + ", " + "requests=" + poolRequestsCount + "\n"); + buff.append("efficiency=" + getPoolEfficency() + "\n-------\n"); Iterator it = rrdMap.values().iterator(); ! while (it.hasNext()) { ! RrdEntry rrdEntry = (RrdEntry) it.next(); ! buff.append(rrdEntry.dump() + "\n"); } return buff.toString(); *************** *** 364,367 **** --- 380,398 ---- /** + * Returns paths to all open files currently held in the pool. + * @return An array containing open file paths. + */ + public synchronized String[] getCachedFilePaths() { + Set keySet = rrdMap.keySet(); + int n = keySet.size(), i = 0; + String[] files = new String[n]; + Iterator it = keySet.iterator(); + while(it.hasNext()) { + files[i++] = (String) it.next(); + } + return files; + } + + /** * Returns maximum number of internally open RRD files * which still does not force garbage collector to run. *************** *** 385,391 **** private RrdBackendFactory getFactory() throws RrdException { ! if(factory == null) { factory = RrdBackendFactory.getDefaultFactory(); ! if(!(factory instanceof RrdFileBackendFactory)) { factory = null; throw new RrdException( --- 416,422 ---- private RrdBackendFactory getFactory() throws RrdException { ! if (factory == null) { factory = RrdBackendFactory.getDefaultFactory(); ! if (!(factory instanceof RrdFileBackendFactory)) { factory = null; throw new RrdException( *************** *** 398,402 **** private class RrdEntry { private RrdDb rrdDb; ! private int usageCount; public RrdEntry(RrdDb rrdDb) { --- 429,433 ---- private class RrdEntry { private RrdDb rrdDb; ! private int usageCount = 1; public RrdEntry(RrdDb rrdDb) { *************** *** 427,432 **** String dump() throws IOException { ! String keypath = rrdDb.getCanonicalPath(); ! return keypath + " [" + usageCount + "]"; } } --- 458,463 ---- String dump() throws IOException { ! String canonicalPath = rrdDb.getCanonicalPath(); ! return canonicalPath + " [" + usageCount + "]"; } } *************** *** 436,444 **** * RrdDb requests served from the internal pool of open RRD files * with the number of total RrdDb requests. * @return Pool's efficiency ratio as a double between 1 (best) and 0 (worst). If no RrdDb reference ! * was ever requested, 1 would be returned. */ public synchronized double getPoolEfficency() { ! if(poolRequestsCount == 0) { return 1.0; } --- 467,476 ---- * RrdDb requests served from the internal pool of open RRD files * with the number of total RrdDb requests. + * * @return Pool's efficiency ratio as a double between 1 (best) and 0 (worst). If no RrdDb reference ! * was ever requested, 1 would be returned. */ public synchronized double getPoolEfficency() { ! if (poolRequestsCount == 0) { return 1.0; } *************** *** 450,453 **** --- 482,486 ---- /** * Returns the number of RRD requests served from the internal pool of open RRD files + * * @return The number of pool "hits". */ *************** *** 458,461 **** --- 491,495 ---- /** * Returns the total number of RRD requests successfully served by this pool. + * * @return Total number of RRD requests */ *************** *** 463,466 **** --- 497,509 ---- return poolRequestsCount; } + + /** + * Returns the maximum number of open RRD files over the lifetime + * of the pool. + * @return maximum number of open RRD files. + */ + public synchronized int getMaxUsedCapacity() { + return maxUsedCapacity; + } } |
From: Sasa M. <sa...@us...> - 2004-08-30 11:10:32
|
Update of /cvsroot/jrobin/src/org/jrobin/mrtg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5603/org/jrobin/mrtg Modified Files: MrtgConstants.java Log Message: minor changes Index: MrtgConstants.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/mrtg/MrtgConstants.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MrtgConstants.java 21 Jul 2004 07:10:26 -0000 1.10 --- MrtgConstants.java 30 Aug 2004 11:10:23 -0000 1.11 *************** *** 26,29 **** --- 26,31 ---- package org.jrobin.mrtg; + import org.jrobin.core.RrdDbPool; + public interface MrtgConstants { // backend factory to be used *************** *** 46,50 **** // number of open RRD files held in the pool ! int POOL_CAPACITY = 100; // graph dimensions --- 48,53 ---- // number of open RRD files held in the pool ! int POOL_CAPACITY = RrdDbPool.INITIAL_CAPACITY; ! // int POOL_CAPACITY = 10; // graph dimensions |
From: Sasa M. <sa...@us...> - 2004-08-27 09:42:54
|
Update of /cvsroot/jrobin/src/org/jrobin/inspector In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24887/org/jrobin/inspector Modified Files: ArchiveTableModel.java DataTableModel.java DatasourceTableModel.java EditArchiveDialog.java EditDatasourceDialog.java HeaderTableModel.java MainTreeModel.java RrdInspector.java Util.java Log Message: Major RRDInspector changes: - archived values are editable - archived values can be plotted - multiple RRDs/plots can be open Index: EditDatasourceDialog.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/EditDatasourceDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EditDatasourceDialog.java 9 Dec 2003 12:22:04 -0000 1.1 --- EditDatasourceDialog.java 27 Aug 2004 09:42:43 -0000 1.2 *************** *** 198,202 **** catch(RrdException e) { // should not be hear ever! ! e.printStackTrace(); return null; } --- 198,202 ---- catch(RrdException e) { // should not be hear ever! ! Util.error(this, e); return null; } Index: Util.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/Util.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Util.java 9 Dec 2003 12:22:04 -0000 1.1 --- Util.java 27 Aug 2004 09:42:43 -0000 1.2 *************** *** 27,30 **** --- 27,31 ---- import javax.swing.*; import java.awt.*; + import java.util.Vector; class Util { *************** *** 41,43 **** --- 42,73 ---- JOptionPane.showMessageDialog(parent, message, "Error", JOptionPane.ERROR_MESSAGE); } + + static void error(Component parent, Exception e) { + e.printStackTrace(); + error(parent, e.toString()); + } + + private static Vector windows = new Vector(); + private static final int WINDOW_POSITION_SHIFT = 20; + + static void placeWindow(Window window) { + int count = windows.size(); + if(count == 0) { + centerOnScreen(window); + } + else { + Window last = (Window) windows.get(count - 1); + int x = last.getX() + WINDOW_POSITION_SHIFT; + int y = last.getY() + WINDOW_POSITION_SHIFT; + window.setLocation(x, y); + } + windows.add(window); + } + + static void dismissWindow(Window window) { + windows.remove(window); + if(windows.size() == 0) { + System.exit(0); + } + } } Index: DataTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/DataTableModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DataTableModel.java 18 Aug 2004 12:51:26 -0000 1.6 --- DataTableModel.java 27 Aug 2004 09:42:43 -0000 1.7 *************** *** 64,67 **** --- 64,94 ---- } + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex == 2; + } + + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + assert columnIndex == 2: "Column " + columnIndex + " is not editable!"; + double value; + try { + value = Double.parseDouble(aValue.toString()); + } + catch (NumberFormatException nfe) { + value = Double.NaN; + } + if(dsIndex >= 0 && arcIndex >= 0 && file != null) { + try { + RrdDb rrd = new RrdDb(file.getAbsolutePath()); + Robin robin = rrd.getArchive(arcIndex).getRobin(dsIndex); + robin.setValue(rowIndex, value); + values[rowIndex][2] = InspectorModel.formatDouble(robin.getValue(rowIndex)); + rrd.close(); + } + catch(Exception e) { + Util.error(null, e); + } + } + } + void setFile(File newFile) { file = newFile; *************** *** 94,101 **** } catch (IOException e) { ! e.printStackTrace(); } catch (RrdException e) { ! e.printStackTrace(); } } --- 121,128 ---- } catch (IOException e) { ! Util.error(null, e); } catch (RrdException e) { ! Util.error(null, e); } } Index: MainTreeModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/MainTreeModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MainTreeModel.java 18 Aug 2004 12:51:27 -0000 1.6 --- MainTreeModel.java 27 Aug 2004 09:42:43 -0000 1.7 *************** *** 66,71 **** --- 66,73 ---- } catch (IOException e) { setRoot(INVALID_NODE); + Util.error(null, e); } catch (RrdException e) { setRoot(INVALID_NODE); + Util.error(null, e); } return false; Index: EditArchiveDialog.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/EditArchiveDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EditArchiveDialog.java 9 Dec 2003 12:22:04 -0000 1.1 --- EditArchiveDialog.java 27 Aug 2004 09:42:43 -0000 1.2 *************** *** 190,194 **** catch(RrdException e) { // should not be hear ever! ! e.printStackTrace(); return null; } --- 190,194 ---- catch(RrdException e) { // should not be hear ever! ! Util.error(this, e); return null; } Index: DatasourceTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/DatasourceTableModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DatasourceTableModel.java 18 Aug 2004 12:51:26 -0000 1.6 --- DatasourceTableModel.java 27 Aug 2004 09:42:43 -0000 1.7 *************** *** 34,40 **** class DatasourceTableModel extends AbstractTableModel { ! private static final Object[] DESCRIPTIONS = {"name", "type", "heartbeat", "min value", ! "max value", "last value", "accum. value", "NaN seconds"}; ! private static final String[] COLUMN_NAMES = {"description", "value"}; private File file; --- 34,44 ---- class DatasourceTableModel extends AbstractTableModel { ! private static final Object[] DESCRIPTIONS = { ! "name", "type", "heartbeat", "min value", ! "max value", "last value", "accum. value", "NaN seconds" ! }; ! private static final String[] COLUMN_NAMES = { ! "description", "value" ! }; private File file; *************** *** 69,72 **** --- 73,80 ---- } + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + void setFile(File newFile) { file = newFile; *************** *** 95,102 **** } catch (IOException e) { ! e.printStackTrace(); } catch (RrdException e) { ! e.printStackTrace(); } } --- 103,110 ---- } catch (IOException e) { ! Util.error(null, e); } catch (RrdException e) { ! Util.error(null, e); } } Index: ArchiveTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/ArchiveTableModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ArchiveTableModel.java 18 Aug 2004 12:51:26 -0000 1.6 --- ArchiveTableModel.java 27 Aug 2004 09:42:42 -0000 1.7 *************** *** 98,105 **** } catch (IOException e) { ! e.printStackTrace(); } catch (RrdException e) { ! e.printStackTrace(); } } --- 98,105 ---- } catch (IOException e) { ! Util.error(null, e); } catch (RrdException e) { ! Util.error(null, e); } } Index: RrdInspector.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/RrdInspector.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RrdInspector.java 18 Aug 2004 12:51:27 -0000 1.7 --- RrdInspector.java 27 Aug 2004 09:42:43 -0000 1.8 *************** *** 29,32 **** --- 29,33 ---- import javax.swing.*; + import javax.swing.table.DefaultTableCellRenderer; import javax.swing.filechooser.FileFilter; import javax.swing.event.TreeSelectionListener; *************** *** 41,50 **** class RrdInspector extends JFrame { static final String TITLE = "RRD File Inspector"; static final boolean SHOULD_FIX_ARCHIVED_VALUES = false; ! static final boolean SHOULD_CREATE_BACKUPS = true; ! ! static Dimension MAIN_TREE_SIZE = new Dimension(250, 400); ! static Dimension INFO_PANE_SIZE = new Dimension(450, 400); JTabbedPane tabbedPane = new JTabbedPane(); --- 42,52 ---- class RrdInspector extends JFrame { + static final boolean SHOULD_CREATE_BACKUPS = true; static final String TITLE = "RRD File Inspector"; static final boolean SHOULD_FIX_ARCHIVED_VALUES = false; ! static final Dimension MAIN_TREE_SIZE = new Dimension(250, 400); ! static final Dimension INFO_PANE_SIZE = new Dimension(450, 400); ! static final String ABOUT = "JRobin project\nRrdInspector utility\n" + ! "Copyright (C) 2003-2004 Sasa Markovic, Arne Vandamme"; JTabbedPane tabbedPane = new JTabbedPane(); *************** *** 62,66 **** super(TITLE); constructUI(); ! showCentered(); if(path == null) { selectFile(); --- 64,70 ---- super(TITLE); constructUI(); ! pack(); ! Util.placeWindow(this); ! setVisible(true); if(path == null) { selectFile(); *************** *** 71,84 **** } - private void showCentered() { - pack(); - Toolkit t = Toolkit.getDefaultToolkit(); - Dimension screenSize = t.getScreenSize(), frameSize = getPreferredSize(); - double x = (screenSize.getWidth() - frameSize.getWidth()) / 2; - double y = (screenSize.getHeight() - frameSize.getHeight()) / 2; - setLocation((int) x, (int) y); - setVisible(true); - } - private void constructUI() { JPanel content = (JPanel) getContentPane(); --- 75,78 ---- *************** *** 134,137 **** --- 128,134 ---- dataTable.getColumnModel().getColumn(0).setMaxWidth(100); dataTable.getColumnModel().getColumn(1).setPreferredWidth(150); + dataTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { + { setBackground(Color.YELLOW); } + }); spData.setPreferredSize(INFO_PANE_SIZE); tabbedPane.add("Archive data", spData); *************** *** 143,149 **** //////////////////////////////////////// JMenuBar menuBar = new JMenuBar(); ! // FILE JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem fileMenuItem = new JMenuItem("Open RRD file...", KeyEvent.VK_O); fileMenuItem.addActionListener(new ActionListener() { --- 140,149 ---- //////////////////////////////////////// JMenuBar menuBar = new JMenuBar(); ! ! // FILE MENU JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); + + // Open file JMenuItem fileMenuItem = new JMenuItem("Open RRD file...", KeyEvent.VK_O); fileMenuItem.addActionListener(new ActionListener() { *************** *** 153,157 **** --- 153,168 ---- }); fileMenu.add(fileMenuItem); + + // Open file in new window + JMenuItem fileMenuItem2 = new JMenuItem("Open RRD file in new window..."); + fileMenuItem2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new RrdInspector(null); + } + }); + fileMenu.add(fileMenuItem2); fileMenu.addSeparator(); + + // Add datasource JMenuItem addDatasourceMenuItem = new JMenuItem("Add datasource..."); addDatasourceMenuItem.addActionListener(new ActionListener() { *************** *** 161,164 **** --- 172,177 ---- }); fileMenu.add(addDatasourceMenuItem); + + // Edit datasource JMenuItem editDatasourceMenuItem = new JMenuItem("Edit datasource..."); editDatasourceMenuItem.addActionListener(new ActionListener() { *************** *** 168,171 **** --- 181,186 ---- }); fileMenu.add(editDatasourceMenuItem); + + // Remove datasource JMenuItem removeDatasourceMenuItem = new JMenuItem("Remove datasource"); removeDatasourceMenuItem.addActionListener(new ActionListener() { *************** *** 176,179 **** --- 191,196 ---- fileMenu.add(removeDatasourceMenuItem); fileMenu.addSeparator(); + + // Add archive JMenuItem addArchiveMenuItem = new JMenuItem("Add archive..."); addArchiveMenuItem.addActionListener(new ActionListener() { *************** *** 183,186 **** --- 200,205 ---- }); fileMenu.add(addArchiveMenuItem); + + // Edit archive JMenuItem editArchiveMenuItem = new JMenuItem("Edit archive..."); editArchiveMenuItem.addActionListener(new ActionListener() { *************** *** 190,193 **** --- 209,214 ---- }); fileMenu.add(editArchiveMenuItem); + + // Remove archive JMenuItem removeArchiveMenuItem = new JMenuItem("Remove archive..."); removeArchiveMenuItem.addActionListener(new ActionListener() { *************** *** 197,201 **** --- 218,233 ---- }); fileMenu.add(removeArchiveMenuItem); + + // Plot archive values + JMenuItem plotArchiveMenuItem = new JMenuItem("Plot archive values..."); + plotArchiveMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + plotArchive(); + } + }); + fileMenu.add(plotArchiveMenuItem); fileMenu.addSeparator(); + + // Exit JMenuItem exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X); exitMenuItem.addActionListener(new ActionListener() { *************** *** 205,218 **** }); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); setJMenuBar(menuBar); // finalize UI addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { ! System.exit(0); } }); } --- 237,273 ---- }); fileMenu.add(exitMenuItem); + + // HELP MENU + JMenu helpMenu = new JMenu("Help"); + fileMenu.setMnemonic(KeyEvent.VK_H); + + // About + JMenuItem aboutMenuItem = new JMenuItem("About..."); + aboutMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + about(); + } + }); + helpMenu.add(aboutMenuItem); + menuBar.add(fileMenu); + menuBar.add(helpMenu); setJMenuBar(menuBar); // finalize UI + setDefaultCloseOperation(DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { ! closeWindow(); } }); + } + + private void closeWindow() { + Util.dismissWindow(this); + } + private void about() { + JOptionPane.showMessageDialog(this, ABOUT, "About", JOptionPane.INFORMATION_MESSAGE); } *************** *** 293,299 **** tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e.toString()); } catch (RrdException e) { ! Util.error(this, e.toString()); } } --- 348,354 ---- tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e); } catch (RrdException e) { ! Util.error(this, e); } } *************** *** 315,321 **** tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e.toString()); } catch (RrdException e) { ! Util.error(this, e.toString()); } } --- 370,376 ---- tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e); } catch (RrdException e) { ! Util.error(this, e); } } *************** *** 351,357 **** rrd.close(); } catch (IOException e) { ! Util.error(this, e.toString()); } catch (RrdException e) { ! Util.error(this, e.toString()); } } --- 406,412 ---- rrd.close(); } catch (IOException e) { ! Util.error(this, e); } catch (RrdException e) { ! Util.error(this, e); } } *************** *** 388,394 **** rrd.close(); } catch (IOException e) { ! Util.error(this, e.toString()); } catch (RrdException e) { ! Util.error(this, e.toString()); } } --- 443,449 ---- rrd.close(); } catch (IOException e) { ! Util.error(this, e); } catch (RrdException e) { ! Util.error(this, e); } } *************** *** 415,421 **** tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e.toString()); } catch (RrdException e) { ! Util.error(this, e.toString()); } } --- 470,476 ---- tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e); } catch (RrdException e) { ! Util.error(this, e); } } *************** *** 444,453 **** tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e.toString()); } catch (RrdException e) { ! Util.error(this, e.toString()); } } private static void printUsageAndExit() { System.err.println("usage: " + RrdInspector.class.getName() + " [<filename>]"); --- 499,524 ---- tabbedPane.setSelectedIndex(0); } catch (IOException e) { ! Util.error(this, e); } catch (RrdException e) { ! Util.error(this, e); } } + private void plotArchive() { + if (!inspectorModel.isOk()) { + Util.error(this, "Open a valid RRD file first."); + return; + } + RrdNode rrdNode = getSelectedRrdNode(); + int arcIndex = -1; + if(rrdNode == null || (arcIndex = rrdNode.getArcIndex()) < 0) { + Util.error(this, "Select archive first"); + return; + } + String sourcePath = inspectorModel.getFile().getAbsolutePath(); + int dsIndex = rrdNode.getDsIndex(); + new GraphFrame(sourcePath, dsIndex, arcIndex); + } + private static void printUsageAndExit() { System.err.println("usage: " + RrdInspector.class.getName() + " [<filename>]"); Index: HeaderTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/HeaderTableModel.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HeaderTableModel.java 18 Aug 2004 12:51:26 -0000 1.7 --- HeaderTableModel.java 27 Aug 2004 09:42:43 -0000 1.8 *************** *** 68,71 **** --- 68,73 ---- } + + void setFile(File newFile) { try { *************** *** 88,94 **** fireTableDataChanged(); } catch (IOException e) { ! e.printStackTrace(); } catch (RrdException e) { ! e.printStackTrace(); } } --- 90,96 ---- fireTableDataChanged(); } catch (IOException e) { ! Util.error(null, e); } catch (RrdException e) { ! Util.error(null, e); } } |
From: Sasa M. <sa...@us...> - 2004-08-27 09:42:52
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24887/org/jrobin/graph Modified Files: TimeGrid.java Log Message: Major RRDInspector changes: - archived values are editable - archived values can be plotted - multiple RRDs/plots can be open Index: TimeGrid.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/TimeGrid.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TimeGrid.java 21 Apr 2004 09:49:01 -0000 1.3 --- TimeGrid.java 27 Aug 2004 09:42:42 -0000 1.4 *************** *** 146,154 **** } else if ( days <= 157 ) { ! tAxis = new TimeAxisUnit( TimeAxisUnit.WEEK, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("ww"), true, firstDayOfWeek ); } ! else { tAxis = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MMM"), true, firstDayOfWeek ); } } } --- 146,160 ---- } else if ( days <= 157 ) { ! tAxis = new TimeAxisUnit( TimeAxisUnit.WEEK, 1, TimeAxisUnit.WEEK, 1, new SimpleDateFormat("'wk'ww"), true, firstDayOfWeek ); } ! else if ( days <= 370 ) { tAxis = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MMM"), true, firstDayOfWeek ); } + else if ( days <= 735 ) { + tAxis = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, TimeAxisUnit.MONTH, 1, new SimpleDateFormat("MM"), true, firstDayOfWeek ); + } + else { + tAxis = new TimeAxisUnit( TimeAxisUnit.MONTH, 1, TimeAxisUnit.YEAR, 1, new SimpleDateFormat("yyyy"), true, firstDayOfWeek ); + } } } |
From: Sasa M. <sa...@us...> - 2004-08-27 09:42:51
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24887/org/jrobin/core Modified Files: Robin.java RrdToolkit.java Log Message: Major RRDInspector changes: - archived values are editable - archived values can be plotted - multiple RRDs/plots can be open Index: Robin.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Robin.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Robin.java 18 Aug 2004 08:02:17 -0000 1.13 --- Robin.java 27 Aug 2004 09:42:42 -0000 1.14 *************** *** 147,150 **** --- 147,161 ---- } + /** + * Sets the i-th value in the Robin archive. + * @param index index in the archive (the oldest value has zero index) + * @param value value to be stored + * @throws IOException Thrown in case of I/O specific error. + */ + public void setValue(int index, double value) throws IOException { + int arrayIndex = (pointer.get() + index) % rows; + values.set(arrayIndex, value); + } + double[] getValues(int index, int count) throws IOException { assert count <= rows: "Too many values requested: " + count + " rows=" + rows; Index: RrdToolkit.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdToolkit.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RrdToolkit.java 13 Jul 2004 09:39:09 -0000 1.10 --- RrdToolkit.java 27 Aug 2004 09:42:42 -0000 1.11 *************** *** 294,297 **** --- 294,313 ---- /** + * Sets datasource heartbeat to a new value. + * @param sourcePath Path to exisiting RRD file (will be updated) + * @param dsIndex Index of the datasource in the specified RRD file + * @param newHeartbeat New datasource heartbeat + * @throws RrdException Thrown in case of JRobin specific error + * @throws IOException Thrown in case of I/O error + */ + public void setDsHeartbeat(String sourcePath, int dsIndex, long newHeartbeat) + throws RrdException, IOException { + RrdDb rrd = new RrdDb(sourcePath); + Datasource ds = rrd.getDatasource(dsIndex); + ds.setHeartbeat(newHeartbeat); + rrd.close(); + } + + /** * Sets datasource min value to a new value * @param sourcePath Path to exisiting RRD file (will be updated) |
From: Sasa M. <sa...@us...> - 2004-08-27 09:42:51
|
Update of /cvsroot/jrobin/src/org/jrobin/cmd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24887/org/jrobin/cmd Modified Files: Epoch.java Log Message: Major RRDInspector changes: - archived values are editable - archived values can be plotted - multiple RRDs/plots can be open Index: Epoch.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/cmd/Epoch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Epoch.java 20 Jul 2004 09:06:53 -0000 1.1 --- Epoch.java 27 Aug 2004 09:42:41 -0000 1.2 *************** *** 3,7 **** import org.jrobin.core.RrdException; import org.jrobin.core.Util; - // import org.jrobin.cmd.TimeParser; import javax.swing.*; --- 3,6 ---- |
From: Sasa M. <sa...@us...> - 2004-08-19 10:54:05
|
Update of /cvsroot/jrobin/src/org/jrobin/cmd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7066/org/jrobin/cmd Modified Files: TimeParser.java Log Message: Minor changes. DsDef throws an exception if too long datasource name is supplied. Index: TimeParser.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/cmd/TimeParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeParser.java 19 Jul 2004 15:00:03 -0000 1.2 --- TimeParser.java 19 Aug 2004 10:53:51 -0000 1.3 *************** *** 32,39 **** import org.jrobin.core.Util; - import java.io.BufferedReader; - import java.io.InputStreamReader; - import java.io.IOException; - /** * Class which parses at-style time specification (describided in detail on the rrdfetch man page), --- 32,35 ---- |
From: Sasa M. <sa...@us...> - 2004-08-19 10:54:05
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7066/org/jrobin/core Modified Files: DsDef.java Log Message: Minor changes. DsDef throws an exception if too long datasource name is supplied. Index: DsDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/DsDef.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DsDef.java 20 Jul 2004 08:21:02 -0000 1.6 --- DsDef.java 19 Aug 2004 10:53:52 -0000 1.7 *************** *** 117,122 **** private void validate() throws RrdException { ! if(dsName == null || dsName.length() == 0) { ! throw new RrdException("Invalid datasource name specified"); } if(!isValidDsType(dsType)) { --- 117,129 ---- private void validate() throws RrdException { ! if(dsName == null) { ! throw new RrdException("Null datasource name specified"); ! } ! if(dsName.length() == 0) { ! throw new RrdException("Datasource name length equal to zero"); ! } ! if(dsName.length() > RrdPrimitive.STRING_LENGTH) { ! throw new RrdException("Datasource name [" + dsName + "] to long (" + ! dsName.length() + " chars found, only " + RrdPrimitive.STRING_LENGTH + " allowed"); } if(!isValidDsType(dsType)) { |
Update of /cvsroot/jrobin/src/org/jrobin/inspector In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32526/org/jrobin/inspector Modified Files: ArchiveTableModel.java DataTableModel.java DatasourceTableModel.java HeaderTableModel.java MainTreeModel.java RrdInspector.java Log Message: Serious bug fixed (related to strange exceptions when a RRD file is about to be open). RRD file is now open in the read-only mode. Index: DataTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/DataTableModel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DataTableModel.java 4 Dec 2003 13:21:03 -0000 1.5 --- DataTableModel.java 18 Aug 2004 12:51:26 -0000 1.6 *************** *** 76,80 **** if(dsIndex >= 0 && arcIndex >= 0) { try { ! RrdDb rrd = new RrdDb(file.getAbsolutePath()); Archive arc = rrd.getArchive(arcIndex); Robin robin = arc.getRobin(dsIndex); --- 76,80 ---- if(dsIndex >= 0 && arcIndex >= 0) { try { ! RrdDb rrd = new RrdDb(file.getAbsolutePath(), true); Archive arc = rrd.getArchive(arcIndex); Robin robin = arc.getRobin(dsIndex); Index: MainTreeModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/MainTreeModel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MainTreeModel.java 4 Dec 2003 13:21:03 -0000 1.5 --- MainTreeModel.java 18 Aug 2004 12:51:27 -0000 1.6 *************** *** 47,51 **** try { file = newFile; ! RrdDb rrd = new RrdDb(file.getAbsolutePath()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RrdNode(rrd)); int dsCount = rrd.getRrdDef().getDsCount(); --- 47,51 ---- try { file = newFile; ! RrdDb rrd = new RrdDb(file.getAbsolutePath(), true); DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RrdNode(rrd)); int dsCount = rrd.getRrdDef().getDsCount(); Index: DatasourceTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/DatasourceTableModel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DatasourceTableModel.java 4 Dec 2003 13:21:03 -0000 1.5 --- DatasourceTableModel.java 18 Aug 2004 12:51:26 -0000 1.6 *************** *** 80,84 **** if(dsIndex >= 0) { try { ! RrdDb rrd = new RrdDb(file.getAbsolutePath()); Datasource ds = rrd.getDatasource(dsIndex); values = new Object[]{ --- 80,84 ---- if(dsIndex >= 0) { try { ! RrdDb rrd = new RrdDb(file.getAbsolutePath(), true); Datasource ds = rrd.getDatasource(dsIndex); values = new Object[]{ Index: HeaderTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/HeaderTableModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** HeaderTableModel.java 20 May 2004 10:29:33 -0000 1.6 --- HeaderTableModel.java 18 Aug 2004 12:51:26 -0000 1.7 *************** *** 73,77 **** values = null; String path = file.getAbsolutePath(); ! RrdDb rrd = new RrdDb(path); Header header = rrd.getHeader(); String signature = header.getSignature(); --- 73,77 ---- values = null; String path = file.getAbsolutePath(); ! RrdDb rrd = new RrdDb(path, true); Header header = rrd.getHeader(); String signature = header.getSignature(); Index: RrdInspector.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/RrdInspector.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RrdInspector.java 13 Jul 2004 10:40:34 -0000 1.6 --- RrdInspector.java 18 Aug 2004 12:51:27 -0000 1.7 *************** *** 250,260 **** JFileChooser chooser = new JFileChooser(lastDirectory); FileFilter filter = new FileFilter() { ! public boolean accept(File f) { ! return f.isDirectory() ? true : ! f.getAbsolutePath().toLowerCase().endsWith(".rrd"); } - public String getDescription() { ! return "JRobin RRD files"; } }; --- 250,260 ---- JFileChooser chooser = new JFileChooser(lastDirectory); FileFilter filter = new FileFilter() { ! public boolean accept(File file) { ! String path = file.getAbsolutePath().toLowerCase(); ! return file.isDirectory() || path.endsWith(".rrd") || ! path.endsWith(".jrb") || path.endsWith(".jrobin"); } public String getDescription() { ! return "JRobin RRD files (*.rrd;*.jrb;*.jrobin)"; } }; *************** *** 263,270 **** if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); ! lastDirectory = file.getParent(); ! //inspectorModel.setFile(file); ! //tabbedPane.setSelectedIndex(0); ! loadFile(file); } } --- 263,272 ---- if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); ! if(file != null) { ! lastDirectory = file.getParent(); ! //inspectorModel.setFile(file); ! //tabbedPane.setSelectedIndex(0); ! loadFile(file); ! } } } *************** *** 333,337 **** try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath); DsDef dsDef = rrd.getRrdDef().getDsDefs()[dsIndex]; rrd.close(); --- 335,339 ---- try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath, true); DsDef dsDef = rrd.getRrdDef().getDsDefs()[dsIndex]; rrd.close(); *************** *** 368,372 **** try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath); ArcDef arcDef = rrd.getRrdDef().getArcDefs()[arcIndex]; rrd.close(); --- 370,374 ---- try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath, true); ArcDef arcDef = rrd.getRrdDef().getArcDefs()[arcIndex]; rrd.close(); *************** *** 405,409 **** try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath); String dsName = rrd.getRrdDef().getDsDefs()[dsIndex].getDsName(); rrd.close(); --- 407,411 ---- try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath, true); String dsName = rrd.getRrdDef().getDsDefs()[dsIndex].getDsName(); rrd.close(); *************** *** 432,436 **** try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath); ArcDef arcDef = rrd.getRrdDef().getArcDefs()[arcIndex]; String consolFun = arcDef.getConsolFun(); --- 434,438 ---- try { String sourcePath = inspectorModel.getFile().getCanonicalPath(); ! RrdDb rrd = new RrdDb(sourcePath, true); ArcDef arcDef = rrd.getRrdDef().getArcDefs()[arcIndex]; String consolFun = arcDef.getConsolFun(); Index: ArchiveTableModel.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/inspector/ArchiveTableModel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ArchiveTableModel.java 4 Dec 2003 13:21:03 -0000 1.5 --- ArchiveTableModel.java 18 Aug 2004 12:51:26 -0000 1.6 *************** *** 82,86 **** if(dsIndex >= 0 && arcIndex >= 0) { try { ! RrdDb rrd = new RrdDb(file.getAbsolutePath()); Archive arc = rrd.getArchive(arcIndex); ArcState state = arc.getArcState(dsIndex); --- 82,86 ---- if(dsIndex >= 0 && arcIndex >= 0) { try { ! RrdDb rrd = new RrdDb(file.getAbsolutePath(), true); Archive arc = rrd.getArchive(arcIndex); ArcState state = arc.getArcState(dsIndex); |
From: Sasa M. <sa...@us...> - 2004-08-18 12:49:55
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32154/org/jrobin/core Modified Files: RrdDb.java RrdFileBackend.java Log Message: Minor improvements. No RRD file will be partially created if the supplied XML or RRDTool source is invalid. Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** RrdDb.java 25 Jul 2004 12:28:14 -0000 1.27 --- RrdDb.java 18 Aug 2004 12:49:46 -0000 1.28 *************** *** 73,76 **** --- 73,80 ---- /** See {@link #getLockMode() getLockMode()} for explanation */ public static final int EXCEPTION_IF_LOCKED = 2; + /** prefix to identify external XML file source used in various RrdDb constructors */ + public static final String PREFIX_XML = "xml:/"; + /** prefix to identify external RRDTool file source used in various RrdDb constructors */ + public static final String PREFIX_RRDTool = "rrdtool:/"; // static final String RRDTOOL = "rrdtool"; *************** *** 266,301 **** /** ! * <p>Constructor used to create new RRD from XML dump. Newly created RRD will be backed ! * with a default storage (backend) type (file on the disk). JRobin and RRDTool ! * use the same format for XML dump and this constructor should be used to ! * (re)create JRobin RRD from XML. In other words, it is possible to convert ! * RRDTool RRD files to JRobin RRD files: first, dump the content of RRDTool * RRD file (use command line):</p> * ! * <code>rrdtool dump original.rrd > original.xml</code> * ! * <p>Than, use file <code>original.xml</code> to create JRobin RRD file * <code>copy.rrd</code>:</p> * ! * <code>RrdDb rrd = new RrdDb("copy.rrd", "original.xml");</code> * * <p>See documentation for {@link #dumpXml(java.lang.String) dumpXml()} method ! * how to convert JRobin files to RRDTool format.</p> * ! * @param rrdPath Path to RRD file which will be created ! * @param xmlPath Path to file containing XML dump of RRDTool's or JRobin's RRD file * @throws IOException Thrown in case of I/O error * @throws RrdException Thrown in case of JRobin specific error */ ! public RrdDb(String rrdPath, String xmlPath) throws IOException, RrdException { ! this(rrdPath, xmlPath, RrdBackendFactory.getDefaultFactory()); } /** ! * <p>Constructor used to create new RRD from XML dump but with a storage (backend) type ! * different from default.</p> * * @param rrdPath Path to RRD which will be created ! * @param xmlPath Path to file containing XML dump of RRDTool's or JRobin's RRD file * @param factory Backend factory which will be used to create storage (backend) for this RRD. * @throws IOException Thrown in case of I/O error --- 270,378 ---- /** ! * <p>Constructor used to create RRD files from external file sources. ! * Supported external file sources are:</p> ! * ! * <ul> ! * <li>RRDTool/JRobin XML file dumps (i.e files created with <code>rrdtool dump</code> command). ! * <li>RRDTool binary files. ! * </ul> ! * ! * <p>Newly created RRD will be backed with a default storage (backend) type ! * (file on the disk).</p> ! * ! * <p>JRobin and RRDTool use the same format for XML dump and this constructor should be used to ! * (re)create JRobin RRD files from XML dumps. First, dump the content of a RRDTool * RRD file (use command line):</p> * ! * <pre> ! * rrdtool dump original.rrd > original.xml ! * </pre> * ! * <p>Than, use the file <code>original.xml</code> to create JRobin RRD file named * <code>copy.rrd</code>:</p> * ! * <pre> ! * RrdDb rrd = new RrdDb("copy.rrd", "original.xml"); ! * </pre> ! * ! * <p>or:</p> ! * ! * <pre> ! * RrdDb rrd = new RrdDb("copy.rrd", "xml:/original.xml"); ! * </pre> * * <p>See documentation for {@link #dumpXml(java.lang.String) dumpXml()} method ! * to see how to convert JRobin files to RRDTool's format.</p> * ! * <p>To read RRDTool files directly, specify <code>rrdtool:/</code> prefix in the ! * <code>externalPath</code> argument. For example, to create JRobin compatible file named ! * <code>copy.rrd</code> from the file <code>original.rrd</code> created with RRDTool, use ! * the following code:</p> ! * ! * <pre> ! * RrdDb rrd = new RrdDb("copy.rrd", "rrdtool:/original.rrd"); ! * </pre> ! * ! * <p>Note that the prefix <code>xml:/</code> or <code>rrdtool:/</code> is necessary to distinguish ! * between XML and RRDTool's binary sources. If no prefix is supplied, XML format is assumed</p> ! * ! * @param rrdPath Path to a RRD file which will be created ! * @param externalPath Path to an external file which should be imported, with an optional ! * <code>xml:/</code> or <code>rrdtool:/</code> prefix. * @throws IOException Thrown in case of I/O error * @throws RrdException Thrown in case of JRobin specific error */ ! public RrdDb(String rrdPath, String externalPath) throws IOException, RrdException { ! this(rrdPath, externalPath, RrdBackendFactory.getDefaultFactory()); } /** ! * <p>Constructor used to create RRD files from external file sources with a backend type ! * different from default. Supported external file sources are:</p> ! * ! * <ul> ! * <li>RRDTool/JRobin XML file dumps (i.e files created with <code>rrdtool dump</code> command). ! * <li>RRDTool binary files. ! * </ul> ! * ! * <p>JRobin and RRDTool use the same format for XML dump and this constructor should be used to ! * (re)create JRobin RRD files from XML dumps. First, dump the content of a RRDTool ! * RRD file (use command line):</p> ! * ! * <pre> ! * rrdtool dump original.rrd > original.xml ! * </pre> ! * ! * <p>Than, use the file <code>original.xml</code> to create JRobin RRD file named ! * <code>copy.rrd</code>:</p> ! * ! * <pre> ! * RrdDb rrd = new RrdDb("copy.rrd", "original.xml"); ! * </pre> ! * ! * <p>or:</p> ! * ! * <pre> ! * RrdDb rrd = new RrdDb("copy.rrd", "xml:/original.xml"); ! * </pre> ! * ! * <p>See documentation for {@link #dumpXml(java.lang.String) dumpXml()} method ! * to see how to convert JRobin files to RRDTool's format.</p> ! * ! * <p>To read RRDTool files directly, specify <code>rrdtool:/</code> prefix in the ! * <code>externalPath</code> argument. For example, to create JRobin compatible file named ! * <code>copy.rrd</code> from the file <code>original.rrd</code> created with RRDTool, use ! * the following code:</p> ! * ! * <pre> ! * RrdDb rrd = new RrdDb("copy.rrd", "rrdtool:/original.rrd"); ! * </pre> ! * ! * <p>Note that the prefix <code>xml:/</code> or <code>rrdtool:/</code> is necessary to distinguish ! * between XML and RRDTool's binary sources. If no prefix is supplied, XML format is assumed</p> * * @param rrdPath Path to RRD which will be created ! * @param externalPath Path to an external file which should be imported, with an optional ! * <code>xml:/</code> or <code>rrdtool:/</code> prefix. * @param factory Backend factory which will be used to create storage (backend) for this RRD. * @throws IOException Thrown in case of I/O error *************** *** 303,321 **** * @see RrdBackendFactory */ ! public RrdDb(String rrdPath, String xmlPath, RrdBackendFactory factory) throws IOException, RrdException { - backend = factory.open(rrdPath, false, lockMode); DataImporter reader; ! if(xmlPath.startsWith("rrdtool:/")) { ! String rrdToolPath = xmlPath.substring("rrdtool:/".length()); reader = new RrdToolReader(rrdToolPath); } ! else if(xmlPath.startsWith("xml:/")) { ! xmlPath = xmlPath.substring("xml:/".length()); ! reader = new XmlReader(xmlPath); } else { ! reader = new XmlReader(xmlPath); } backend.setLength(reader.getEstimatedSize()); // create header --- 380,398 ---- * @see RrdBackendFactory */ ! public RrdDb(String rrdPath, String externalPath, RrdBackendFactory factory) throws IOException, RrdException { DataImporter reader; ! if(externalPath.startsWith(PREFIX_RRDTool)) { ! String rrdToolPath = externalPath.substring(PREFIX_RRDTool.length()); reader = new RrdToolReader(rrdToolPath); } ! else if(externalPath.startsWith(PREFIX_XML)) { ! externalPath = externalPath.substring(PREFIX_XML.length()); ! reader = new XmlReader(externalPath); } else { ! reader = new XmlReader(externalPath); } + backend = factory.open(rrdPath, false, lockMode); backend.setLength(reader.getEstimatedSize()); // create header Index: RrdFileBackend.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdFileBackend.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RrdFileBackend.java 12 Jul 2004 13:35:16 -0000 1.7 --- RrdFileBackend.java 18 Aug 2004 12:49:46 -0000 1.8 *************** *** 53,58 **** channel = file.getChannel(); if(!readOnly) { - lockFile(lockMode); // We'll try to lock the file only in "rw" mode registerWriter(path); } --- 53,58 ---- channel = file.getChannel(); if(!readOnly) { // We'll try to lock the file only in "rw" mode + lockFile(lockMode); registerWriter(path); } |
From: Sasa M. <sa...@us...> - 2004-08-18 12:48:52
|
Update of /cvsroot/jrobin/src/org/jrobin/convertor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31899/org/jrobin/convertor Modified Files: Convertor.java Log Message: Greatly improved importer utility. Now it reads RRDTool binary files directly. Index: Convertor.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/convertor/Convertor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Convertor.java 19 Feb 2004 10:46:08 -0000 1.2 --- Convertor.java 18 Aug 2004 12:48:39 -0000 1.3 *************** *** 1,129 **** package org.jrobin.convertor; import org.jrobin.core.RrdDb; - import org.jrobin.core.RrdException; - import java.io.*; class Convertor { ! static final String SUFFIX = ".jrb"; ! static final String SEPARATOR = System.getProperty("file.separator"); ! static final Runtime RUNTIME = Runtime.getRuntime(); ! ! private String rrdtoolBinary; ! private String workingDirectory; ! private String suffix; ! private int okCount, badCount; ! private Convertor(String rrdtoolBinary, String workingDirectory, String suffix) { ! this.rrdtoolBinary = rrdtoolBinary; ! this.workingDirectory = workingDirectory; ! this.suffix = suffix; } ! private void convert() { ! println("Converting RRDTool files to JRobin native format"); ! println("Converted files will be placed in the same directory, with " + ! suffix + " suffix appended"); ! println("=========================================="); ! long start = System.currentTimeMillis(); ! if(!workingDirectory.endsWith(SEPARATOR)) { ! workingDirectory += SEPARATOR; ! } ! File parent = new File(workingDirectory); ! if(parent.isDirectory() && parent.exists()) { ! // directory ! FileFilter filter = new FileFilter() { ! public boolean accept(File f) { ! try { ! return !f.isDirectory() && f.getCanonicalPath().endsWith(".rrd"); ! } catch (IOException e) { ! return false; ! } ! } ! }; ! File[] files = parent.listFiles(filter); ! for(int i = 0; i < files.length; i++) { ! print("[" + i + "/" + files.length + "] "); ! convertFile(files[i]); ! } ! } ! else if(!parent.isDirectory() && parent.exists()) { ! // single file ! convertFile(parent); ! } ! else { ! println("Nothing to do"); } ! println("Conversion finished, " + okCount + " files ok, " + badCount + " files bad"); ! long secs = (System.currentTimeMillis() - start + 500L) / 1000L; ! long mins = secs / 60; ! secs %= 60; ! println("Time elapsed: " + mins + ":" + ((secs < 10)? "0": "") + secs); } ! private long convertFile(File rrdFile) { long start = System.currentTimeMillis(); ! String xmlPath = null, destPath = null; try { String sourcePath = rrdFile.getCanonicalPath(); ! xmlPath = sourcePath + ".xml"; ! destPath = sourcePath + suffix; ! print(rrdFile.getName() + " "); ! xmlDump(sourcePath, xmlPath); ! RrdDb rrd = new RrdDb(destPath, xmlPath); rrd.close(); ! rrd = null; ! System.gc(); ! okCount++; ! long elapsed = System.currentTimeMillis() - start; ! println("[OK, " + (elapsed / 1000.0) + "]"); ! return elapsed; ! } catch (IOException e) { ! removeFile(destPath); ! badCount++; ! println("[IO ERROR]"); ! return -1; ! } catch (RrdException e) { ! removeFile(destPath); badCount++; ! println("[RRD ERROR]"); ! return -2; ! } ! finally { ! removeFile(xmlPath); ! } ! } ! ! private static boolean removeFile(String filePath) { ! if(filePath != null) { ! return new File(filePath).delete(); ! } ! return true; ! } ! ! private void xmlDump(String sourcePath, String xmlPath) throws IOException { ! String[] cmd = new String[] { rrdtoolBinary, "dump", sourcePath }; ! Process p = RUNTIME.exec(cmd); ! OutputStream outStream = new BufferedOutputStream(new FileOutputStream(xmlPath, false)); ! transportStream(p.getInputStream(), outStream); ! transportStream(p.getErrorStream(), null); ! try { ! p.waitFor(); ! } ! catch(InterruptedException ie) { ! // NOP ! } ! } ! ! public static void main(String[] args) { ! if(args.length < 2 || args.length > 3) { ! println("Usage: java -jar convertor.jar " + ! "<path to RRDTool binary> <RRD directory/file path> [converted file suffix]"); ! } ! else { ! Convertor c = new Convertor(args[0], args[1], args.length == 3? args[2]: SUFFIX); ! c.convert(); } } --- 1,76 ---- + /* ============================================================ + * JRobin : Pure java implementation of RRDTool's functionality + * ============================================================ + * + * Project Info: http://www.jrobin.org + * Project Lead: Sasa Markovic (sa...@jr...); + * + * (C) Copyright 2003, by Sasa Markovic. + * + * Developers: Sasa Markovic (sa...@jr...) + * Arne Vandamme (cob...@jr...) + * + * This library is free software; you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Foundation; + * either version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this + * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + package org.jrobin.convertor; import org.jrobin.core.RrdDb; import java.io.*; + import java.text.DecimalFormat; class Convertor { ! private static final String SUFFIX = ".jrobin"; ! private static final DecimalFormat secondsFormatter = new DecimalFormat("##0.000"); ! private static final DecimalFormat countFormatter = new DecimalFormat("00000"); ! private String[] files; ! private int totalCount, badCount, goodCount; ! private Convertor(String[] files) { ! this.files = files; } ! private void convertAll() { ! final String ruler = "======================================================================="; ! println(ruler); ! println("Converting RRDTool files to JRobin native format."); ! println("Original RRDTool files will not be modified in any way"); ! println("JRobin files created during the process will have a " + SUFFIX + " suffix"); ! println(ruler); ! for(int i = 0; i < files.length; i++) { ! convertFile(files[i]); } ! println(ruler); ! println("Finished: " + totalCount + " total, " + ! goodCount + " OK, " + badCount + " failed."); } ! private void convertFile(String path) { long start = System.currentTimeMillis(); ! totalCount++; try { + File rrdFile = new File(path); + print(countFormatter.format(totalCount) + " " + rrdFile.getName() + " "); String sourcePath = rrdFile.getCanonicalPath(); ! String destPath = sourcePath + SUFFIX; ! RrdDb rrd = new RrdDb(destPath, RrdDb.PREFIX_RRDTool + sourcePath); rrd.close(); ! goodCount++; ! double seconds = (System.currentTimeMillis() - start) / 1000.0; ! println("[OK, " + secondsFormatter.format(seconds) + " sec]"); ! } catch (Exception e) { badCount++; ! println("[" + e + "]"); } } *************** *** 137,156 **** } ! private static void transportStream(InputStream in, OutputStream out) throws IOException { ! try { ! int b; ! while((b = in.read()) != -1) { ! if(out != null) { ! out.write(b); ! } ! } ! } ! finally { ! in.close(); ! if(out != null) { ! out.flush(); ! out.close(); ! } } } } --- 84,95 ---- } ! public static void main(String[] args) { ! if(args.length == 0) { ! println("Usage : java -jar convertor.jar <RRD file pattern> ..."); ! println("Example: java -jar convertor.jar files/*.rrd"); ! System.exit(1); } + Convertor c = new Convertor(args); + c.convertAll(); } } |
From: Sasa M. <sa...@us...> - 2004-08-18 08:02:27
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12848/org/jrobin/core Modified Files: Robin.java RrdDef.java Log Message: Bug fixes and API enhancements to Robin class. Index: RrdDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDef.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** RrdDef.java 21 Jul 2004 08:27:40 -0000 1.14 --- RrdDef.java 18 Aug 2004 08:02:17 -0000 1.15 *************** *** 546,551 **** static long calculateSize(int dsCount, int arcCount, int rowsCount) { ! return 64L + 128L * dsCount + 56L * arcCount + ! 20L * dsCount * arcCount + 8L * dsCount * rowsCount; } --- 546,554 ---- static long calculateSize(int dsCount, int arcCount, int rowsCount) { ! // return 64L + 128L * dsCount + 56L * arcCount + ! // 20L * dsCount * arcCount + 8L * dsCount * rowsCount; ! return (24L + 48L * dsCount + 16L * arcCount + ! 20L * dsCount * arcCount + 8L * dsCount * rowsCount) + ! (1L + 2L * dsCount + arcCount) * 2L * RrdPrimitive.STRING_LENGTH; } Index: Robin.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/Robin.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Robin.java 20 May 2004 10:29:32 -0000 1.12 --- Robin.java 18 Aug 2004 08:02:17 -0000 1.13 *************** *** 91,102 **** } - // updates Robin values in bulk void update(double[] newValues) throws IOException { ! assert rows == newValues.length: "Invalid number of values supplied: " + newValues.length + ! " rows=" + rows; pointer.set(0); values.writeDouble(0, newValues); } String dump() throws IOException { StringBuffer buffer = new StringBuffer("Robin " + pointer.get() + "/" + rows + ": "); --- 91,129 ---- } void update(double[] newValues) throws IOException { ! assert rows == newValues.length: "Invalid number of robin values supplied (" + newValues.length + ! "), exactly " + rows + " needed"; pointer.set(0); values.writeDouble(0, newValues); } + /** + * Updates archived values in bulk. + * @param newValues Array of double values to be stored in the archive + * @throws IOException Thrown in case of I/O error + * @throws RrdException Thrown if the length of the input array is different from the length of + * this archive + */ + public void setValues(double[] newValues) throws IOException, RrdException { + if(rows != newValues.length) { + throw new RrdException("Invalid number of robin values supplied (" + newValues.length + + "), exactly " + rows + " needed"); + } + update(newValues); + } + + /** + * (Re)sets all values in this archive to the same value. + * @param newValue New value + * @throws IOException Thrown in case of I/O error + */ + public void setValues(double newValue) throws IOException { + double[] values = new double[rows]; + for(int i = 0; i < values.length; i++) { + values[i] = newValue; + } + update(values); + } + String dump() throws IOException { StringBuffer buffer = new StringBuffer("Robin " + pointer.get() + "/" + rows + ": "); *************** *** 188,192 **** } ! void filterValues(double minValue, double maxValue) throws IOException { for(int i = 0; i < rows; i++) { double value = values.get(i); --- 215,227 ---- } ! /** ! * Filters values stored in this archive based on the given boundary. ! * Archived values found to be outside of <code>[minValue, maxValue]</code> interval (inclusive) ! * will be silently replaced with <code>NaN</code>. ! * @param minValue lower boundary ! * @param maxValue upper boundary ! * @throws IOException Thrown in case of I/O error ! */ ! public void filterValues(double minValue, double maxValue) throws IOException { for(int i = 0; i < rows; i++) { double value = values.get(i); |
From: Arne V. <cob...@us...> - 2004-07-27 12:30:31
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16033/org/jrobin/graph Modified Files: ExportData.java Grapher.java RrdExportDefTemplate.java RrdGraphDefTemplate.java ValueAxisUnit.java Log Message: JRobin 1.4.0 - Updated Javadoc - Value grid tweaking Index: Grapher.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Grapher.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Grapher.java 19 Jul 2004 21:12:27 -0000 1.19 --- Grapher.java 27 Jul 2004 12:30:17 -0000 1.20 *************** *** 662,666 **** { int valRel = chartGraph.getY( valueList[i].getValue() ); ! valueFormat.setFormat( valueList[i].getValue(), 2, 0 ); String label = (valueFormat.getScaledValue() + " " + valueFormat.getPrefix()).trim(); --- 662,666 ---- { int valRel = chartGraph.getY( valueList[i].getValue() ); ! valueFormat.setFormat( valueList[i].getValue(), 2, 0 ); String label = (valueFormat.getScaledValue() + " " + valueFormat.getPrefix()).trim(); Index: ValueAxisUnit.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueAxisUnit.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ValueAxisUnit.java 10 Jul 2004 00:07:03 -0000 1.7 --- ValueAxisUnit.java 27 Jul 2004 12:30:17 -0000 1.8 *************** *** 82,104 **** ValueMarker[] getValueMarkers( double lower, double upper ) { ! double minPoint = 0.0d; ! double majPoint = 0.0d; // Find the first visible gridpoint ! if ( lower > 0 ) { ! while ( minPoint < lower ) minPoint += gridStep; ! while ( majPoint < lower ) majPoint += labelStep; ! } else { ! while ( minPoint > lower ) minPoint -= gridStep; ! while ( majPoint > lower ) majPoint -= labelStep; ! // Go one up to make it visible ! if (minPoint != lower ) minPoint += gridStep; ! if (majPoint != lower ) majPoint += labelStep; } ! ! // Now get all time markers. ! // Again we choose to use a series of loops as to avoid unnecessary drawing. ArrayList markerList = new ArrayList(); ! while ( minPoint <= upper && majPoint <= upper ) { --- 82,114 ---- ValueMarker[] getValueMarkers( double lower, double upper ) { ! double minPoint = 0.0; ! double majPoint = 0.0; // Find the first visible gridpoint ! if ( lower > 0 ) ! { ! minPoint = lower; ! double mod = ( lower % labelStep ); ! ! if ( mod > 0 ) ! majPoint = lower + (labelStep - mod ); ! else ! majPoint = lower; } ! else if ( lower < 0 ) ! { ! minPoint = lower; ! double mod = ( lower % labelStep ); ! ! if ( Math.abs(mod) > 0 ) ! majPoint = lower - mod; ! else ! majPoint = lower; ! } ! ! // Now get all value markers. ! // Again we choose to use a series of loops as to avoid unnecessary drawing. ArrayList markerList = new ArrayList(); ! while ( minPoint <= upper && majPoint <= upper ) { *************** *** 106,110 **** { markerList.add( new ValueMarker(minPoint, false) ); ! minPoint = round( minPoint + gridStep ); } else --- 116,120 ---- { markerList.add( new ValueMarker(minPoint, false) ); ! minPoint = round( minPoint + gridStep ); } else *************** *** 135,142 **** majPoint = round( majPoint + labelStep ); } ! return (ValueMarker[]) markerList.toArray( new ValueMarker[0] ); } ! /** * Gets a rounded value that's slightly below the given exact value. --- 145,152 ---- majPoint = round( majPoint + labelStep ); } ! return (ValueMarker[]) markerList.toArray( new ValueMarker[0] ); } ! /** * Gets a rounded value that's slightly below the given exact value. Index: ExportData.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ExportData.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ExportData.java 13 Jul 2004 12:13:13 -0000 1.4 --- ExportData.java 27 Jul 2004 12:30:17 -0000 1.5 *************** *** 196,199 **** --- 196,200 ---- /** * Returns the step with which this data was fetched. + * * @return Step as long. */ Index: RrdGraphDefTemplate.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphDefTemplate.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RrdGraphDefTemplate.java 20 Jul 2004 16:51:27 -0000 1.10 --- RrdGraphDefTemplate.java 27 Jul 2004 12:30:17 -0000 1.11 *************** *** 96,101 **** * <date_format>HH:mm</date_format> * <center_labels>true</center_labels> ! * <!-- ALLOWED DAYS OF WEEK: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY --> ! * <first_day_of_week>MONDAY</first_day_of_week> * </time_axis> * <time_axis_label>time</time_axis_label> --- 96,101 ---- * <date_format>HH:mm</date_format> * <center_labels>true</center_labels> ! * <!-- ALLOWED DAYS OF WEEK: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY --> ! * <first_day_of_week>MONDAY</first_day_of_week> * </time_axis> * <time_axis_label>time</time_axis_label> *************** *** 126,129 **** --- 126,130 ---- * <source>outOctets</source> * <cf>MAX</cf> + * <backend>FILE</backend> * </def> * <def> *************** *** 135,138 **** --- 136,155 ---- * <rpn>output,8,*,-1,*</rpn> * </def> + * <def> + * <name>avgOutput8</name> + * <datasource>output8</datasource> + * <cf>AVERAGE</cf> + * </def> + * <export_data> + * <file>exportdata1.xml</file> + * <ds_name_prefix>traffic</ds_name_prefix> + * </export_data> + * <export_data> + * <file>exportdata2.xml</file> + * <use_legend_names>true</use_legend_names> + * </export_data> + * <export_data> + * <file>exportdata3.xml</file> + * </export_data> * </datasources> * <graph> *************** *** 204,207 **** --- 221,233 ---- * <width>6</width> * </vrule> + * <time> + * <format>Current time: @t</format> + * <pattern>MMM dd, yyyy HH:mm:ss</pattern> + * </time> + * <time> + * <format>Month: @t</format> + * <pattern>MMMM yyyy</pattern> + * <value>2004-01-01 12:00:00</value> + * </time> * <comment>Created with JRobin</comment> * </graph> *************** *** 215,219 **** * <li>hard-coded timestamps in templates should be long integeres * (like: 1000243567) or ISO formatted strings (like: 2004-02-21 12:25:45) ! * <li>whitespaces are not harmful * <li>use <code>true</code>, <code>on</code>, <code>yes</code>, <code>y</code>, * or <code>1</code> to specify boolean <code>true</code> value (anything else will --- 241,247 ---- * <li>hard-coded timestamps in templates should be long integeres * (like: 1000243567) or ISO formatted strings (like: 2004-02-21 12:25:45) ! * <li>whitespaces are not harmful, however, whitespaces do get special treatment in case of printed text: it is not ! * necessary to use CDATA blocks to specify fixed whitespace with <code>comment</code>,<code>title</code>, <code>time</code>, ! * <code>gprint</code> or <code>legend</code> tags * <li>use <code>true</code>, <code>on</code>, <code>yes</code>, <code>y</code>, * or <code>1</code> to specify boolean <code>true</code> value (anything else will Index: RrdExportDefTemplate.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdExportDefTemplate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdExportDefTemplate.java 13 Jul 2004 12:13:13 -0000 1.2 --- RrdExportDefTemplate.java 27 Jul 2004 12:30:17 -0000 1.3 *************** *** 36,43 **** /** ! * <p>Class used to create an arbitrary number of RrdExportDef (export) objects * from a single XML template. XML template can be supplied as an XML InputSource, * XML file or XML formatted string.<p> * * @author Arne Vandamme (arn...@jr...) */ --- 36,94 ---- /** ! * <p>Class used to create a RrdExportDef (export) object * from a single XML template. XML template can be supplied as an XML InputSource, * XML file or XML formatted string.<p> * + * <p>Below is an exmple XML template, not all options are required:</p> + * + * <xmp> + * <rrd_export_def> + * <span> + * <start>${start}</start> + * <end>${end}</end> + * </span> + * <options> + * <resolution>300</resolution> + * <strict_export>true</strict_export> + * </options> + * <datasources> + * <def> + * <name>bytesIn</name> + * <rrd>${rrd}</rrd> + * <source>ifInOctets</source> + * <cf>AVERAGE</cf> + * </def> + * <def> + * <name>bytesOut</name> + * <rrd>${rrd}</rrd> + * <source>ifOutOctets</source> + * <cf>AVERAGE</cf> + * </def> + * <def> + * <name>bitsIn</name> + * <rpn>bytesIn,8,*</rpn> + * </def> + * <def> + * <name>bitsOut</name> + * <rpn>bytesOut,8,*</rpn> + * </def> + * </datasources> + * <exports> + * <export> + * <datasource>bitsIn</datasource> + * <legend>Incoming traffic</legend> + * </export> + * <export> + * <datasource>bitsOut</datasource> + * <legend>Outgoing traffic</legend> + * </export> + * </exports> + * </rrd_export_def> + * </xmp> + * + * <p><b>Note:</b> for more information on JRobin XML templates in general, refer to the {@link RrdGraphDefTemplate}</p> + * <p><b>Note:</b> the <code>RrdExportDefTemplate</code> <code>datasources</code> section can contain all the same options + * as the corresponding section in {@link RrdGraphDefTemplate} + * </p> * @author Arne Vandamme (arn...@jr...) */ |
From: Arne V. <cob...@us...> - 2004-07-25 12:29:28
|
Update of /cvsroot/jrobin/src/org/jrobin/demo/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7060/org/jrobin/demo/graph Modified Files: ExportExportDemo.java ExportImportDemo.java ExportTemplate.java LazyDemo.java Log Message: JRobin 1.4.0 - Bug fixes graphing - Demo tweaks Index: ExportExportDemo.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/demo/graph/ExportExportDemo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExportExportDemo.java 14 Jul 2004 12:52:34 -0000 1.2 --- ExportExportDemo.java 25 Jul 2004 12:29:19 -0000 1.3 *************** *** 53,69 **** private static void prepare( String[] args ) { - /* - if ( args.length != 1 ) - { - println( "Usage: ExportExportDemo <path_to_demo_resources>" ); - println( " The only argument to this program should be the path to the JRobin" ); - println( " demo resources. These are normally included in the JRobin distribution" ); - println( " in the <jrobin>/res/demo directory." ); - - System.exit( 1 ); - } - - demoResources = new File(args[0]).getAbsolutePath() + "/"; - */ demoResources = Util.getJRobinHomeDirectory() + "/res/demo/"; } --- 53,56 ---- Index: ExportImportDemo.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/demo/graph/ExportImportDemo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExportImportDemo.java 14 Jul 2004 12:52:34 -0000 1.2 --- ExportImportDemo.java 25 Jul 2004 12:29:19 -0000 1.3 *************** *** 52,68 **** private static void prepare( String[] args ) { - /* - if ( args.length != 1 ) - { - println( "Usage: ExportImportDemo <path_to_demo_resources>" ); - println( " The only argument to this program should be the path to the JRobin" ); - println( " demo resources. These are normally included in the JRobin distribution" ); - println( " in the <jrobin>/res/demo directory." ); - - System.exit( 1 ); - } - - demoResources = new File(args[0]).getAbsolutePath() + "/"; - */ demoResources = Util.getJRobinHomeDirectory() + "/res/demo/"; } --- 52,55 ---- Index: ExportTemplate.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/demo/graph/ExportTemplate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExportTemplate.java 13 Jul 2004 12:16:08 -0000 1.2 --- ExportTemplate.java 25 Jul 2004 12:29:19 -0000 1.3 *************** *** 93,97 **** if ( args.length < 1 ) { ! System.out.println( "Usage: ExportTemplate [-m width] [-f <dump_file>] <template_file>" ); System.exit(0); } --- 93,97 ---- if ( args.length < 1 ) { ! System.out.println( "Usage: ExportTemplate [-m maxRows] [-f <dump_file>] <template_file>" ); System.exit(0); } Index: LazyDemo.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/demo/graph/LazyDemo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LazyDemo.java 14 Jul 2004 12:52:34 -0000 1.2 --- LazyDemo.java 25 Jul 2004 12:29:19 -0000 1.3 *************** *** 83,100 **** private static void prepare( String[] args ) { ! /* ! if ( args.length != 1 ) ! { ! println( "Usage: LazyDemo <path_to_demo_resources>" ); ! println( " The only argument to this program should be the path to the JRobin" ); ! println( " demo resources. These are normally included in the JRobin distribution" ); ! println( " in the <jrobin>/res/demo directory." ); ! ! System.exit( 1 ); ! } ! ! demoResources = new File(args[0]).getAbsolutePath() + "/"; ! */ ! demoResources = Util.getJRobinHomeDirectory() + "/res/demo/"; rrd1 = demoResources + rrd1; rrd2 = demoResources + rrd2; --- 83,87 ---- private static void prepare( String[] args ) { ! demoResources = Util.getJRobinHomeDirectory() + "/res/demo/"; rrd1 = demoResources + rrd1; rrd2 = demoResources + rrd2; |
From: Arne V. <cob...@us...> - 2004-07-25 12:29:00
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6986/org/jrobin/graph Modified Files: FetchSource.java PlotDef.java RrdExporter.java Source.java ValueExtractor.java ValueGrid.java Log Message: JRobin 1.4.0 - Bug fixes graphing - Demo tweaks Index: ValueExtractor.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueExtractor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ValueExtractor.java 9 Jul 2004 12:22:15 -0000 1.3 --- ValueExtractor.java 25 Jul 2004 12:28:49 -0000 1.4 *************** *** 77,81 **** dsValues[i] = values[i].getValues(); ! if ( timestamps[i].length > 2 ) steps[i] = (timestamps[i][1] - timestamps[i][0]); } --- 77,81 ---- dsValues[i] = values[i].getValues(); ! if ( timestamps[i].length >= 2 ) steps[i] = (timestamps[i][1] - timestamps[i][0]); } *************** *** 96,100 **** --- 96,102 ---- { for (int x = 0; x < dsValues[i].length; x++) + { sources[tblPos++].setFetchedStep( steps[i] ); + } } } Index: ValueGrid.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/ValueGrid.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ValueGrid.java 20 Jul 2004 17:01:41 -0000 1.12 --- ValueGrid.java 25 Jul 2004 12:28:49 -0000 1.13 *************** *** 82,86 **** { baseValue = base; ! double tmp = 1; for (int i = 1; i < 7; i++) { --- 82,86 ---- { baseValue = base; ! double tmp = 1; for (int i = 1; i < 7; i++) { Index: RrdExporter.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdExporter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RrdExporter.java 19 Jul 2004 21:12:27 -0000 1.5 --- RrdExporter.java 25 Jul 2004 12:28:49 -0000 1.6 *************** *** 285,289 **** vEndTime += minStep; ! numRows = (int) ((vEndTime - vStartTime) / minStep) + 1; } --- 285,289 ---- vEndTime += minStep; ! numRows = reducedNumRows; //(int) ((vEndTime - vStartTime) / minStep) + 1; } Index: Source.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/Source.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Source.java 11 Jul 2004 22:04:14 -0000 1.11 --- Source.java 25 Jul 2004 12:28:49 -0000 1.12 *************** *** 95,100 **** } ! void setFetchedStep( long step ) ! { this.step = step; } --- 95,99 ---- } ! void setFetchedStep( long step ) { this.step = step; } Index: FetchSource.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/FetchSource.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FetchSource.java 9 Jul 2004 12:22:15 -0000 1.9 --- FetchSource.java 25 Jul 2004 12:28:49 -0000 1.10 *************** *** 196,202 **** // Fetch datasources ! FetchRequest request = rrd.createFetchRequest( cfNames[i], startTime, endTime + rrdStep, resolution ); ! long arcStep = rrd.findMatchingArchive( request ).getArcStep(); ! request = rrd.createFetchRequest( cfNames[i], startTime, endTime + arcStep, resolution ); request.setFilter( dsNames ); --- 196,200 ---- // Fetch datasources ! FetchRequest request = rrd.createFetchRequest( cfNames[i], startTime, endTime, resolution ); request.setFilter( dsNames ); Index: PlotDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/PlotDef.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PlotDef.java 9 Jul 2004 12:22:15 -0000 1.5 --- PlotDef.java 25 Jul 2004 12:28:49 -0000 1.6 *************** *** 133,137 **** double getValue( int tblPos, long[] timestamps ) { ! return source.values[tblPos]; } --- 133,137 ---- double getValue( int tblPos, long[] timestamps ) { ! return source.get( tblPos ); } |
From: Arne V. <cob...@us...> - 2004-07-25 12:28:24
|
Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6947/org/jrobin/core Modified Files: RrdDb.java Log Message: JRobin 1.4.0 - Bug fixes graphing - Demo tweaks Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** RrdDb.java 22 Jul 2004 09:34:10 -0000 1.26 --- RrdDb.java 25 Jul 2004 12:28:14 -0000 1.27 *************** *** 515,564 **** } ! public Archive findMatchingArchive(FetchRequest request) throws RrdException, IOException { ! String consolFun = request.getConsolFun(); ! long fetchStart = request.getFetchStart(); ! long fetchEnd = request.getFetchEnd(); ! long resolution = request.getResolution(); Archive bestFullMatch = null, bestPartialMatch = null; long bestStepDiff = 0, bestMatch = 0; ! for(int i = 0; i < archives.length; i++) { ! if(archives[i].getConsolFun().equals(consolFun)) { ! long arcStep = archives[i].getArcStep(); ! long arcStart = archives[i].getStartTime() - arcStep; ! long arcEnd = archives[i].getEndTime(); ! long fullMatch = fetchEnd - fetchStart; ! // best full match ! if(arcEnd >= fetchEnd && arcStart <= fetchStart) { ! long tmpStepDiff = Math.abs(archives[i].getArcStep() - resolution); ! if(bestFullMatch == null || tmpStepDiff < bestStepDiff) { bestStepDiff = tmpStepDiff; bestFullMatch = archives[i]; } } ! // best partial match ! else { long tmpMatch = fullMatch; ! if(arcStart > fetchStart) { tmpMatch -= (arcStart - fetchStart); ! } ! if(arcEnd < fetchEnd) { tmpMatch -= (fetchEnd - arcEnd); ! } ! if(bestPartialMatch == null || bestMatch < tmpMatch) { ! bestPartialMatch = archives[i]; ! bestMatch = tmpMatch; } } } } ! if(bestFullMatch != null) { return bestFullMatch; ! } ! else if(bestPartialMatch != null) { return bestPartialMatch; ! } ! else { throw new RrdException("RRD file does not contain RRA:" + consolFun + " archive"); - } } --- 515,573 ---- } ! public Archive findMatchingArchive(FetchRequest request) throws RrdException, IOException ! { ! String consolFun = request.getConsolFun(); ! long fetchStart = request.getFetchStart(); ! long fetchEnd = request.getFetchEnd(); ! long resolution = request.getResolution(); ! Archive bestFullMatch = null, bestPartialMatch = null; + long bestStepDiff = 0, bestMatch = 0; ! ! for ( int i = 0; i < archives.length; i++ ) ! { ! if ( archives[i].getConsolFun().equals(consolFun) ) ! { ! long arcStep = archives[i].getArcStep(); ! long arcStart = archives[i].getStartTime() - arcStep; ! long arcEnd = archives[i].getEndTime(); ! long fullMatch = fetchEnd - fetchStart; ! ! if ( arcEnd >= fetchEnd && arcStart <= fetchStart ) // best full match ! { ! long tmpStepDiff = Math.abs( archives[i].getArcStep() - resolution ); ! ! if ( tmpStepDiff < bestStepDiff || bestFullMatch == null ) ! { bestStepDiff = tmpStepDiff; bestFullMatch = archives[i]; } + } ! else // best partial match ! { long tmpMatch = fullMatch; ! ! if ( arcStart > fetchStart ) tmpMatch -= (arcStart - fetchStart); ! if( arcEnd < fetchEnd ) tmpMatch -= (fetchEnd - arcEnd); ! ! if ( bestPartialMatch == null || bestMatch < tmpMatch ) ! { ! bestPartialMatch = archives[i]; ! bestMatch = tmpMatch; } } } } ! ! if ( bestFullMatch != null ) return bestFullMatch; ! else if ( bestPartialMatch != null ) return bestPartialMatch; ! else throw new RrdException("RRD file does not contain RRA:" + consolFun + " archive"); } |
From: Sasa M. <sa...@us...> - 2004-07-22 09:36:46
|
Update of /cvsroot/jrobin/src/org/jrobin/core/jrrd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9853/org/jrobin/core/jrrd Modified Files: RRDatabase.java Log Message: minor changes Index: RRDatabase.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/jrrd/RRDatabase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RRDatabase.java 22 Jul 2004 09:34:10 -0000 1.1 --- RRDatabase.java 22 Jul 2004 09:36:33 -0000 1.2 *************** *** 288,292 **** // Find start and end offsets ! // todo: This is terrible - some of this should be encapsulated in Archive - CT. long lastUpdateLong = lastUpdate.getTime() / 1000; long archiveEndTime = lastUpdateLong - (lastUpdateLong % step); --- 288,292 ---- // Find start and end offsets ! // This is terrible - some of this should be encapsulated in Archive - CT. long lastUpdateLong = lastUpdate.getTime() / 1000; long archiveEndTime = lastUpdateLong - (lastUpdateLong % step); *************** *** 321,325 **** int firstFull = 1; long bestMatch = 0; ! long bestPartRRA = 0; long bestStepDiff = 0; long tmpStepDiff = 0; --- 321,325 ---- int firstFull = 1; long bestMatch = 0; ! //long bestPartRRA = 0; long bestStepDiff = 0; long tmpStepDiff = 0; *************** *** 364,368 **** // See how the matching went ! // todo: optimise this if (firstFull == 0) { archive = bestFullArchive; --- 364,368 ---- // See how the matching went ! // optimise this if (firstFull == 0) { archive = bestFullArchive; |