hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gourks...@apache.org
Subject hadoop git commit: YARN-5769. Integrate update app lifetime using feature implemented in YARN-5611. Contributed by Jian He
Date Thu, 01 Dec 2016 07:27:29 GMT
Repository: hadoop
Updated Branches:
  refs/heads/yarn-native-services 9db05374a -> f32cf8f3b


YARN-5769. Integrate update app lifetime using feature implemented in YARN-5611. 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/f32cf8f3
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f32cf8f3
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f32cf8f3

Branch: refs/heads/yarn-native-services
Commit: f32cf8f3bf4c9f3fe0991bca2922c0768dcf8a50
Parents: 9db0537
Author: Gour Saha <gourksaha@apache.org>
Authored: Wed Nov 30 23:24:45 2016 -0800
Committer: Gour Saha <gourksaha@apache.org>
Committed: Wed Nov 30 23:24:45 2016 -0800

----------------------------------------------------------------------
 .../api/impl/ApplicationApiService.java         | 25 +++++++++++++--
 .../org/apache/slider/client/SliderClient.java  | 33 +++++++++++++++++---
 .../AbstractClusterBuildingActionArgs.java      |  3 +-
 3 files changed, 53 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f32cf8f3/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 6db69ac..c4f5d43 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
@@ -77,6 +77,7 @@ import org.apache.slider.common.params.ActionFreezeArgs;
 import org.apache.slider.common.params.ActionListArgs;
 import org.apache.slider.common.params.ActionRegistryArgs;
 import org.apache.slider.common.params.ActionThawArgs;
+import org.apache.slider.common.params.ActionUpdateArgs;
 import org.apache.slider.common.params.ComponentArgsDelegate;
 import org.apache.slider.common.tools.SliderUtils;
 import org.apache.slider.common.tools.SliderVersionInfo;
@@ -1398,14 +1399,34 @@ public class ApplicationApiService implements ApplicationApi {
     }
 
     // If new lifetime value specified then update it
-    if (updateAppData.getLifetime() != null) {
-      // TODO: Once YARN-3813 and YARN-4205 are available
+    if (updateAppData.getLifetime() != null
+        && updateAppData.getLifetime() > 0) {
+      try {
+        updateAppLifetime(appName, updateAppData.getLifetime());
+      } catch (Exception e) {
+        logger.error("Failed to update application (" + appName + ") lifetime ("
+            + updateAppData.getLifetime() + ")", e);
+        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
+      }
     }
 
     // If nothing happens consider it a no-op
     return Response.status(Status.NO_CONTENT).build();
   }
 
+  private Void updateAppLifetime(String appName, long lifetime)
+      throws InterruptedException, YarnException, IOException {
+    return invokeSliderClientRunnable(new SliderClientContextRunnable<Void>() {
+      @Override public Void run(SliderClient sliderClient)
+          throws YarnException, IOException, InterruptedException {
+        ActionUpdateArgs args = new ActionUpdateArgs();
+        args.lifetime = lifetime;
+        sliderClient.actionUpdate(appName, args);
+        return null;
+      }
+    });
+  }
+
   // create default component and initialize with app level global values
   private List<Component> getDefaultComponentAsList(Application app) {
     List<Component> comps = getDefaultComponentAsList();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f32cf8f3/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 3f2df0a..12f7870 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
@@ -52,6 +52,7 @@ import org.apache.hadoop.security.alias.CredentialProvider;
 import org.apache.hadoop.security.alias.CredentialProviderFactory;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.yarn.api.ApplicationConstants;
+import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
@@ -65,6 +66,7 @@ import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
 import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.util.ConverterUtils;
+import org.apache.hadoop.yarn.util.Times;
 import org.apache.slider.api.ClusterDescription;
 import org.apache.slider.api.ClusterNode;
 import org.apache.slider.api.SliderApplicationApi;
@@ -177,14 +179,12 @@ import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.BufferedReader;
 import java.io.Console;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.InterruptedIOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
@@ -1602,8 +1602,33 @@ public class SliderClient extends AbstractSliderLaunchedService implements
RunSe
   public int actionUpdate(String clustername,
       AbstractClusterBuildingActionArgs buildInfo) throws
       YarnException, IOException {
-    buildInstanceDefinition(clustername, buildInfo, true, true);
-    return EXIT_SUCCESS; 
+    if (buildInfo.lifetime > 0) {
+      updateLifetime(clustername, buildInfo.lifetime);
+    } else {
+      buildInstanceDefinition(clustername, buildInfo, true, true);
+    }
+    return EXIT_SUCCESS;
+  }
+
+  public void updateLifetime(String appName, long lifetime)
+      throws YarnException, IOException {
+    ApplicationReport report = findInstance(appName);
+    if (report == null) {
+      throw new YarnException("Application not found for " + appName);
+    }
+    ApplicationId appId = report.getApplicationId();
+    log.info("Updating lifetime of an application: appName = " + appName
+        + ", appId = " + appId+ ", lifetime = " + lifetime);
+    Map<ApplicationTimeoutType, String> map = new HashMap<>();
+    String newTimeout =
+        Times.formatISO8601(System.currentTimeMillis() + lifetime * 1000);
+    map.put(ApplicationTimeoutType.LIFETIME, newTimeout);
+    UpdateApplicationTimeoutsRequest request =
+        UpdateApplicationTimeoutsRequest.newInstance(appId, map);
+    yarnClient.updateApplicationTimeouts(request);
+    log.info("Successfully updated lifetime for an application: appName = "
+        + appName + ", appId = " + appId
+        + ". New expiry time in ISO8601 format is " + newTimeout);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f32cf8f3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AbstractClusterBuildingActionArgs.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/common/params/AbstractClusterBuildingActionArgs.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AbstractClusterBuildingActionArgs.java
index 3cb75e1..20a9989 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AbstractClusterBuildingActionArgs.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/common/params/AbstractClusterBuildingActionArgs.java
@@ -103,8 +103,7 @@ public abstract class AbstractClusterBuildingActionArgs extends
   public String queue;
 
   @Parameter(names = {ARG_LIFETIME},
-      description = "Life time of the application since application started at"
-          + " running state")
+      description = "Lifetime of the application from the time of request")
   public long lifetime;
 
   @ParametersDelegate


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