|
@@ -17,9 +17,6 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.mapred;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.FileUtil;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
@@ -27,9 +24,18 @@ import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.ipc.ProtocolSignature;
|
|
|
import org.apache.hadoop.mapred.SortedRanges.Range;
|
|
|
import org.apache.hadoop.mapreduce.TaskType;
|
|
|
-import org.apache.hadoop.mapreduce.checkpoint.CheckpointID;
|
|
|
-import org.apache.hadoop.mapreduce.checkpoint.FSCheckpointID;
|
|
|
import org.apache.hadoop.mapreduce.checkpoint.TaskCheckpointID;
|
|
|
+import org.junit.After;
|
|
|
+import org.junit.Test;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertFalse;
|
|
|
+import static org.junit.Assert.assertTrue;
|
|
|
+import static org.junit.Assert.fail;
|
|
|
+
|
|
|
|
|
|
|
|
|
public class TestTaskCommit extends HadoopTestCase {
|
|
@@ -80,12 +86,13 @@ public class TestTaskCommit extends HadoopTestCase {
|
|
|
super(LOCAL_MR, LOCAL_FS, 1, 1);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ @After
|
|
|
public void tearDown() throws Exception {
|
|
|
super.tearDown();
|
|
|
FileUtil.fullyDelete(new File(rootDir.toString()));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test
|
|
|
public void testCommitFail() throws IOException {
|
|
|
final Path inDir = new Path(rootDir, "./input");
|
|
|
final Path outDir = new Path(rootDir, "./output");
|
|
@@ -199,6 +206,7 @@ public class TestTaskCommit extends HadoopTestCase {
|
|
|
*
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
+ @Test
|
|
|
public void testTaskCleanupDoesNotCommit() throws Exception {
|
|
|
// Mimic a job with a special committer that does not cleanup
|
|
|
// files when a task fails.
|
|
@@ -245,23 +253,27 @@ public class TestTaskCommit extends HadoopTestCase {
|
|
|
assertTrue("Task did not succeed", umbilical.taskDone);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testCommitRequiredForMapTask() throws Exception {
|
|
|
Task testTask = createDummyTask(TaskType.MAP);
|
|
|
assertTrue("MapTask should need commit", testTask.isCommitRequired());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testCommitRequiredForReduceTask() throws Exception {
|
|
|
Task testTask = createDummyTask(TaskType.REDUCE);
|
|
|
assertTrue("ReduceTask should need commit", testTask.isCommitRequired());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test
|
|
|
public void testCommitNotRequiredForJobSetup() throws Exception {
|
|
|
Task testTask = createDummyTask(TaskType.MAP);
|
|
|
testTask.setJobSetupTask();
|
|
|
assertFalse("Job setup task should not need commit",
|
|
|
testTask.isCommitRequired());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test
|
|
|
public void testCommitNotRequiredForJobCleanup() throws Exception {
|
|
|
Task testTask = createDummyTask(TaskType.MAP);
|
|
|
testTask.setJobCleanupTask();
|
|
@@ -269,6 +281,7 @@ public class TestTaskCommit extends HadoopTestCase {
|
|
|
testTask.isCommitRequired());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testCommitNotRequiredForTaskCleanup() throws Exception {
|
|
|
Task testTask = createDummyTask(TaskType.REDUCE);
|
|
|
testTask.setTaskCleanupTask();
|