Java Code Examples for org.apache.hadoop.yarn.api.records.ApplicationId#fromString()
The following examples show how to use
org.apache.hadoop.yarn.api.records.ApplicationId#fromString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YarnServiceJobSubmitter.java From submarine with Apache License 2.0 | 5 votes |
private ApplicationId submitJobInternal(Service serviceSpec) throws IOException, YarnException { String serviceSpecFile = ServiceSpecFileGenerator.generateJson(serviceSpec); AppAdminClient appAdminClient = YarnServiceUtils.createServiceClient(clientContext.getYarnConfig()); int code = appAdminClient.actionLaunch(serviceSpecFile, serviceSpec.getName(), null, null); if (code != EXIT_SUCCESS) { throw new YarnException( "Fail to launch application with exit code:" + code); } String appStatus = appAdminClient.getStatusString(serviceSpec.getName()); Service app = ServiceApiUtil.jsonSerDeser.fromJson(appStatus); // Retry multiple times if applicationId is null int maxRetryTimes = 30; int count = 0; while (app.getId() == null && count < maxRetryTimes) { LOG.info("Waiting for application Id. AppStatusString=\n {}", appStatus); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new IOException(e); } appStatus = appAdminClient.getStatusString(serviceSpec.getName()); app = ServiceApiUtil.jsonSerDeser.fromJson(appStatus); count++; } // Retry timeout if (app.getId() == null) { throw new YarnException( "Can't get application id for Service " + serviceSpec.getName()); } ApplicationId appid = ApplicationId.fromString(app.getId()); appAdminClient.stop(); return appid; }
Example 2
Source File: EmrClusterJob.java From datacollector with Apache License 2.0 | 5 votes |
@Override public void terminateJob(Properties jobProps) throws IOException { String appIdStr = Utils.checkNotNull(jobProps.getProperty("appId"), null); if (appIdStr == null) { throw new IOException("appId not present in jobProps"); } YarnClient yarnClient = getYarnClient(new EMRJobConfig(jobProps).getClusterId(), emrClusterConfig); ApplicationId appId = ApplicationId.fromString(appIdStr); try { yarnClient.killApplication(appId); } catch (YarnException ex) { throw new IOException("Failed to terminate yarn job " + ex); } }