瀏覽代碼

commit c4552dbc8fb5bbf76f7e04cb0c97316a70291d79
Author: Lee Tucker <ltucker@yahoo-inc.com>
Date: Thu Jul 30 17:40:42 2009 -0700

Applying patch 2870656.mr709.patch


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1076954 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 年之前
父節點
當前提交
c053100aaf

+ 9 - 2
src/mapred/org/apache/hadoop/mapred/NodeHealthCheckerService.java

@@ -70,6 +70,8 @@ class NodeHealthCheckerService {
 
   static final String HEALTH_CHECK_SCRIPT_ARGUMENTS_PROPERTY = "mapred.healthChecker.script.args";
   /* end of configuration keys */
+  /** Time out error message */
+  static final String NODE_HEALTH_SCRIPT_TIMED_OUT_MSG = "Node health script timed out";
 
   /** Default frequency of running node health script */
   private static final long DEFAULT_HEALTH_CHECK_INTERVAL = 10 * 60 * 1000;
@@ -84,6 +86,7 @@ class NodeHealthCheckerService {
 
   private TimerTask timer;
   
+  
   private enum HealthCheckerExitStatus {
     SUCCESS,
     TIMED_OUT,
@@ -122,7 +125,11 @@ class NodeHealthCheckerService {
         status = HealthCheckerExitStatus.FAILED_WITH_EXIT_CODE;
       } catch (Exception e) {
         LOG.warn("Caught exception : " + e.getMessage());
-        status = HealthCheckerExitStatus.FAILED_WITH_EXCEPTION;
+        if (!shexec.isTimedOut()) {
+          status = HealthCheckerExitStatus.FAILED_WITH_EXCEPTION;
+        } else {
+          status = HealthCheckerExitStatus.TIMED_OUT;
+        }
         exceptionStackTrace = StringUtils.stringifyException(e);
       } finally {
         if (status == HealthCheckerExitStatus.SUCCESS) {
@@ -160,7 +167,7 @@ class NodeHealthCheckerService {
         setHealthStatus(true, "", now);
         break;
       case TIMED_OUT:
-        setHealthStatus(false, "Node health script timed out");
+        setHealthStatus(false, NODE_HEALTH_SCRIPT_TIMED_OUT_MSG);
         break;
       case FAILED_WITH_EXCEPTION:
         setHealthStatus(false, exceptionStackTrace);

+ 3 - 2
src/test/org/apache/hadoop/mapred/TestNodeHealthService.java

@@ -152,8 +152,9 @@ public class TestNodeHealthService extends TestCase {
     LOG.info("Checking Healthy--->timeout");
     assertFalse("Node health status reported healthy even after timeout",
         healthStatus.isNodeHealthy());
-    assertFalse("Node health status reported healthy even after timeout",
-        healthStatus.getHealthReport().isEmpty());
+    assertEquals("Node time out message not propogated", healthStatus
+        .getHealthReport(),
+        NodeHealthCheckerService.NODE_HEALTH_SCRIPT_TIMED_OUT_MSG);
   }
 
 }