|
From: <jt...@hy...> - 2007-03-20 20:50:04
|
Author: jtravis Date: 2007-03-20 12:50:02 -0800 (Tue, 20 Mar 2007) New Revision: 3797 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3797 Modified: branches/HQ_3_0/installer/data/db-upgrade.xml branches/HQ_3_0/sql/measurement/MeasurementData.hq-xml branches/HQ_3_0/sql/measurement/MeasurementHistData.hq-xml branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementData.java branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java Log: HHQ-755 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: branches/HQ_3_0/installer/data/db-upgrade.xml =================================================================== --- branches/HQ_3_0/installer/data/db-upgrade.xml 2007-03-20 20:35:41 UTC (rev 3796) +++ branches/HQ_3_0/installer/data/db-upgrade.xml 2007-03-20 20:50:02 UTC (rev 3797) @@ -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: branches/HQ_3_0/sql/measurement/MeasurementData.hq-xml =================================================================== --- branches/HQ_3_0/sql/measurement/MeasurementData.hq-xml 2007-03-20 20:35:41 UTC (rev 3796) +++ branches/HQ_3_0/sql/measurement/MeasurementData.hq-xml 2007-03-20 20:50:02 UTC (rev 3797) @@ -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: branches/HQ_3_0/sql/measurement/MeasurementHistData.hq-xml =================================================================== --- branches/HQ_3_0/sql/measurement/MeasurementHistData.hq-xml 2007-03-20 20:35:41 UTC (rev 3796) +++ branches/HQ_3_0/sql/measurement/MeasurementHistData.hq-xml 2007-03-20 20:50:02 UTC (rev 3797) @@ -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: branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java =================================================================== --- branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java 2007-03-20 20:35:41 UTC (rev 3796) +++ branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/DataManagerEJBImpl.java 2007-03-20 20:50:02 UTC (rev 3797) @@ -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: branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementData.java =================================================================== --- branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementData.java 2007-03-20 20:35:41 UTC (rev 3796) +++ branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementData.java 2007-03-20 20:50:02 UTC (rev 3797) @@ -26,10 +26,11 @@ package org.hyperic.hq.measurement.server.session; import java.io.Serializable; +import java.math.BigDecimal; public class MeasurementData implements Serializable { private MeasurementDataId _id; - private double _value; + private BigDecimal _value; public MeasurementData() { } @@ -42,11 +43,11 @@ _id = id; } - public double getValue() { + public BigDecimal getValue() { return _value; } - protected void setValue(double value) { + protected void setValue(BigDecimal value) { _value = value; } Modified: branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java =================================================================== --- branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java 2007-03-20 20:35:41 UTC (rev 3796) +++ branches/HQ_3_0/src/org/hyperic/hq/measurement/server/session/MeasurementHistData.java 2007-03-20 20:50:02 UTC (rev 3797) @@ -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; } |