Search in sources :

Example 26 with JobReport

use of org.apache.hadoop.mapreduce.v2.api.records.JobReport in project hadoop by apache.

the class TestJobInfo method testGetStartTimeStr.

@Test
public void testGetStartTimeStr() {
    JobReport jobReport = mock(JobReport.class);
    when(jobReport.getStartTime()).thenReturn(-1L);
    Job job = mock(Job.class);
    when(job.getReport()).thenReturn(jobReport);
    when(job.getName()).thenReturn("TestJobInfo");
    when(job.getState()).thenReturn(JobState.SUCCEEDED);
    JobId jobId = MRBuilderUtils.newJobId(1L, 1, 1);
    when(job.getID()).thenReturn(jobId);
    JobInfo jobInfo = new JobInfo(job);
    Assert.assertEquals(JobInfo.NA, jobInfo.getStartTimeStr());
    Date date = new Date();
    when(jobReport.getStartTime()).thenReturn(date.getTime());
    jobInfo = new JobInfo(job);
    Assert.assertEquals(date.toString(), jobInfo.getStartTimeStr());
}
Also used : CompletedJob(org.apache.hadoop.mapreduce.v2.hs.CompletedJob) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) Date(java.util.Date) JobReport(org.apache.hadoop.mapreduce.v2.api.records.JobReport) Test(org.junit.Test)

Example 27 with JobReport

use of org.apache.hadoop.mapreduce.v2.api.records.JobReport in project hadoop by apache.

the class NotRunningJob method getJobReport.

@Override
public GetJobReportResponse getJobReport(GetJobReportRequest request) throws IOException {
    JobReport jobReport = recordFactory.newRecordInstance(JobReport.class);
    jobReport.setJobId(request.getJobId());
    jobReport.setJobState(jobState);
    jobReport.setUser(applicationReport.getUser());
    jobReport.setStartTime(applicationReport.getStartTime());
    YarnApplicationState state = applicationReport.getYarnApplicationState();
    if (state == YarnApplicationState.KILLED || state == YarnApplicationState.FAILED || state == YarnApplicationState.FINISHED) {
        jobReport.setDiagnostics(applicationReport.getDiagnostics());
    }
    jobReport.setJobName(applicationReport.getName());
    jobReport.setTrackingUrl(applicationReport.getTrackingUrl());
    jobReport.setFinishTime(applicationReport.getFinishTime());
    GetJobReportResponse resp = recordFactory.newRecordInstance(GetJobReportResponse.class);
    resp.setJobReport(jobReport);
    return resp;
}
Also used : YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) JobReport(org.apache.hadoop.mapreduce.v2.api.records.JobReport) GetJobReportResponse(org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse)

Example 28 with JobReport

use of org.apache.hadoop.mapreduce.v2.api.records.JobReport in project hadoop by apache.

the class TestClientServiceDelegate method getJobReportResponseFromHistoryServer.

private GetJobReportResponse getJobReportResponseFromHistoryServer() {
    GetJobReportResponse jobReportResponse = Records.newRecord(GetJobReportResponse.class);
    JobReport jobReport = Records.newRecord(JobReport.class);
    jobReport.setJobId(jobId);
    jobReport.setJobState(JobState.SUCCEEDED);
    jobReport.setMapProgress(1.0f);
    jobReport.setReduceProgress(1.0f);
    jobReport.setJobFile("TestJobFilePath");
    jobReport.setTrackingUrl("http://TestTrackingUrl");
    jobReportResponse.setJobReport(jobReport);
    return jobReportResponse;
}
Also used : GetJobReportResponse(org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse) JobReport(org.apache.hadoop.mapreduce.v2.api.records.JobReport)

Example 29 with JobReport

use of org.apache.hadoop.mapreduce.v2.api.records.JobReport in project hadoop by apache.

the class TestMRJobsWithHistoryService method verifyJobReport.

private void verifyJobReport(JobReport jobReport, JobId jobId) {
    List<AMInfo> amInfos = jobReport.getAMInfos();
    Assert.assertEquals(1, amInfos.size());
    AMInfo amInfo = amInfos.get(0);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(jobId.getAppId(), 1);
    ContainerId amContainerId = ContainerId.newContainerId(appAttemptId, 1);
    Assert.assertEquals(appAttemptId, amInfo.getAppAttemptId());
    Assert.assertEquals(amContainerId, amInfo.getContainerId());
    Assert.assertTrue(jobReport.getSubmitTime() > 0);
    Assert.assertTrue(jobReport.getStartTime() > 0 && jobReport.getStartTime() >= jobReport.getSubmitTime());
    Assert.assertTrue(jobReport.getFinishTime() > 0 && jobReport.getFinishTime() >= jobReport.getStartTime());
}
Also used : AMInfo(org.apache.hadoop.mapreduce.v2.api.records.AMInfo) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId)

Aggregations

JobReport (org.apache.hadoop.mapreduce.v2.api.records.JobReport)26 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)9 Test (org.junit.Test)9 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)8 GetJobReportResponse (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse)5 GetJobReportRequest (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportRequest)4 AMInfo (org.apache.hadoop.mapreduce.v2.api.records.AMInfo)4 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)4 TaskAttemptReport (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptReport)3 TaskAttempt (org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt)3 CompletedJob (org.apache.hadoop.mapreduce.v2.hs.CompletedJob)3 IOException (java.io.IOException)2 Date (java.util.Date)2 Configuration (org.apache.hadoop.conf.Configuration)2 Counters (org.apache.hadoop.mapreduce.Counters)2 GetTaskAttemptReportRequest (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetTaskAttemptReportRequest)2 JobState (org.apache.hadoop.mapreduce.v2.api.records.JobState)2 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)2 TaskReport (org.apache.hadoop.mapreduce.v2.api.records.TaskReport)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2