MAPREDUCE-5674. Missing start and finish time in mapred.JobStatus. Contributed by Chuan Liu.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1550472 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2013-12-12 18:30:12 +00:00
parent 5fd7230671
commit ee0530ee0e
3 changed files with 32 additions and 0 deletions

View File

@ -290,6 +290,9 @@ Release 2.3.0 - UNRELEASED
event: TA_TOO_MANY_FETCH_FAILURE at KILLED for TaskAttemptImpl (Gera event: TA_TOO_MANY_FETCH_FAILURE at KILLED for TaskAttemptImpl (Gera
Shegalov via jlowe) Shegalov via jlowe)
MAPREDUCE-5674. Missing start and finish time in mapred.JobStatus.
(Chuan Liu via cnauroth)
Release 2.2.0 - 2013-10-13 Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -300,6 +300,8 @@ public class TypeConverter {
.getCleanupProgress(), fromYarn(jobreport.getJobState()), .getCleanupProgress(), fromYarn(jobreport.getJobState()),
jobPriority, jobreport.getUser(), jobreport.getJobName(), jobreport jobPriority, jobreport.getUser(), jobreport.getJobName(), jobreport
.getJobFile(), trackingUrl, jobreport.isUber()); .getJobFile(), trackingUrl, jobreport.isUber());
jobStatus.setStartTime(jobreport.getStartTime());
jobStatus.setFinishTime(jobreport.getFinishTime());
jobStatus.setFailureInfo(jobreport.getDiagnostics()); jobStatus.setFailureInfo(jobreport.getDiagnostics());
return jobStatus; return jobStatus;
} }
@ -441,6 +443,7 @@ public class TypeConverter {
); );
jobStatus.setSchedulingInfo(trackingUrl); // Set AM tracking url jobStatus.setSchedulingInfo(trackingUrl); // Set AM tracking url
jobStatus.setStartTime(application.getStartTime()); jobStatus.setStartTime(application.getStartTime());
jobStatus.setFinishTime(application.getFinishTime());
jobStatus.setFailureInfo(application.getDiagnostics()); jobStatus.setFailureInfo(application.getDiagnostics());
jobStatus.setNeededMem(application.getApplicationResourceUsageReport().getNeededResources().getMemory()); jobStatus.setNeededMem(application.getApplicationResourceUsageReport().getNeededResources().getMemory());
jobStatus.setNumReservedSlots(application.getApplicationResourceUsageReport().getNumReservedContainers()); jobStatus.setNumReservedSlots(application.getApplicationResourceUsageReport().getNumReservedContainers());

View File

@ -27,6 +27,8 @@ import junit.framework.Assert;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.JobStatus.State; import org.apache.hadoop.mapreduce.JobStatus.State;
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
import org.apache.hadoop.mapreduce.v2.api.records.JobReport;
import org.apache.hadoop.mapreduce.v2.api.records.JobState; import org.apache.hadoop.mapreduce.v2.api.records.JobState;
import org.apache.hadoop.mapreduce.v2.api.records.TaskState; import org.apache.hadoop.mapreduce.v2.api.records.TaskState;
import org.apache.hadoop.mapreduce.v2.api.records.TaskType; import org.apache.hadoop.mapreduce.v2.api.records.TaskType;
@ -71,6 +73,7 @@ public class TestTypeConverter {
@Test @Test
public void testFromYarn() throws Exception { public void testFromYarn() throws Exception {
int appStartTime = 612354; int appStartTime = 612354;
int appFinishTime = 612355;
YarnApplicationState state = YarnApplicationState.RUNNING; YarnApplicationState state = YarnApplicationState.RUNNING;
ApplicationId applicationId = ApplicationId.newInstance(0, 0); ApplicationId applicationId = ApplicationId.newInstance(0, 0);
ApplicationReport applicationReport = Records ApplicationReport applicationReport = Records
@ -78,6 +81,7 @@ public class TestTypeConverter {
applicationReport.setApplicationId(applicationId); applicationReport.setApplicationId(applicationId);
applicationReport.setYarnApplicationState(state); applicationReport.setYarnApplicationState(state);
applicationReport.setStartTime(appStartTime); applicationReport.setStartTime(appStartTime);
applicationReport.setFinishTime(appFinishTime);
applicationReport.setUser("TestTypeConverter-user"); applicationReport.setUser("TestTypeConverter-user");
ApplicationResourceUsageReport appUsageRpt = Records ApplicationResourceUsageReport appUsageRpt = Records
.newRecord(ApplicationResourceUsageReport.class); .newRecord(ApplicationResourceUsageReport.class);
@ -91,6 +95,7 @@ public class TestTypeConverter {
applicationReport.setApplicationResourceUsageReport(appUsageRpt); applicationReport.setApplicationResourceUsageReport(appUsageRpt);
JobStatus jobStatus = TypeConverter.fromYarn(applicationReport, "dummy-jobfile"); JobStatus jobStatus = TypeConverter.fromYarn(applicationReport, "dummy-jobfile");
Assert.assertEquals(appStartTime, jobStatus.getStartTime()); Assert.assertEquals(appStartTime, jobStatus.getStartTime());
Assert.assertEquals(appFinishTime, jobStatus.getFinishTime());
Assert.assertEquals(state.toString(), jobStatus.getState().toString()); Assert.assertEquals(state.toString(), jobStatus.getState().toString());
} }
@ -172,4 +177,25 @@ public class TestTypeConverter {
Assert.assertEquals("QueueInfo children weren't properly converted", Assert.assertEquals("QueueInfo children weren't properly converted",
returned.getQueueChildren().size(), 1); returned.getQueueChildren().size(), 1);
} }
@Test
public void testFromYarnJobReport() throws Exception {
int jobStartTime = 612354;
int jobFinishTime = 612355;
JobState state = JobState.RUNNING;
JobId jobId = Records.newRecord(JobId.class);
JobReport jobReport = Records.newRecord(JobReport.class);
ApplicationId applicationId = ApplicationId.newInstance(0, 0);
jobId.setAppId(applicationId);
jobId.setId(0);
jobReport.setJobId(jobId);
jobReport.setJobState(state);
jobReport.setStartTime(jobStartTime);
jobReport.setFinishTime(jobFinishTime);
jobReport.setUser("TestTypeConverter-user");
JobStatus jobStatus = TypeConverter.fromYarn(jobReport, "dummy-jobfile");
Assert.assertEquals(jobStartTime, jobStatus.getStartTime());
Assert.assertEquals(jobFinishTime, jobStatus.getFinishTime());
Assert.assertEquals(state.toString(), jobStatus.getState().toString());
}
} }