Java Code Examples for org.apache.hadoop.yarn.api.records.ApplicationReport#setFinishTime()

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationReport#setFinishTime() . 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: AbstractYarnClusterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private ApplicationReport createApplicationReport(
	ApplicationId applicationId,
	YarnApplicationState yarnApplicationState,
	FinalApplicationStatus finalApplicationStatus) {

	ApplicationReport applicationReport = Records.newRecord(ApplicationReport.class);
	applicationReport.setApplicationId(applicationId);
	applicationReport.setCurrentApplicationAttemptId(ApplicationAttemptId.newInstance(applicationId, 0));
	applicationReport.setUser("user");
	applicationReport.setQueue("queue");
	applicationReport.setName("name");
	applicationReport.setHost("localhost");
	applicationReport.setRpcPort(42);
	applicationReport.setYarnApplicationState(yarnApplicationState);
	applicationReport.setStartTime(1L);
	applicationReport.setFinishTime(2L);
	applicationReport.setFinalApplicationStatus(finalApplicationStatus);
	applicationReport.setProgress(1.0f);
	return applicationReport;
}
 
Example 2
Source File: NotRunningJob.java    From tez with Apache License 2.0 6 votes vote down vote up
private ApplicationReport getUnknownApplicationReport() {
  ApplicationId unknownAppId = recordFactory
      .newRecordInstance(ApplicationId.class);
  ApplicationAttemptId unknownAttemptId = recordFactory
      .newRecordInstance(ApplicationAttemptId.class);

  ApplicationReport report = recordFactory.newRecordInstance(ApplicationReport.class);
  report.setApplicationId(unknownAppId);
  report.setCurrentApplicationAttemptId(unknownAttemptId);
  report.setUser("N/A");
  report.setName("N/A");
  report.setDiagnostics("N/A");
  report.setTrackingUrl("N/A");
  report.setStartTime(0);
  report.setFinishTime(0);
  return report;
}
 
Example 3
Source File: BuilderUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: TestClientRedirect.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 5
Source File: TestTypeConverter.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 6
Source File: BuilderUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: TestClientRedirect.java    From big-c with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: TestTypeConverter.java    From big-c with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 9
Source File: LocalClient.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationReport getApplicationReport(ApplicationId appId) {
  ApplicationReport report = Records.newRecord(ApplicationReport.class);
  report.setApplicationId(appId);
  report.setCurrentApplicationAttemptId(dagAppMaster.getAttemptID());

  AppContext runningAppContext = dagAppMaster.getContext();
  if (runningAppContext != null) {
    DAG dag = runningAppContext.getCurrentDAG();
    if (dag != null) {
      report.setUser(runningAppContext.getUser());
    }
    report.setName(runningAppContext.getApplicationName());
    report.setStartTime(runningAppContext.getStartTime());
  }

  report.setHost(dagAppMaster.getAppNMHost());
  report.setRpcPort(dagAppMaster.getRpcPort());
  report.setClientToAMToken(null);
  report.setYarnApplicationState(convertDAGAppMasterState(dagAppMaster.getState()));
  report.setFinalApplicationStatus(convertDAGAppMasterStateToFinalYARNState(dagAppMaster.getState()));


  List<String> diagnostics = dagAppMaster.getDiagnostics();
  if (diagnostics != null) {
    report.setDiagnostics(diagnostics.toString());
  }
  report.setTrackingUrl("N/A");
  report.setFinishTime(0);
  report.setApplicationResourceUsageReport(null);
  report.setOriginalTrackingUrl("N/A");
  report.setProgress(dagAppMaster.getProgress());
  report.setAMRMToken(null);

  return report;
}