You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ma...@apache.org on 2012/02/12 08:19:48 UTC

svn commit: r1243204 - in /hadoop/common/branches/branch-1.0: CHANGES.txt src/core/org/apache/hadoop/metrics2/util/SampleStat.java src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java

Author: mattf
Date: Sun Feb 12 07:19:47 2012
New Revision: 1243204

URL: http://svn.apache.org/viewvc?rev=1243204&view=rev
Log:
HADOOP-8052. Hadoop Metrics2 should emit Float.MAX_VALUE (instead of Double.MAX_VALUE) to avoid making Ganglia's gmetad core. Contributed by Varun Kapoor.

Modified:
    hadoop/common/branches/branch-1.0/CHANGES.txt
    hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/metrics2/util/SampleStat.java
    hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java

Modified: hadoop/common/branches/branch-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/CHANGES.txt?rev=1243204&r1=1243203&r2=1243204&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1.0/CHANGES.txt Sun Feb 12 07:19:47 2012
@@ -1,6 +1,6 @@
 Hadoop Change Log
 
-Release 1.0.1 - 2012.02.08
+Release 1.0.1 - 2012.02.12
 
   NEW FEATURES
 
@@ -35,6 +35,10 @@ Release 1.0.1 - 2012.02.08
     HADOOP-8010. hadoop-config.sh errors when HADOOP_HOME_WARN_SUPPRESS is set 
     to true and HADOOP_HOME is present. (Roman Shaposhnik via mattf)
 
+    HADOOP-8052. Hadoop Metrics2 should emit Float.MAX_VALUE (instead of 
+    Double.MAX_VALUE) to avoid making Ganglia's gmetad core. (Varun Kapoor
+    via mattf)
+
 Release 1.0.0 - 2011.12.15
 
   NEW FEATURES

Modified: hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/metrics2/util/SampleStat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/metrics2/util/SampleStat.java?rev=1243204&r1=1243203&r2=1243204&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/metrics2/util/SampleStat.java (original)
+++ hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/metrics2/util/SampleStat.java Sun Feb 12 07:19:47 2012
@@ -141,8 +141,16 @@ public class SampleStat {
   @SuppressWarnings("PublicInnerClass")
   public static class MinMax {
 
-    private double min = Double.MAX_VALUE;
-    private double max = Double.MIN_VALUE;
+    // Float.MAX_VALUE is used rather than Double.MAX_VALUE, even though the
+    // min and max variables are of type double.
+    // Float.MAX_VALUE is big enough, and using Double.MAX_VALUE makes 
+    // Ganglia core due to buffer overflow.
+    // The same reasoning applies to the MIN_VALUE counterparts.
+    static final double DEFAULT_MIN_VALUE = Float.MAX_VALUE;
+    static final double DEFAULT_MAX_VALUE = Float.MIN_VALUE;
+
+    private double min = DEFAULT_MIN_VALUE;
+    private double max = DEFAULT_MAX_VALUE;
 
     public void add(double value) {
       if (value > max) max = value;
@@ -153,8 +161,8 @@ public class SampleStat {
     public double max() { return max; }
 
     public void reset() {
-      min = Double.MAX_VALUE;
-      max = Double.MIN_VALUE;
+      min = DEFAULT_MIN_VALUE;
+      max = DEFAULT_MAX_VALUE;
     }
 
     public void reset(MinMax other) {

Modified: hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java?rev=1243204&r1=1243203&r2=1243204&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java (original)
+++ hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java Sun Feb 12 07:19:47 2012
@@ -36,8 +36,8 @@ public class TestSampleStat {
     assertEquals("mean", 0.0, stat.mean(), EPSILON);
     assertEquals("variance", 0.0, stat.variance(), EPSILON);
     assertEquals("stddev", 0.0, stat.stddev(), EPSILON);
-    assertEquals("min", Double.MAX_VALUE, stat.min(), EPSILON);
-    assertEquals("max", Double.MIN_VALUE, stat.max(), EPSILON);
+    assertEquals("min", SampleStat.MinMax.DEFAULT_MIN_VALUE, stat.min(), EPSILON);
+    assertEquals("max", SampleStat.MinMax.DEFAULT_MAX_VALUE, stat.max(), EPSILON);
 
     stat.add(3);
     assertEquals("num samples", 1L, stat.numSamples());
@@ -60,8 +60,8 @@ public class TestSampleStat {
     assertEquals("mean", 0.0, stat.mean(), EPSILON);
     assertEquals("variance", 0.0, stat.variance(), EPSILON);
     assertEquals("stddev", 0.0, stat.stddev(), EPSILON);
-    assertEquals("min", Double.MAX_VALUE, stat.min(), EPSILON);
-    assertEquals("max", Double.MIN_VALUE, stat.max(), EPSILON);
+    assertEquals("min", SampleStat.MinMax.DEFAULT_MIN_VALUE, stat.min(), EPSILON);
+    assertEquals("max", SampleStat.MinMax.DEFAULT_MAX_VALUE, stat.max(), EPSILON);
   }
 
 }