[30/66] [abbrv] hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-20 Thread inigoiri
YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi


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

Branch: refs/heads/HDFS-13532
Commit: 69b05968974994c6e22d6562a67b9392d1700094
Parents: 7566e0e
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:05:52 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/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 578273c..82fadae 100644
--- 

[34/49] hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-15 Thread gifuma
YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi


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

Branch: refs/heads/HADOOP-15461
Commit: 69b05968974994c6e22d6562a67b9392d1700094
Parents: 7566e0e
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:05:52 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/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 578273c..82fadae 100644
--- 

[37/50] [abbrv] hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-14 Thread xkrogen
YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi


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

Branch: refs/heads/HDFS-12943
Commit: 69b05968974994c6e22d6562a67b9392d1700094
Parents: 7566e0e
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:05:52 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/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 578273c..82fadae 100644
--- 

[46/50] [abbrv] hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-14 Thread stevel
YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi


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

Branch: refs/heads/HADOOP-15407
Commit: 69b05968974994c6e22d6562a67b9392d1700094
Parents: 7566e0e
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:05:52 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/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 578273c..82fadae 100644
--- 

[45/50] [abbrv] hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-14 Thread arp
YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi


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

Branch: refs/heads/HDDS-48
Commit: 69b05968974994c6e22d6562a67b9392d1700094
Parents: 7566e0e
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:05:52 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/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 578273c..82fadae 100644
--- 

hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-13 Thread eyang
Repository: hadoop
Updated Branches:
  refs/heads/branch-3.1 5c1248b2d -> aba67c360


YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi

(cherry picked from commit 69b05968974994c6e22d6562a67b9392d1700094)


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

Branch: refs/heads/branch-3.1
Commit: aba67c360c3082ed82154d70afca7c150829bb73
Parents: 5c1248b
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:10:13 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/aba67c36/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/aba67c36/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
 

hadoop git commit: YARN-8411. Restart stopped system service during RM start. Contributed by Billie Rinaldi

2018-06-13 Thread eyang
Repository: hadoop
Updated Branches:
  refs/heads/trunk 7566e0ec5 -> 69b059689


YARN-8411.  Restart stopped system service during RM start.
Contributed by Billie Rinaldi


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

Branch: refs/heads/trunk
Commit: 69b05968974994c6e22d6562a67b9392d1700094
Parents: 7566e0e
Author: Eric Yang 
Authored: Wed Jun 13 19:05:52 2018 -0400
Committer: Eric Yang 
Committed: Wed Jun 13 19:05:52 2018 -0400

--
 .../client/SystemServiceManagerImpl.java| 29 --
 .../hadoop/yarn/service/webapp/ApiServer.java   |  3 +-
 .../hadoop/yarn/service/ServiceClientTest.java  |  4 +-
 .../client/TestSystemServiceManagerImpl.java| 40 +---
 .../yarn/service/client/ServiceClient.java  | 14 +--
 5 files changed, 72 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
index f9cfa92..08ad1b6 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/client/SystemServiceManagerImpl.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/client/SystemServiceManagerImpl.java
@@ -29,7 +29,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.server.service.SystemServiceManager;
 import org.apache.hadoop.yarn.service.api.records.Service;
 import org.apache.hadoop.yarn.service.api.records.ServiceState;
+import org.apache.hadoop.yarn.service.conf.SliderExitCodes;
 import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
+import org.apache.hadoop.yarn.service.exceptions.SliderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -228,12 +230,31 @@ public class SystemServiceManagerImpl extends 
AbstractService
   userUgi.doAs(new PrivilegedExceptionAction() {
 @Override public ApplicationId run()
 throws IOException, YarnException {
-  ApplicationId applicationId = 
serviceClient.actionCreate(service);
-  return applicationId;
+  boolean tryStart = true;
+  try {
+serviceClient.actionBuild(service);
+  } catch (Exception e) {
+if (e instanceof SliderException && ((SliderException) e)
+.getExitCode() == SliderExitCodes.EXIT_INSTANCE_EXISTS) {
+  LOG.info("Service {} already exists, will attempt to start " 
+
+  "service", service.getName());
+} else {
+  tryStart = false;
+  LOG.info("Got exception saving {}, will not attempt to " +
+  "start service", service.getName(), e);
+}
+  }
+  if (tryStart) {
+return serviceClient.actionStartAndGetId(service.getName());
+  } else {
+return null;
+  }
 }
   });
-  LOG.info("Service {} submitted with Application ID: {}",
-  service.getName(), applicationId);
+  if (applicationId != null) {
+LOG.info("Service {} submitted with Application ID: {}",
+service.getName(), applicationId);
+  }
 }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/69b05968/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