hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jia...@apache.org
Subject [48/52] [abbrv] hadoop git commit: YARN-6617. Services API delete call first attempt usually fails. Contributed by Jian He
Date Fri, 21 Jul 2017 18:39:50 GMT
YARN-6617. Services API delete call first attempt usually fails. Contributed by Jian He


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

Branch: refs/heads/yarn-native-services
Commit: d6aeea32ec3cede617d33b3cfba8ae344fb594a5
Parents: eb98456
Author: Billie Rinaldi <billie@apache.org>
Authored: Fri May 26 12:15:28 2017 -0700
Committer: Jian He <jianhe@apache.org>
Committed: Fri Jul 21 11:38:14 2017 -0700

----------------------------------------------------------------------
 .../org/apache/slider/client/SliderClient.java  | 36 ++++++++++++++++----
 1 file changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/d6aeea32/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index 29ca471..a3ba8c0 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -230,6 +230,9 @@ public class SliderClient extends AbstractSliderLaunchedService implements
RunSe
   @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
   private RegistryOperations registryOperations;
 
+  private static EnumSet<YarnApplicationState> terminatedStates = EnumSet
+      .of(YarnApplicationState.FINISHED, YarnApplicationState.FAILED,
+          YarnApplicationState.KILLED);
   /**
    * Constructor
    */
@@ -699,7 +702,7 @@ public class SliderClient extends AbstractSliderLaunchedService implements
RunSe
     //TODO set retry window
     submissionContext.setResource(Resource.newInstance(
         conf.getLong(KEY_AM_RESOURCE_MEM, DEFAULT_KEY_AM_RESOURCE_MEM), 1));
-    submissionContext.setQueue(conf.get(KEY_YARN_QUEUE, DEFAULT_YARN_QUEUE));
+    submissionContext.setQueue(conf.get(KEY_YARN_QUEUE, app.getQueue()));
     submissionContext.setApplicationName(appName);
     submissionContext.setApplicationType(SliderKeys.APP_TYPE);
     Set<String> appTags =
@@ -1725,9 +1728,8 @@ public class SliderClient extends AbstractSliderLaunchedService implements
RunSe
           "Application " + appName + " doesn't exist in RM.");
     }
 
-    if (app.getYarnApplicationState().ordinal() >= YarnApplicationState.FINISHED
-        .ordinal()) {
-      log.info("Application {} is in a terminated state {}", appName,
+    if (terminatedStates.contains(app.getYarnApplicationState())) {
+      log.info("Application {} is already in a terminated state {}", appName,
           app.getYarnApplicationState());
       return EXIT_SUCCESS;
     }
@@ -1738,8 +1740,30 @@ public class SliderClient extends AbstractSliderLaunchedService implements
RunSe
           Messages.StopClusterRequestProto.newBuilder()
               .setMessage(freezeArgs.message).build();
       appMaster.stopCluster(r);
-      log.info("Application " + appName + " is gracefully stopped.");
-    } catch (IOException | YarnException e){
+      log.info("Application " + appName + " is being gracefully stopped...");
+      long startTime = System.currentTimeMillis();
+      int pollCount = 0;
+      while (true) {
+        Thread.sleep(200);
+        ApplicationReport report =
+            yarnClient.getApplicationReport(app.getApplicationId());
+        if (terminatedStates.contains(report.getYarnApplicationState())) {
+          log.info("Application " + appName + " is stopped.");
+          break;
+        }
+        // kill after 10 seconds.
+        if ((System.currentTimeMillis() - startTime) > 10000) {
+          log.info("Stop operation timeout stopping, forcefully kill the app "
+              + appName);
+          yarnClient
+              .killApplication(app.getApplicationId(), freezeArgs.message);
+          break;
+        }
+        if (++pollCount % 10 == 0) {
+          log.info("Waiting for application " + appName + " to be stopped.");
+        }
+      }
+    } catch (IOException | YarnException | InterruptedException e) {
       log.info("Failed to stop " + appName
           + " gracefully, forcefully kill the app.");
       yarnClient.killApplication(app.getApplicationId(), freezeArgs.message);


---------------------------------------------------------------------
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