소스 검색

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
Chris Nauroth 11 년 전
부모
커밋
ee0530ee0e

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

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

+ 3 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/TypeConverter.java

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

+ 26 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/TestTypeConverter.java

@@ -27,6 +27,8 @@ import junit.framework.Assert;
 
 import org.apache.hadoop.conf.Configuration;
 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.TaskState;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskType;
@@ -71,6 +73,7 @@ public class TestTypeConverter {
   @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
@@ -78,6 +81,7 @@ public class TestTypeConverter {
     applicationReport.setApplicationId(applicationId);
     applicationReport.setYarnApplicationState(state);
     applicationReport.setStartTime(appStartTime);
+    applicationReport.setFinishTime(appFinishTime);
     applicationReport.setUser("TestTypeConverter-user");
     ApplicationResourceUsageReport appUsageRpt = Records
         .newRecord(ApplicationResourceUsageReport.class);
@@ -91,6 +95,7 @@ public class TestTypeConverter {
     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());
   }
 
@@ -172,4 +177,25 @@ public class TestTypeConverter {
     Assert.assertEquals("QueueInfo children weren't properly converted",
       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());
+  }  
 }