浏览代码

MAPREDUCE-5671. NaN can be created by client and assign to Progress (Chen He via jeagles)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1570620 13f79535-47bb-0310-9956-ffa450edef68
Jonathan Turner Eagles 11 年之前
父节点
当前提交
aa4cbcfa79

+ 25 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Progress.java

@@ -160,6 +160,31 @@ public class Progress {
 
   /** Called during execution on a leaf node to set its progress. */
   public synchronized void set(float progress) {
+    if (Float.isNaN(progress)) {
+      progress = 0;
+      LOG.warn("Illegal progress value found, progress is Float.NaN. " +
+        "Progress will be changed to 0");
+    }
+    else if (progress == Float.NEGATIVE_INFINITY) {
+      progress = 0;
+      LOG.warn("Illegal progress value found, progress is " +
+        "Float.NEGATIVE_INFINITY. Progress will be changed to 0");
+    }
+    else if (progress < 0) {
+      progress = 0;
+      LOG.warn("Illegal progress value found, progress is less than 0." +
+        " Progress will be changed to 0");
+    }
+    else if (progress > 1) {
+      progress = 1;
+      LOG.warn("Illegal progress value found, progress is larger than 1." +
+        " Progress will be changed to 1");
+    }
+    else if (progress == Float.POSITIVE_INFINITY) {
+      progress = 1;
+      LOG.warn("Illegal progress value found, progress is " +
+        "Float.POSITIVE_INFINITY. Progress will be changed to 1");
+    }
     this.progress = progress;
   }
 

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -147,6 +147,9 @@ Release 2.5.0 - UNRELEASED
 
   IMPROVEMENTS
 
+    MAPREDUCE-5671. NaN can be created by client and assign to Progress (Chen
+    He via jeagles)
+
   OPTIMIZATIONS
 
   BUG FIXES