svn merge -c 1381784 FIXES: MAPREDUCE-4641. Exception in commitJob marks job as successful in job history (Jason Lowe via bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1381786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3d928ddeb8
commit
928e6864d3
|
@ -759,6 +759,9 @@ Release 0.23.3 - UNRELEASED
|
||||||
MAPREDUCE-4633. history server doesn't set permissions on all subdirs
|
MAPREDUCE-4633. history server doesn't set permissions on all subdirs
|
||||||
(tgraves via bobby)
|
(tgraves via bobby)
|
||||||
|
|
||||||
|
MAPREDUCE-4641. Exception in commitJob marks job as successful in job
|
||||||
|
history (Jason Lowe via bobby)
|
||||||
|
|
||||||
Release 0.23.2 - UNRELEASED
|
Release 0.23.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -759,7 +759,8 @@ public class JobImpl implements org.apache.hadoop.mapreduce.v2.app.job.Job,
|
||||||
job.getCommitter().commitJob(job.getJobContext());
|
job.getCommitter().commitJob(job.getJobContext());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Could not do commit for Job", e);
|
LOG.error("Could not do commit for Job", e);
|
||||||
job.logJobHistoryFinishedEvent();
|
job.addDiagnostic("Job commit failed: " + e.getMessage());
|
||||||
|
job.abortJob(org.apache.hadoop.mapreduce.JobStatus.State.FAILED);
|
||||||
return job.finished(JobState.FAILED);
|
return job.finished(JobState.FAILED);
|
||||||
}
|
}
|
||||||
job.logJobHistoryFinishedEvent();
|
job.logJobHistoryFinishedEvent();
|
||||||
|
@ -1199,7 +1200,7 @@ public class JobImpl implements org.apache.hadoop.mapreduce.v2.app.job.Job,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abortJob(
|
protected void abortJob(
|
||||||
org.apache.hadoop.mapreduce.JobStatus.State finalState) {
|
org.apache.hadoop.mapreduce.JobStatus.State finalState) {
|
||||||
try {
|
try {
|
||||||
committer.abortJob(jobContext, finalState);
|
committer.abortJob(jobContext, finalState);
|
||||||
|
@ -1501,7 +1502,7 @@ public class JobImpl implements org.apache.hadoop.mapreduce.v2.app.job.Job,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDiagnostic(String diag) {
|
protected void addDiagnostic(String diag) {
|
||||||
diagnostics.add(diag);
|
diagnostics.add(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
package org.apache.hadoop.mapreduce.v2.app.job.impl;
|
package org.apache.hadoop.mapreduce.v2.app.job.impl;
|
||||||
|
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -91,8 +93,6 @@ public class TestJobImpl {
|
||||||
when(mockJob.getCommitter()).thenReturn(mockCommitter);
|
when(mockJob.getCommitter()).thenReturn(mockCommitter);
|
||||||
when(mockJob.getEventHandler()).thenReturn(mockEventHandler);
|
when(mockJob.getEventHandler()).thenReturn(mockEventHandler);
|
||||||
when(mockJob.getJobContext()).thenReturn(mockJobContext);
|
when(mockJob.getJobContext()).thenReturn(mockJobContext);
|
||||||
doNothing().when(mockJob).setFinishTime();
|
|
||||||
doNothing().when(mockJob).logJobHistoryFinishedEvent();
|
|
||||||
when(mockJob.finished(JobState.KILLED)).thenReturn(JobState.KILLED);
|
when(mockJob.finished(JobState.KILLED)).thenReturn(JobState.KILLED);
|
||||||
when(mockJob.finished(JobState.FAILED)).thenReturn(JobState.FAILED);
|
when(mockJob.finished(JobState.FAILED)).thenReturn(JobState.FAILED);
|
||||||
when(mockJob.finished(JobState.SUCCEEDED)).thenReturn(JobState.SUCCEEDED);
|
when(mockJob.finished(JobState.SUCCEEDED)).thenReturn(JobState.SUCCEEDED);
|
||||||
|
@ -103,11 +103,13 @@ public class TestJobImpl {
|
||||||
// commitJob stubbed out, so this can't happen
|
// commitJob stubbed out, so this can't happen
|
||||||
}
|
}
|
||||||
doNothing().when(mockEventHandler).handle(any(JobHistoryEvent.class));
|
doNothing().when(mockEventHandler).handle(any(JobHistoryEvent.class));
|
||||||
|
JobState jobState = JobImpl.checkJobCompleteSuccess(mockJob);
|
||||||
Assert.assertNotNull("checkJobCompleteSuccess incorrectly returns null " +
|
Assert.assertNotNull("checkJobCompleteSuccess incorrectly returns null " +
|
||||||
"for successful job",
|
"for successful job", jobState);
|
||||||
JobImpl.checkJobCompleteSuccess(mockJob));
|
|
||||||
Assert.assertEquals("checkJobCompleteSuccess returns incorrect state",
|
Assert.assertEquals("checkJobCompleteSuccess returns incorrect state",
|
||||||
JobState.FAILED, JobImpl.checkJobCompleteSuccess(mockJob));
|
JobState.FAILED, jobState);
|
||||||
|
verify(mockJob).abortJob(
|
||||||
|
eq(org.apache.hadoop.mapreduce.JobStatus.State.FAILED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue