svn merge -c 1551616 FIXES: MAPREDUCE-5679. TestJobHistoryParsing has race condition. Contributed by Liyin Liang

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1551619 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Darrell Lowe 2013-12-17 16:50:57 +00:00
parent 4aeef4181d
commit 5975cf8fa9
2 changed files with 42 additions and 39 deletions

View File

@ -103,6 +103,9 @@ Release 2.4.0 - UNRELEASED
MAPREDUCE-5623. TestJobCleanup fails because of RejectedExecutionException MAPREDUCE-5623. TestJobCleanup fails because of RejectedExecutionException
and NPE. (jlowe) and NPE. (jlowe)
MAPREDUCE-5679. TestJobHistoryParsing has race condition (Liyin Liang via
jlowe)
Release 2.3.0 - UNRELEASED Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -340,8 +340,11 @@ public class TestJobHistoryParsing {
PrintStream stdps = System.out; PrintStream stdps = System.out;
try { try {
System.setOut(new PrintStream(outContent)); System.setOut(new PrintStream(outContent));
HistoryViewer viewer = new HistoryViewer(fc.makeQualified( HistoryViewer viewer;
synchronized (fileInfo) {
viewer = new HistoryViewer(fc.makeQualified(
fileInfo.getHistoryFile()).toString(), conf, true); fileInfo.getHistoryFile()).toString(), conf, true);
}
viewer.print(); viewer.print();
for (TaskInfo taskInfo : allTasks.values()) { for (TaskInfo taskInfo : allTasks.values()) {
@ -398,17 +401,14 @@ public class TestJobHistoryParsing {
// make sure all events are flushed // make sure all events are flushed
app.waitForState(Service.STATE.STOPPED); app.waitForState(Service.STATE.STOPPED);
String jobhistoryDir = JobHistoryUtils
.getHistoryIntermediateDoneDirForUser(conf);
JobHistory jobHistory = new JobHistory(); JobHistory jobHistory = new JobHistory();
jobHistory.init(conf); jobHistory.init(conf);
HistoryFileInfo fileInfo = jobHistory.getJobFileInfo(jobId);
JobIndexInfo jobIndexInfo = jobHistory.getJobFileInfo(jobId) JobHistoryParser parser;
.getJobIndexInfo(); JobInfo jobInfo;
String jobhistoryFileName = FileNameIndexUtils synchronized (fileInfo) {
.getDoneFileName(jobIndexInfo); Path historyFilePath = fileInfo.getHistoryFile();
Path historyFilePath = new Path(jobhistoryDir, jobhistoryFileName);
FSDataInputStream in = null; FSDataInputStream in = null;
FileContext fc = null; FileContext fc = null;
try { try {
@ -419,8 +419,9 @@ public class TestJobHistoryParsing {
throw (new Exception("Can not open History File")); throw (new Exception("Can not open History File"));
} }
JobHistoryParser parser = new JobHistoryParser(in); parser = new JobHistoryParser(in);
JobInfo jobInfo = parser.parse(); jobInfo = parser.parse();
}
Exception parseException = parser.getParseException(); Exception parseException = parser.getParseException();
Assert.assertNull("Caught an expected exception " + parseException, Assert.assertNull("Caught an expected exception " + parseException,
parseException); parseException);
@ -465,17 +466,15 @@ public class TestJobHistoryParsing {
// make sure all events are flushed // make sure all events are flushed
app.waitForState(Service.STATE.STOPPED); app.waitForState(Service.STATE.STOPPED);
String jobhistoryDir = JobHistoryUtils
.getHistoryIntermediateDoneDirForUser(conf);
JobHistory jobHistory = new JobHistory(); JobHistory jobHistory = new JobHistory();
jobHistory.init(conf); jobHistory.init(conf);
JobIndexInfo jobIndexInfo = jobHistory.getJobFileInfo(jobId) HistoryFileInfo fileInfo = jobHistory.getJobFileInfo(jobId);
.getJobIndexInfo();
String jobhistoryFileName = FileNameIndexUtils
.getDoneFileName(jobIndexInfo);
Path historyFilePath = new Path(jobhistoryDir, jobhistoryFileName); JobHistoryParser parser;
JobInfo jobInfo;
synchronized (fileInfo) {
Path historyFilePath = fileInfo.getHistoryFile();
FSDataInputStream in = null; FSDataInputStream in = null;
FileContext fc = null; FileContext fc = null;
try { try {
@ -486,8 +485,9 @@ public class TestJobHistoryParsing {
throw (new Exception("Can not open History File")); throw (new Exception("Can not open History File"));
} }
JobHistoryParser parser = new JobHistoryParser(in); parser = new JobHistoryParser(in);
JobInfo jobInfo = parser.parse(); jobInfo = parser.parse();
}
Exception parseException = parser.getParseException(); Exception parseException = parser.getParseException();
Assert.assertNull("Caught an expected exception " + parseException, Assert.assertNull("Caught an expected exception " + parseException,
parseException); parseException);