|
@@ -255,13 +255,18 @@ public class TestFileOutputCommitter {
|
|
assert(dataFileFound && indexFileFound);
|
|
assert(dataFileFound && indexFileFound);
|
|
}
|
|
}
|
|
|
|
|
|
- private void testCommitterInternal(int version) throws Exception {
|
|
|
|
|
|
+ private void testCommitterInternal(int version, boolean taskCleanup)
|
|
|
|
+ throws Exception {
|
|
Job job = Job.getInstance();
|
|
Job job = Job.getInstance();
|
|
FileOutputFormat.setOutputPath(job, outDir);
|
|
FileOutputFormat.setOutputPath(job, outDir);
|
|
Configuration conf = job.getConfiguration();
|
|
Configuration conf = job.getConfiguration();
|
|
conf.set(MRJobConfig.TASK_ATTEMPT_ID, attempt);
|
|
conf.set(MRJobConfig.TASK_ATTEMPT_ID, attempt);
|
|
- conf.setInt(FileOutputCommitter.FILEOUTPUTCOMMITTER_ALGORITHM_VERSION,
|
|
|
|
|
|
+ conf.setInt(
|
|
|
|
+ FileOutputCommitter.FILEOUTPUTCOMMITTER_ALGORITHM_VERSION,
|
|
version);
|
|
version);
|
|
|
|
+ conf.setBoolean(
|
|
|
|
+ FileOutputCommitter.FILEOUTPUTCOMMITTER_TASK_CLEANUP_ENABLED,
|
|
|
|
+ taskCleanup);
|
|
JobContext jContext = new JobContextImpl(conf, taskID.getJobID());
|
|
JobContext jContext = new JobContextImpl(conf, taskID.getJobID());
|
|
TaskAttemptContext tContext = new TaskAttemptContextImpl(conf, taskID);
|
|
TaskAttemptContext tContext = new TaskAttemptContextImpl(conf, taskID);
|
|
FileOutputCommitter committer = new FileOutputCommitter(outDir, tContext);
|
|
FileOutputCommitter committer = new FileOutputCommitter(outDir, tContext);
|
|
@@ -275,9 +280,30 @@ public class TestFileOutputCommitter {
|
|
RecordWriter theRecordWriter = theOutputFormat.getRecordWriter(tContext);
|
|
RecordWriter theRecordWriter = theOutputFormat.getRecordWriter(tContext);
|
|
writeOutput(theRecordWriter, tContext);
|
|
writeOutput(theRecordWriter, tContext);
|
|
|
|
|
|
|
|
+ // check task and job temp directories exist
|
|
|
|
+ File jobOutputDir = new File(
|
|
|
|
+ new Path(outDir, FileOutputCommitter.PENDING_DIR_NAME).toString());
|
|
|
|
+ File taskOutputDir = new File(Path.getPathWithoutSchemeAndAuthority(
|
|
|
|
+ committer.getWorkPath()).toString());
|
|
|
|
+ assertTrue("job temp dir does not exist", jobOutputDir.exists());
|
|
|
|
+ assertTrue("task temp dir does not exist", taskOutputDir.exists());
|
|
|
|
+
|
|
// do commit
|
|
// do commit
|
|
committer.commitTask(tContext);
|
|
committer.commitTask(tContext);
|
|
|
|
+ assertTrue("job temp dir does not exist", jobOutputDir.exists());
|
|
|
|
+ if (version == 1 || taskCleanup) {
|
|
|
|
+ // Task temp dir gets renamed in v1 and deleted if taskCleanup is
|
|
|
|
+ // enabled in v2
|
|
|
|
+ assertFalse("task temp dir still exists", taskOutputDir.exists());
|
|
|
|
+ } else {
|
|
|
|
+ // By default, in v2 the task temp dir is only deleted during commitJob
|
|
|
|
+ assertTrue("task temp dir does not exist", taskOutputDir.exists());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Entire job temp directory gets deleted, including task temp dir
|
|
committer.commitJob(jContext);
|
|
committer.commitJob(jContext);
|
|
|
|
+ assertFalse("job temp dir still exists", jobOutputDir.exists());
|
|
|
|
+ assertFalse("task temp dir still exists", taskOutputDir.exists());
|
|
|
|
|
|
// validate output
|
|
// validate output
|
|
validateContent(outDir);
|
|
validateContent(outDir);
|
|
@@ -286,12 +312,17 @@ public class TestFileOutputCommitter {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testCommitterV1() throws Exception {
|
|
public void testCommitterV1() throws Exception {
|
|
- testCommitterInternal(1);
|
|
|
|
|
|
+ testCommitterInternal(1, false);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testCommitterV2() throws Exception {
|
|
public void testCommitterV2() throws Exception {
|
|
- testCommitterInternal(2);
|
|
|
|
|
|
+ testCommitterInternal(2, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testCommitterV2TaskCleanupEnabled() throws Exception {
|
|
|
|
+ testCommitterInternal(2, true);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|