From 437c5187cd82f45ab709f9b87dba75d2911f20e4 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Fri, 19 Oct 2018 13:19:10 -0700 Subject: [PATCH] HADOOP-15850. CopyCommitter#concatFileChunks should check that the blocks per chunk is not 0. Contributed by Ted Yu. Signed-off-by: Wei-Chiu Chuang (cherry picked from commit e2cecb681e2aab8b7c5465719cac53dce407a64c) (cherry picked from commit a7dd244a4995cbf20feb054530fc5913ccf384ac) (cherry picked from commit 84726679f0441bfa0788ad5a5ac2bfa4353afedb) --- .../org/apache/hadoop/tools/mapred/CopyCommitter.java | 8 +++++++- .../org/apache/hadoop/tools/mapred/TestCopyCommitter.java | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyCommitter.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyCommitter.java index 81c2be7e05d..238a37ba5fe 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyCommitter.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyCommitter.java @@ -69,6 +69,7 @@ public class CopyCommitter extends FileOutputCommitter { private boolean overwrite = false; private boolean targetPathExists = true; private boolean ignoreFailures = false; + private int blocksPerChunk = 0; /** * Create a output committer @@ -79,6 +80,9 @@ public class CopyCommitter extends FileOutputCommitter { */ public CopyCommitter(Path outputPath, TaskAttemptContext context) throws IOException { super(outputPath, context); + blocksPerChunk = context.getConfiguration().getInt( + DistCpOptionSwitch.BLOCKS_PER_CHUNK.getConfigLabel(), 0); + LOG.debug("blocks per chunk {}", blocksPerChunk); this.taskAttemptContext = context; } @@ -93,7 +97,9 @@ public class CopyCommitter extends FileOutputCommitter { ignoreFailures = conf.getBoolean( DistCpOptionSwitch.IGNORE_FAILURES.getConfigLabel(), false); - concatFileChunks(conf); + if (blocksPerChunk > 0) { + concatFileChunks(conf); + } super.commitJob(jobContext); diff --git a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyCommitter.java b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyCommitter.java index 6ee37ccd6a5..38964c1c2cc 100644 --- a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyCommitter.java +++ b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/mapred/TestCopyCommitter.java @@ -82,10 +82,6 @@ public class TestCopyCommitter { @Before public void createMetaFolder() { config.set(DistCpConstants.CONF_LABEL_META_FOLDER, "/meta"); - // Unset listing file path since the config is shared by - // multiple tests, and some test doesn't set it, such as - // testNoCommitAction, but the distcp code will check it. - config.set(DistCpConstants.CONF_LABEL_LISTING_FILE_PATH, ""); Path meta = new Path("/meta"); try { cluster.getFileSystem().mkdirs(meta);