|
From: <jt...@hy...> - 2007-03-20 20:19:32
|
Author: jtravis Date: 2007-03-20 12:19:17 -0800 (Tue, 20 Mar 2007) New Revision: 3795 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3795 Modified: trunk/installer/data/db-upgrade.xml trunk/sql/measurement/MeasurementData.hq-xml trunk/sql/measurement/MeasurementHistData.hq-xml trunk/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java trunk/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java Log: Revert back to BigDecimal, since underflows and other floating point errors will cause measurement data to not be inserted. The original Sorry error is likely fixed by the change to DataManager which dealt with processing the exception of batch (logic error) Modified: trunk/installer/data/db-upgrade.xml =================================================================== --- trunk/installer/data/db-upgrade.xml 2007-03-20 13:03:23 UTC (rev 3794) +++ trunk/installer/data/db-upgrade.xml 2007-03-20 20:19:17 UTC (rev 3795) @@ -4938,6 +4938,70 @@ nullable="NULL"/> </schemaSpec> + <schemaSpec version="3.22"> + <schema-directSQL> + <statement targetDB="postgresql"> + alter table eam_measurement_data alter column value type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_1h alter column value type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_1h alter column minvalue type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_1h alter column maxvalue type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_6h alter column value type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_6h alter column minvalue type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_6h alter column maxvalue type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_1d alter column value type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_1d alter column minvalue type NUMERIC(24,5) + </statement> + <statement targetDB="postgresql"> + alter table eam_measurement_data_1d alter column maxvalue type NUMERIC(24,5) + </statement> + + <statement targetDB="oracle"> + alter table eam_measurement_data modify ( + value NUMERIC(24,5) + ) + </statement> + <statement targetDB="oracle"> + alter table eam_measurement_data_1h modify ( + value NUMERIC(24,5), + minvalue NUMERIC(24,5), + maxvalue NUMERIC(24,5) + ) + </statement> + <statement targetDB="oracle"> + alter table eam_measurement_data_6h modify ( + value NUMERIC(24,5), + minvalue NUMERIC(24,5), + maxvalue NUMERIC(24,5) + ) + </statement> + <statement targetDB="oracle"> + alter table eam_measurement_data_1d modify ( + value NUMERIC(24,5), + minvalue NUMERIC(24,5), + maxvalue NUMERIC(24,5) + ) + </statement> + + </schema-directSQL> + </schemaSpec> + + </dbupgrade> </target> Modified: trunk/sql/measurement/MeasurementData.hq-xml =================================================================== --- trunk/sql/measurement/MeasurementData.hq-xml 2007-03-20 13:03:23 UTC (rev 3794) +++ trunk/sql/measurement/MeasurementData.hq-xml 2007-03-20 20:19:17 UTC (rev 3795) @@ -17,8 +17,8 @@ </key-property> </composite-id> - <property name="value"> - <column name="VALUE" /> + <property name="value" type="big_decimal"> + <column name="VALUE" precision="24" scale="5" /> </property> </class> Modified: trunk/sql/measurement/MeasurementHistData.hq-xml =================================================================== --- trunk/sql/measurement/MeasurementHistData.hq-xml 2007-03-20 13:03:23 UTC (rev 3794) +++ trunk/sql/measurement/MeasurementHistData.hq-xml 2007-03-20 20:19:17 UTC (rev 3795) @@ -17,16 +17,16 @@ </key-property> </composite-id> - <property name="value"> - <column name="VALUE"/> + <property name="value" type="big_decimal"> + <column name="VALUE" precision="24" scale="5" /> </property> - <property name="minValue"> - <column name="MINVALUE"/> + <property name="minValue" type="big_decimal"> + <column name="MINVALUE" precision="24" scale="5"/> </property> - <property name="maxValue"> - <column name="MAXVALUE"/> + <property name="maxValue" type="big_decimal"> + <column name="MAXVALUE" precision="24" scale="5"/> </property> </class> @@ -41,16 +41,16 @@ </key-property> </composite-id> - <property name="value"> - <column name="VALUE"/> + <property name="value" type="big_decimal"> + <column name="VALUE" precision="24" scale="5" /> </property> - <property name="minValue"> - <column name="MINVALUE"/> + <property name="minValue" type="big_decimal"> + <column name="MINVALUE" precision="24" scale="5"/> </property> - <property name="maxValue"> - <column name="MAXVALUE"/> + <property name="maxValue" type="big_decimal"> + <column name="MAXVALUE" precision="24" scale="5"/> </property> </class> @@ -65,16 +65,16 @@ </key-property> </composite-id> - <property name="value"> - <column name="VALUE"/> + <property name="value" type="big_decimal"> + <column name="VALUE" precision="24" scale="5" /> </property> - <property name="minValue"> - <column name="MINVALUE"/> + <property name="minValue" type="big_decimal"> + <column name="MINVALUE" precision="24" scale="5"/> </property> - <property name="maxValue"> - <column name="MAXVALUE"/> + <property name="maxValue" type="big_decimal"> + <column name="MAXVALUE" precision="24" scale="5"/> </property> </class> Modified: trunk/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java 2007-03-20 13:03:23 UTC (rev 3794) +++ trunk/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java 2007-03-20 20:19:17 UTC (rev 3795) @@ -25,6 +25,7 @@ package org.hyperic.hq.measurement.server.session; +import java.math.BigDecimal; import java.sql.BatchUpdateException; import java.sql.Connection; import java.sql.PreparedStatement; @@ -303,10 +304,17 @@ DataPoint pt = (DataPoint)i.next(); Integer metricId = pt.getMetricId(); MetricValue val = pt.getMetricValue(); + BigDecimal bigDec; + try { + bigDec = BigDecimal.valueOf(val.getValue()); + } catch(NumberFormatException e) { // infinite, or NaN + _log.warn("Unable to insert infinite or NaN for metric id=" + metricId); + continue; + } stmt.setInt(1, metricId.intValue()); stmt.setLong(2, val.getTimestamp()); - stmt.setDouble(3, val.getValue()); + stmt.setBigDecimal(3, bigDec); stmt.addBatch(); } @@ -432,10 +440,17 @@ DataPoint pt = (DataPoint)i.next(); Integer metricId = pt.getMetricId(); MetricValue val = pt.getMetricValue(); + BigDecimal bigDec; + try { + bigDec = BigDecimal.valueOf(val.getValue()); + } catch(NumberFormatException e) { // infinite, or NaN + _log.warn("Unable to insert infinite or NaN for metric id=" + metricId); + continue; + } stmt.setInt(1, metricId.intValue()); stmt.setLong(2, val.getTimestamp()); - stmt.setDouble(3, val.getValue()); + stmt.setBigDecimal(3, bigDec); stmt.addBatch(); } Modified: trunk/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java =================================================================== --- trunk/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java 2007-03-20 13:03:23 UTC (rev 3794) +++ trunk/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java 2007-03-20 20:19:17 UTC (rev 3795) @@ -26,14 +26,15 @@ package org.hyperic.hq.measurement.server.session; import java.io.Serializable; +import java.math.BigDecimal; public class MeasurementHistData implements Serializable { private MeasurementDataId _id; - private double _value; - private double _minValue; - private double _maxValue; + private BigDecimal _value; + private BigDecimal _minValue; + private BigDecimal _maxValue; protected MeasurementHistData() { } @@ -46,27 +47,27 @@ _id = id; } - public double getValue() { + public BigDecimal getValue() { return _value; } - protected void setValue(double value) { + protected void setValue(BigDecimal value) { _value = value; } - public double getMinValue() { + public BigDecimal getMinValue() { return _minValue; } - protected void setMinValue(double minValue) { + protected void setMinValue(BigDecimal minValue) { _minValue = minValue; } - public double getMaxValue() { + public BigDecimal getMaxValue() { return _maxValue; } - protected void setMaxValue(double maxValue) { + protected void setMaxValue(BigDecimal maxValue) { _maxValue = maxValue; } |