hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravip...@apache.org
Subject svn commit: r1574406 - in /hadoop/common/branches/branch-2.4/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/
Date Wed, 05 Mar 2014 09:48:05 GMT
Author: raviprak
Date: Wed Mar  5 09:48:04 2014
New Revision: 1574406

URL: http://svn.apache.org/r1574406
Log:
YARN-1768. Fixed error message being too verbose when killing a non-existent application.
Contributed by Tsuyoshi Ozawa

Modified:
    hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt
    hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
    hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java

Modified: hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt?rev=1574406&r1=1574405&r2=1574406&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt Wed Mar  5 09:48:04
2014
@@ -352,6 +352,9 @@ Release 2.4.0 - UNRELEASED
 
     YARN-1766. Fixed a bug in ResourceManager to use configuration loaded from the
     configuration-provider when booting up. (Xuan Gong via vinodkv)
+
+    YARN-1768. Fixed error message being too verbose when killing a non-existent
+    application
     
 
 Release 2.3.1 - UNRELEASED

Modified: hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java?rev=1574406&r1=1574405&r2=1574406&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
(original)
+++ hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
Wed Mar  5 09:48:04 2014
@@ -40,6 +40,7 @@ import org.apache.hadoop.yarn.api.record
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ContainerReport;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.util.ConverterUtils;
 
@@ -208,7 +209,11 @@ public class ApplicationCLI extends Yarn
         printUsage(opts);
         return exitCode;
       }
-      killApplication(cliParser.getOptionValue(KILL_CMD));
+      try{
+        killApplication(cliParser.getOptionValue(KILL_CMD));
+      } catch (ApplicationNotFoundException e) {
+        return exitCode;
+      }
     } else if (cliParser.hasOption(MOVE_TO_QUEUE_CMD)) {
       if (!cliParser.hasOption(QUEUE_CMD)) {
         printUsage(opts);
@@ -370,7 +375,15 @@ public class ApplicationCLI extends Yarn
   private void killApplication(String applicationId) throws YarnException,
       IOException {
     ApplicationId appId = ConverterUtils.toApplicationId(applicationId);
-    ApplicationReport appReport = client.getApplicationReport(appId);
+    ApplicationReport  appReport = null;
+    try {
+      appReport = client.getApplicationReport(appId);
+    } catch (ApplicationNotFoundException e) {
+      sysout.println("Application with id '" + applicationId +
+          "' doesn't exist in RM.");
+      throw e;
+    }
+
     if (appReport.getYarnApplicationState() == YarnApplicationState.FINISHED
         || appReport.getYarnApplicationState() == YarnApplicationState.KILLED
         || appReport.getYarnApplicationState() == YarnApplicationState.FAILED) {
@@ -380,7 +393,7 @@ public class ApplicationCLI extends Yarn
       client.killApplication(appId);
     }
   }
-  
+
   /**
    * Moves the application with the given ID to the given queue.
    */
@@ -470,12 +483,12 @@ public class ApplicationCLI extends Yarn
    * @throws YarnException
    * @throws IOException
    */
-  private void listApplicationAttempts(String appId) throws YarnException,
+  private void listApplicationAttempts(String applicationId) throws YarnException,
       IOException {
     PrintWriter writer = new PrintWriter(sysout);
 
     List<ApplicationAttemptReport> appAttemptsReport = client
-        .getApplicationAttempts(ConverterUtils.toApplicationId(appId));
+        .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId));
     writer.println("Total number of application attempts " + ":"
         + appAttemptsReport.size());
     writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id",

Modified: hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java?rev=1574406&r1=1574405&r2=1574406&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
(original)
+++ hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
Wed Mar  5 09:48:04 2014
@@ -740,12 +740,16 @@ public class TestYarnCLI {
         .getApplicationReport(applicationId);
     cli = createAndGetAppCLI();
     try {
-      cli.run(new String[] { "application","-kill", applicationId.toString() });
-      Assert.fail();
-    } catch (Exception ex) {
-      Assert.assertTrue(ex instanceof ApplicationNotFoundException);
-      Assert.assertEquals("Application with id '" + applicationId +
-          "' doesn't exist in RM.", ex.getMessage());
+      int exitCode =
+          cli.run(new String[] { "application","-kill", applicationId.toString() });
+      verify(sysOut).println("Application with id '" + applicationId +
+              "' doesn't exist in RM.");
+      Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
+    } catch (ApplicationNotFoundException appEx) {
+      Assert.fail("application -kill should not throw" +
+          "ApplicationNotFoundException. " + appEx);
+    } catch (Exception e) {
+      Assert.fail("Unexpected exception: " + e);
     }
   }
   



Mime
View raw message