hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject hadoop git commit: YARN-8368. yarn app start cli should print applicationId. Contributed by Rohith Sharma K S
Date Wed, 30 May 2018 20:01:39 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-3.1 3d06d7542 -> 7bd5d7917


YARN-8368. yarn app start cli should print applicationId. Contributed by Rohith Sharma K S

(cherry picked from commit 96eefcc84aacc4cc82ad7e3e72c5bdad56f4a7b7)


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

Branch: refs/heads/branch-3.1
Commit: 7bd5d79177c8b1c2d1c0fcc0220b88da3c06df6a
Parents: 3d06d75
Author: Billie Rinaldi <billie@apache.org>
Authored: Wed May 30 12:37:01 2018 -0700
Committer: Billie Rinaldi <billie@apache.org>
Committed: Wed May 30 12:38:53 2018 -0700

----------------------------------------------------------------------
 .../hadoop/yarn/service/webapp/ApiServer.java   | 28 +++++++++++---------
 .../hadoop/yarn/service/ServiceClientTest.java  | 18 ++++++++++++-
 .../yarn/service/client/ServiceClient.java      |  2 ++
 3 files changed, 35 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7bd5d791/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/webapp/ApiServer.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/webapp/ApiServer.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/webapp/ApiServer.java
index 46c9abe..578273c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/webapp/ApiServer.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/webapp/ApiServer.java
@@ -641,20 +641,24 @@ public class ApiServer {
   private Response startService(String appName,
       final UserGroupInformation ugi) throws IOException,
       InterruptedException {
-    ugi.doAs(new PrivilegedExceptionAction<Void>() {
-      @Override
-      public Void run() throws YarnException, IOException {
-        ServiceClient sc = getServiceClient();
-        sc.init(YARN_CONFIG);
-        sc.start();
-        sc.actionStart(appName);
-        sc.close();
-        return null;
-      }
-    });
+    ApplicationId appId =
+        ugi.doAs(new PrivilegedExceptionAction<ApplicationId>() {
+          @Override public ApplicationId run()
+              throws YarnException, IOException {
+            ServiceClient sc = getServiceClient();
+            sc.init(YARN_CONFIG);
+            sc.start();
+            sc.actionStart(appName);
+            ApplicationId appId = sc.getAppId(appName);
+            sc.close();
+            return appId;
+          }
+        });
     LOG.info("Successfully started service " + appName);
     ServiceStatus status = new ServiceStatus();
-    status.setDiagnostics("Service " + appName + " is successfully started.");
+    status.setDiagnostics(
+        "Service " + appName + " is successfully started with ApplicationId: "
+            + appId);
     status.setState(ServiceState.ACCEPTED);
     return formatResponse(Status.OK, status);
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7bd5d791/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/ServiceClientTest.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/ServiceClientTest.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/ServiceClientTest.java
index 75b9486..81be750 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/ServiceClientTest.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/ServiceClientTest.java
@@ -34,8 +34,10 @@ import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -50,6 +52,8 @@ public class ServiceClientTest extends ServiceClient {
   private Service goodServiceStatus = buildLiveGoodService();
   private boolean initialized;
   private Set<String> expectedInstances = new HashSet<>();
+  private Map<String, ApplicationId> serviceAppId = new HashMap<>();
+
 
   public ServiceClientTest() {
     super();
@@ -83,7 +87,10 @@ public class ServiceClientTest extends ServiceClient {
   public ApplicationId actionCreate(Service service) throws IOException {
     ServiceApiUtil.validateAndResolveService(service,
         new SliderFileSystem(conf), getConfig());
-    return ApplicationId.newInstance(System.currentTimeMillis(), 1);
+    ApplicationId appId =
+        ApplicationId.newInstance(System.currentTimeMillis(), 1);
+    serviceAppId.put(service.getName(), appId);
+    return appId;
   }
 
   @Override
@@ -99,6 +106,9 @@ public class ServiceClientTest extends ServiceClient {
   public int actionStart(String serviceName)
       throws YarnException, IOException {
     if (serviceName != null && serviceName.equals("jenkins")) {
+      ApplicationId appId =
+          ApplicationId.newInstance(System.currentTimeMillis(), 1);
+      serviceAppId.put(serviceName, appId);
       return EXIT_SUCCESS;
     } else {
       throw new ApplicationNotFoundException("");
@@ -207,4 +217,10 @@ public class ServiceClientTest extends ServiceClient {
     comp.setContainers(containers);
     return service;
   }
+
+  @Override
+  public synchronized ApplicationId getAppId(String serviceName)
+      throws IOException, YarnException {
+    return serviceAppId.get(serviceName);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7bd5d791/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java
index 0ab3322..e86ecbc 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/client/ServiceClient.java
@@ -978,6 +978,8 @@ public class ServiceClient extends AppAdminClient implements SliderExitCodes,
       // see if it is actually running and bail out;
       verifyNoLiveAppInRM(serviceName, "start");
       ApplicationId appId = submitApp(service);
+      cachedAppInfo.put(serviceName, new AppInfo(appId, service
+          .getKerberosPrincipal().getPrincipalName()));
       service.setId(appId.toString());
       // write app definition on to hdfs
       Path appJson = ServiceApiUtil.writeAppDefinition(fs, appDir, service);


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