本文整理汇总了Java中org.apache.hadoop.yarn.api.records.ApplicationReport.setApplicationId方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationReport.setApplicationId方法的具体用法?Java ApplicationReport.setApplicationId怎么用?Java ApplicationReport.setApplicationId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.api.records.ApplicationReport
的用法示例。
在下文中一共展示了ApplicationReport.setApplicationId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
@Test
public void testApplicationReport() {
long timestamp = System.currentTimeMillis();
ApplicationReport appReport1 =
createApplicationReport(1, 1, timestamp);
ApplicationReport appReport2 =
createApplicationReport(1, 1, timestamp);
ApplicationReport appReport3 =
createApplicationReport(1, 1, timestamp);
Assert.assertEquals(appReport1, appReport2);
Assert.assertEquals(appReport2, appReport3);
appReport1.setApplicationId(null);
Assert.assertNull(appReport1.getApplicationId());
Assert.assertNotSame(appReport1, appReport2);
appReport2.setCurrentApplicationAttemptId(null);
Assert.assertNull(appReport2.getCurrentApplicationAttemptId());
Assert.assertNotSame(appReport2, appReport3);
Assert.assertNull(appReport1.getAMRMToken());
}
示例2: getDefaultApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
private ApplicationReport getDefaultApplicationReport(ApplicationId appId) {
ApplicationReport result = new ApplicationReportPBImpl();
result.setApplicationId(appId);
result.setOriginalTrackingUrl("localhost:" + originalPort + "/foo/bar");
result.setYarnApplicationState(YarnApplicationState.RUNNING);
result.setUser(CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER);
return result;
}
示例3: newApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
public static ApplicationReport newApplicationReport(
ApplicationId applicationId, ApplicationAttemptId applicationAttemptId,
String user, String queue, String name, String host, int rpcPort,
Token clientToAMToken, YarnApplicationState state, String diagnostics,
String url, long startTime, long finishTime,
FinalApplicationStatus finalStatus,
ApplicationResourceUsageReport appResources, String origTrackingUrl,
float progress, String appType, Token amRmToken, Set<String> tags) {
ApplicationReport report = recordFactory
.newRecordInstance(ApplicationReport.class);
report.setApplicationId(applicationId);
report.setCurrentApplicationAttemptId(applicationAttemptId);
report.setUser(user);
report.setQueue(queue);
report.setName(name);
report.setHost(host);
report.setRpcPort(rpcPort);
report.setClientToAMToken(clientToAMToken);
report.setYarnApplicationState(state);
report.setDiagnostics(diagnostics);
report.setTrackingUrl(url);
report.setStartTime(startTime);
report.setFinishTime(finishTime);
report.setFinalApplicationStatus(finalStatus);
report.setApplicationResourceUsageReport(appResources);
report.setOriginalTrackingUrl(origTrackingUrl);
report.setProgress(progress);
report.setApplicationType(appType);
report.setAMRMToken(amRmToken);
report.setApplicationTags(tags);
return report;
}
示例4: getApplicationReport
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
@Override
public GetApplicationReportResponse getApplicationReport(
GetApplicationReportRequest request) throws IOException {
ApplicationId applicationId = request.getApplicationId();
ApplicationReport application = recordFactory
.newRecordInstance(ApplicationReport.class);
application.setApplicationId(applicationId);
application.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
if (amRunning) {
application.setYarnApplicationState(YarnApplicationState.RUNNING);
} else if (amRestarting) {
application.setYarnApplicationState(YarnApplicationState.SUBMITTED);
} else {
application.setYarnApplicationState(YarnApplicationState.FINISHED);
application.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
}
String[] split = AMHOSTADDRESS.split(":");
application.setHost(split[0]);
application.setRpcPort(Integer.parseInt(split[1]));
application.setUser("TestClientRedirect-user");
application.setName("N/A");
application.setQueue("N/A");
application.setStartTime(0);
application.setFinishTime(0);
application.setTrackingUrl("N/A");
application.setDiagnostics("N/A");
GetApplicationReportResponse response = recordFactory
.newRecordInstance(GetApplicationReportResponse.class);
response.setApplicationReport(application);
return response;
}
示例5: testFromYarn
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
@Test
public void testFromYarn() throws Exception {
int appStartTime = 612354;
int appFinishTime = 612355;
YarnApplicationState state = YarnApplicationState.RUNNING;
ApplicationId applicationId = ApplicationId.newInstance(0, 0);
ApplicationReport applicationReport = Records
.newRecord(ApplicationReport.class);
applicationReport.setApplicationId(applicationId);
applicationReport.setYarnApplicationState(state);
applicationReport.setStartTime(appStartTime);
applicationReport.setFinishTime(appFinishTime);
applicationReport.setUser("TestTypeConverter-user");
ApplicationResourceUsageReport appUsageRpt = Records
.newRecord(ApplicationResourceUsageReport.class);
Resource r = Records.newRecord(Resource.class);
r.setMemory(2048);
appUsageRpt.setNeededResources(r);
appUsageRpt.setNumReservedContainers(1);
appUsageRpt.setNumUsedContainers(3);
appUsageRpt.setReservedResources(r);
appUsageRpt.setUsedResources(r);
applicationReport.setApplicationResourceUsageReport(appUsageRpt);
JobStatus jobStatus = TypeConverter.fromYarn(applicationReport, "dummy-jobfile");
Assert.assertEquals(appStartTime, jobStatus.getStartTime());
Assert.assertEquals(appFinishTime, jobStatus.getFinishTime());
Assert.assertEquals(state.toString(), jobStatus.getState().toString());
}
示例6: getApplications
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
public List<ApplicationReport> getApplications(int id) {
String result = null;
String squeueCmd = conf.get(
HPCConfiguration.YARN_APPLICATION_HPC_COMMAND_SLURM_SQUEUE,
HPCConfiguration.DEFAULT_YARN_APPLICATION_HPC_COMMAND_SLURM_SQUEUE);
List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
try {
String argJ = id < 0 ? "" : "-j " + id;
result = Shell.execCommand(squeueCmd, "-h", argJ, "-o %i %P %j %u %k");
String[] resultLines = result.split("\\n");
for (String line : resultLines) {
if (line == null || line.length() == 0) {
return applications;
}
String[] lineParts = line.trim().split("\\s+");
if (!("YarnMaster".equals(lineParts[2]) && StringUtils
.isNotEmpty(lineParts[4])))
continue;
String[] addr = lineParts[4].split(":");
if (addr.length != 3)
continue;
ApplicationReport appReport = Records
.newRecord(ApplicationReport.class);
int jobid = Integer.parseInt(lineParts[0]);
ApplicationId applicationId = ApplicationId.newInstance(
getClusterTimestamp(), jobid);
appReport.setApplicationId(applicationId);
appReport.setTrackingUrl("");
appReport.setQueue(lineParts[1]);
appReport.setName(lineParts[2]);
appReport.setUser(lineParts[3]);
appReport.setHost(addr[1]);
appReport.setRpcPort(Integer.parseInt(addr[2]));
String stateStr = addr[0].toUpperCase();
YarnApplicationState state = YarnApplicationState.valueOf(stateStr);
appReport.setYarnApplicationState(state);
if (state == YarnApplicationState.FINISHED) {
appReport.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
}else{
appReport.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
}
applications.add(appReport);
}
} catch (Throwable t) {
throw new YarnRuntimeException(result, t);
}
return applications;
}
示例7: getApplications
import org.apache.hadoop.yarn.api.records.ApplicationReport; //导入方法依赖的package包/类
@Override
public List<ApplicationReport> getApplications() throws IOException {
List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
String qstatCmd = conf.get(
HPCConfiguration.YARN_APPLICATION_HPC_COMMAND_PBS_QSTAT,
HPCConfiguration.DEFAULT_YARN_APPLICATION_HPC_COMMAND_PBS_QSTAT);
String result = Shell.execCommand(qstatCmd);
String[] resultLines = result.split("\\n");
if (resultLines.length > 2) {
for (int i = 2; i < resultLines.length; i++) {
String[] lineParts = resultLines[i].trim().split("\\s+");
if (lineParts.length > 5 && lineParts[1].startsWith("Y#")) {
// If it is an YARN application
Matcher matcher = Pattern.compile("(\\d+)").matcher(lineParts[0]);
if (!matcher.find()) {
LOG.info("Could not get Job Id from " + result);
continue;
}
ApplicationReport report = Records.newRecord(ApplicationReport.class);
int jobId = Integer.parseInt(matcher.group(1));
String name = lineParts[1].substring(2);
String user = lineParts[2];
String state = lineParts[4];
String queue = lineParts[5];
report.setApplicationId(ApplicationId.newInstance(
HPCUtils.getClusterTimestamp(), jobId));
report.setName(name);
report.setUser(user);
report.setQueue(queue);
if ("R".equals(state) || "T".equals(state) || "W".equals(state)
|| "S".equals(state)) {
report.setYarnApplicationState(YarnApplicationState.RUNNING);
report.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
} else if ("E".equals(state)) {
report.setYarnApplicationState(YarnApplicationState.FINISHED);
report.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
} else {
report.setYarnApplicationState(YarnApplicationState.SUBMITTED);
report.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
}
applications.add(report);
}
}
}
return applications;
}