MAPREDUCE-6620. Jobs that did not start are shown as starting in 1969 in the JHS web UI (haibochen via rkanter)
(cherry picked from commit ccbba4a4de
)
This commit is contained in:
parent
b4ad58796b
commit
358c49d830
|
@ -14,6 +14,9 @@ Release 2.9.0 - UNRELEASED
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
|
MAPREDUCE-6620. Jobs that did not start are shown as starting in 1969 in
|
||||||
|
the JHS web UI (haibochen via rkanter)
|
||||||
|
|
||||||
Release 2.8.0 - UNRELEASED
|
Release 2.8.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class HsJobBlock extends HtmlBlock {
|
||||||
_("State:", job.getState()).
|
_("State:", job.getState()).
|
||||||
_("Uberized:", job.isUber()).
|
_("Uberized:", job.isUber()).
|
||||||
_("Submitted:", new Date(job.getSubmitTime())).
|
_("Submitted:", new Date(job.getSubmitTime())).
|
||||||
_("Started:", new Date(job.getStartTime())).
|
_("Started:", job.getStartTimeStr()).
|
||||||
_("Finished:", new Date(job.getFinishTime())).
|
_("Finished:", new Date(job.getFinishTime())).
|
||||||
_("Elapsed:", StringUtils.formatTime(
|
_("Elapsed:", StringUtils.formatTime(
|
||||||
Times.elapsed(job.getStartTime(), job.getFinishTime(), false)));
|
Times.elapsed(job.getStartTime(), job.getFinishTime(), false)));
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class HsJobsBlock extends HtmlBlock {
|
||||||
JobInfo job = new JobInfo(j);
|
JobInfo job = new JobInfo(j);
|
||||||
jobsTableData.append("[\"")
|
jobsTableData.append("[\"")
|
||||||
.append(dateFormat.format(new Date(job.getSubmitTime()))).append("\",\"")
|
.append(dateFormat.format(new Date(job.getSubmitTime()))).append("\",\"")
|
||||||
.append(dateFormat.format(new Date(job.getStartTime()))).append("\",\"")
|
.append(job.getStartTimeStr()).append("\",\"")
|
||||||
.append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"")
|
.append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"")
|
||||||
.append("<a href='").append(url("job", job.getId())).append("'>")
|
.append("<a href='").append(url("job", job.getId())).append("'>")
|
||||||
.append(job.getId()).append("</a>\",\"")
|
.append(job.getId()).append("</a>\",\"")
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.hadoop.mapreduce.v2.hs.webapp.dao;
|
package org.apache.hadoop.mapreduce.v2.hs.webapp.dao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ import org.apache.hadoop.security.authorize.AccessControlList;
|
||||||
@XmlRootElement(name = "job")
|
@XmlRootElement(name = "job")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class JobInfo {
|
public class JobInfo {
|
||||||
|
private static final String NA = "N/A";
|
||||||
|
|
||||||
protected long submitTime;
|
protected long submitTime;
|
||||||
protected long startTime;
|
protected long startTime;
|
||||||
|
@ -226,6 +228,16 @@ public class JobInfo {
|
||||||
return this.startTime;
|
return this.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStartTimeStr() {
|
||||||
|
String str = NA;
|
||||||
|
|
||||||
|
if (startTime >= 0) {
|
||||||
|
str = new Date(startTime).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
public long getFinishTime() {
|
public long getFinishTime() {
|
||||||
return this.finishTime;
|
return this.finishTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -136,4 +137,27 @@ public class TestJobInfo {
|
||||||
|
|
||||||
Assert.assertEquals(11L, jobInfo.getAvgReduceTime().longValue());
|
Assert.assertEquals(11L, jobInfo.getAvgReduceTime().longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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("N/A", jobInfo.getStartTimeStr());
|
||||||
|
|
||||||
|
Date date = new Date();
|
||||||
|
when(jobReport.getStartTime()).thenReturn(date.getTime());
|
||||||
|
|
||||||
|
jobInfo = new JobInfo(job);
|
||||||
|
Assert.assertEquals(date.toString(), jobInfo.getStartTimeStr());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue