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,
|
private Response startService(String appName,
|
||||||
final UserGroupInformation ugi) throws IOException,
|
final UserGroupInformation ugi) throws IOException,
|
||||||
InterruptedException {
|
InterruptedException {
|
||||||
ugi.doAs(new PrivilegedExceptionAction<Void>() {
|
ApplicationId appId =
|
||||||
@Override
|
ugi.doAs(new PrivilegedExceptionAction<ApplicationId>() {
|
||||||
public Void run() throws YarnException, IOException {
|
@Override public ApplicationId run()
|
||||||
ServiceClient sc = getServiceClient();
|
throws YarnException, IOException {
|
||||||
sc.init(YARN_CONFIG);
|
ServiceClient sc = getServiceClient();
|
||||||
sc.start();
|
sc.init(YARN_CONFIG);
|
||||||
sc.actionStart(appName);
|
sc.start();
|
||||||
sc.close();
|
sc.actionStart(appName);
|
||||||
return null;
|
ApplicationId appId = sc.getAppId(appName);
|
||||||
}
|
sc.close();
|
||||||
});
|
return appId;
|
||||||
|
}
|
||||||
|
});
|
||||||
LOG.info("Successfully started service " + appName);
|
LOG.info("Successfully started service " + appName);
|
||||||
ServiceStatus status = new ServiceStatus();
|
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);
|
status.setState(ServiceState.ACCEPTED);
|
||||||
return formatResponse(Status.OK, status);
|
return formatResponse(Status.OK, status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,10 @@ import org.apache.hadoop.yarn.service.utils.SliderFileSystem;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -50,6 +52,8 @@ public class ServiceClientTest extends ServiceClient {
|
||||||
private Service goodServiceStatus = buildLiveGoodService();
|
private Service goodServiceStatus = buildLiveGoodService();
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private Set<String> expectedInstances = new HashSet<>();
|
private Set<String> expectedInstances = new HashSet<>();
|
||||||
|
private Map<String, ApplicationId> serviceAppId = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public ServiceClientTest() {
|
public ServiceClientTest() {
|
||||||
super();
|
super();
|
||||||
|
@ -83,7 +87,10 @@ public class ServiceClientTest extends ServiceClient {
|
||||||
public ApplicationId actionCreate(Service service) throws IOException {
|
public ApplicationId actionCreate(Service service) throws IOException {
|
||||||
ServiceApiUtil.validateAndResolveService(service,
|
ServiceApiUtil.validateAndResolveService(service,
|
||||||
new SliderFileSystem(conf), getConfig());
|
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
|
@Override
|
||||||
|
@ -99,6 +106,9 @@ public class ServiceClientTest extends ServiceClient {
|
||||||
public int actionStart(String serviceName)
|
public int actionStart(String serviceName)
|
||||||
throws YarnException, IOException {
|
throws YarnException, IOException {
|
||||||
if (serviceName != null && serviceName.equals("jenkins")) {
|
if (serviceName != null && serviceName.equals("jenkins")) {
|
||||||
|
ApplicationId appId =
|
||||||
|
ApplicationId.newInstance(System.currentTimeMillis(), 1);
|
||||||
|
serviceAppId.put(serviceName, appId);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
throw new ApplicationNotFoundException("");
|
throw new ApplicationNotFoundException("");
|
||||||
|
@ -207,4 +217,10 @@ public class ServiceClientTest extends ServiceClient {
|
||||||
comp.setContainers(containers);
|
comp.setContainers(containers);
|
||||||
return service;
|
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;
|
// see if it is actually running and bail out;
|
||||||
verifyNoLiveAppInRM(serviceName, "start");
|
verifyNoLiveAppInRM(serviceName, "start");
|
||||||
ApplicationId appId = submitApp(service);
|
ApplicationId appId = submitApp(service);
|
||||||
|
cachedAppInfo.put(serviceName, new AppInfo(appId, service
|
||||||
|
.getKerberosPrincipal().getPrincipalName()));
|
||||||
service.setId(appId.toString());
|
service.setId(appId.toString());
|
||||||
// write app definition on to hdfs
|
// write app definition on to hdfs
|
||||||
Path appJson = ServiceApiUtil.writeAppDefinition(fs, appDir, service);
|
Path appJson = ServiceApiUtil.writeAppDefinition(fs, appDir, service);
|
||||||
|
|
Loading…
Reference in New Issue