YARN-8368. yarn app start cli should print applicationId. Contributed by Rohith Sharma K S
(cherry picked from commit 96eefcc84a
)
This commit is contained in:
parent
3d06d75423
commit
7bd5d79177
|
@ -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 {
|
||||
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 null;
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue