瀏覽代碼

svn merge -c 1513888 FIXES: YARN-337. RM handles killed application tracking URL poorly. Contributed by Jason Lowe

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1513894 13f79535-47bb-0310-9956-ffa450edef68
Jason Darrell Lowe 11 年之前
父節點
當前提交
65b77717b4

+ 2 - 0
hadoop-yarn-project/CHANGES.txt

@@ -27,6 +27,8 @@ Release 0.23.10 - UNRELEASED
     YARN-543. Shared data structures in Public Localizer and Private
     YARN-543. Shared data structures in Public Localizer and Private
     Localizer are not Thread safe. (Omkar Vinit Joshi and Mit Desai via jlowe)
     Localizer are not Thread safe. (Omkar Vinit Joshi and Mit Desai via jlowe)
 
 
+    YARN-337. RM handles killed application tracking URL poorly (jlowe)
+
 Release 0.23.9 - 2013-07-08
 Release 0.23.9 - 2013-07-08
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 4 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java

@@ -678,6 +678,8 @@ public class RMAppAttemptImpl implements RMAppAttempt {
         break;
         break;
         case KILLED:
         case KILLED:
         {
         {
+          // don't leave the tracking URL pointing to a non-existent AM
+          appAttempt.setTrackingUrlToRMAppPage();
           appEvent =
           appEvent =
               new RMAppFailedAttemptEvent(applicationId,
               new RMAppFailedAttemptEvent(applicationId,
                   RMAppEventType.ATTEMPT_KILLED,
                   RMAppEventType.ATTEMPT_KILLED,
@@ -686,6 +688,8 @@ public class RMAppAttemptImpl implements RMAppAttempt {
         break;
         break;
         case FAILED:
         case FAILED:
         {
         {
+          // don't leave the tracking URL pointing to a non-existent AM
+          appAttempt.setTrackingUrlToRMAppPage();
           appEvent =
           appEvent =
               new RMAppFailedAttemptEvent(applicationId,
               new RMAppFailedAttemptEvent(applicationId,
                   RMAppEventType.ATTEMPT_FAILED,
                   RMAppEventType.ATTEMPT_FAILED,
@@ -849,7 +853,6 @@ public class RMAppAttemptImpl implements RMAppAttempt {
         RMAppAttemptEvent event) {
         RMAppAttemptEvent event) {
       appAttempt.diagnostics.append("ApplicationMaster for attempt " +
       appAttempt.diagnostics.append("ApplicationMaster for attempt " +
         appAttempt.getAppAttemptId() + " timed out");
         appAttempt.getAppAttemptId() + " timed out");
-      appAttempt.setTrackingUrlToRMAppPage();
       super.transition(appAttempt, event);
       super.transition(appAttempt, event);
     }
     }
   }
   }
@@ -930,11 +933,6 @@ public class RMAppAttemptImpl implements RMAppAttempt {
             " due to: " +  containerStatus.getDiagnostics() + "." +
             " due to: " +  containerStatus.getDiagnostics() + "." +
             "Failing this attempt.");
             "Failing this attempt.");
 
 
-        // When the AM dies, the trackingUrl is left pointing to the AM's URL,
-        // which shows up in the scheduler UI as a broken link.  Direct the
-        // user to the app page on the RM so they can see the status and logs.
-        appAttempt.setTrackingUrlToRMAppPage();
-
         new FinalTransition(RMAppAttemptState.FAILED).transition(
         new FinalTransition(RMAppAttemptState.FAILED).transition(
             appAttempt, containerFinishedEvent);
             appAttempt, containerFinishedEvent);
         return RMAppAttemptState.FAILED;
         return RMAppAttemptState.FAILED;

+ 20 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java

@@ -538,6 +538,26 @@ public class TestRMAppAttemptTransitions {
     assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
     assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
   }
   }
 
 
+  @Test
+  public void testRunningToKilled() {
+    Container amContainer = allocateApplicationAttempt();
+    launchApplicationAttempt(amContainer);
+    runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl");
+    applicationAttempt.handle(
+        new RMAppAttemptEvent(
+            applicationAttempt.getAppAttemptId(),
+            RMAppAttemptEventType.KILL));
+    assertEquals(RMAppAttemptState.KILLED,
+        applicationAttempt.getAppAttemptState());
+    assertEquals(0,applicationAttempt.getJustFinishedContainers().size());
+    assertEquals(amContainer, applicationAttempt.getMasterContainer());
+    assertEquals(0, applicationAttempt.getRanNodes().size());
+    String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
+        applicationAttempt.getAppAttemptId().getApplicationId());
+    assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
+    assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
+  }
+
   @Test(timeout=10000)
   @Test(timeout=10000)
   public void testLaunchedExpire() {
   public void testLaunchedExpire() {
     Container amContainer = allocateApplicationAttempt();
     Container amContainer = allocateApplicationAttempt();