hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jia...@apache.org
Subject hadoop git commit: YARN-5812. Exception during GET call - "Failed to retrieve application: null". Contributed by Gour Saha
Date Wed, 02 Nov 2016 22:55:49 GMT
Repository: hadoop
Updated Branches:
  refs/heads/yarn-native-services 87f09be00 -> 2ec9e9dcd


YARN-5812. Exception during GET call - "Failed to retrieve application: null". Contributed
by Gour Saha


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2ec9e9dc
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2ec9e9dc
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2ec9e9dc

Branch: refs/heads/yarn-native-services
Commit: 2ec9e9dcdbc15794ca7f9a55177bc0cbf5e1b64d
Parents: 87f09be
Author: Jian He <jianhe@apache.org>
Authored: Wed Nov 2 15:55:48 2016 -0700
Committer: Jian He <jianhe@apache.org>
Committed: Wed Nov 2 15:56:09 2016 -0700

----------------------------------------------------------------------
 .../api/impl/ApplicationApiService.java         | 36 ++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2ec9e9dc/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/services/api/impl/ApplicationApiService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/services/api/impl/ApplicationApiService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/services/api/impl/ApplicationApiService.java
index 37bd134..6db69ac 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/services/api/impl/ApplicationApiService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/services/api/impl/ApplicationApiService.java
@@ -50,7 +50,6 @@ import javax.ws.rs.core.Response.Status;
 
 import org.apache.commons.lang.SerializationUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.fs.PathNotFoundException;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
@@ -905,6 +904,10 @@ public class ApplicationApiService implements ApplicationApi {
 
     // state
     String appState = jsonGetAsString(appStatus, "state");
+    if (appState == null) {
+      // consider that app is still in ACCEPTED state
+      appState = String.valueOf(StateValues.STATE_INCOMPLETE);
+    }
     switch (Integer.parseInt(appState)) {
       case StateValues.STATE_LIVE:
         app.setState(ApplicationState.STARTED);
@@ -1069,6 +1072,9 @@ public class ApplicationApiService implements ApplicationApi {
             String status = null;
             try {
               status = sliderClient.actionStatus(appName);
+            } catch (BadClusterStateException e) {
+              logger.warn("Application not running yet", e);
+              return EMPTY_JSON_OBJECT;
             } catch (Exception e) {
               logger.error("Exception calling slider.actionStatus", e);
               return EMPTY_JSON_OBJECT;
@@ -1097,7 +1103,7 @@ public class ApplicationApiService implements ApplicationApi {
             try {
               registry = sliderClient.actionRegistryGetConfig(registryArgs)
                 .asJson();
-            } catch (FileNotFoundException | PathNotFoundException e) {
+            } catch (FileNotFoundException | NotFoundException e) {
               // ignore and return empty object
               return EMPTY_JSON_OBJECT;
             } catch (Exception e) {
@@ -1192,23 +1198,33 @@ public class ApplicationApiService implements ApplicationApi {
     // little longer for it to stop from YARN point of view. Slider destroy
     // fails if the application is not completely stopped. Hence the need to
     // call destroy in a controlled loop few times (only if exit code is
-    // EXIT_APPLICATION_IN_USE), before giving up.
+    // EXIT_APPLICATION_IN_USE or EXIT_INSTANCE_EXISTS), before giving up.
     boolean keepTrying = true;
-    int maxDeleteAttempt = 5;
-    int deleteAttempt = 0;
-    while (keepTrying && deleteAttempt < maxDeleteAttempt) {
+    int maxDeleteAttempts = 5;
+    int deleteAttempts = 0;
+    int sleepIntervalInMillis = 500;
+    while (keepTrying && deleteAttempts < maxDeleteAttempts) {
       try {
         destroySliderApplication(appName);
         keepTrying = false;
       } catch (SliderException e) {
-        logger.error("Delete application threw exception", e);
-        if (e.getExitCode() == SliderExitCodes.EXIT_APPLICATION_IN_USE) {
-          deleteAttempt++;
+        if (e.getExitCode() == SliderExitCodes.EXIT_APPLICATION_IN_USE
+            || e.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+          deleteAttempts++;
+          // If we used up all the allowed delete attempts, let's log it as
+          // error before giving up. Otherwise log as warn.
+          if (deleteAttempts < maxDeleteAttempts) {
+            logger.warn("Application not in stopped state, waiting for {}ms"
+                + " before trying delete again", sleepIntervalInMillis);
+          } else {
+            logger.error("Delete application failed", e);
+          }
           try {
-            Thread.sleep(500);
+            Thread.sleep(sleepIntervalInMillis);
           } catch (InterruptedException e1) {
           }
         } else {
+          logger.error("Delete application threw exception", e);
           return Response.status(Status.INTERNAL_SERVER_ERROR).build();
         }
       } catch (Exception e) {


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message