From dd65eea74b1f9dde858ff34df8111e5340115511 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Tue, 20 Jun 2017 09:53:47 -0500 Subject: [PATCH] HADOOP-8143. Change distcp to have -pb on by default. Contributed by Mithun Radhakrishnan --- .../src/main/java/org/apache/hadoop/tools/OptionsParser.java | 3 +++ .../test/java/org/apache/hadoop/tools/TestOptionsParser.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java index 96fb1d918e..2bfaccfe09 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java @@ -187,6 +187,9 @@ public static DistCpOptions parse(String[] args) if (command.hasOption(DistCpOptionSwitch.PRESERVE_STATUS.getSwitch())) { builder.preserve( getVal(command, DistCpOptionSwitch.PRESERVE_STATUS.getSwitch())); + } else { + // No "preserve" settings specified. Preserve block-size. + builder.preserve(DistCpOptions.FileAttribute.BLOCKSIZE); } if (command.hasOption(DistCpOptionSwitch.FILE_LIMIT.getSwitch())) { diff --git a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestOptionsParser.java b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestOptionsParser.java index e7fdc515a7..6928cdf045 100644 --- a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestOptionsParser.java +++ b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestOptionsParser.java @@ -413,7 +413,7 @@ public void testPreserve() { "-f", "hdfs://localhost:9820/source/first", "hdfs://localhost:9820/target/"}); - Assert.assertFalse(options.shouldPreserve(FileAttribute.BLOCKSIZE)); + Assert.assertTrue(options.shouldPreserve(FileAttribute.BLOCKSIZE)); Assert.assertFalse(options.shouldPreserve(FileAttribute.REPLICATION)); Assert.assertFalse(options.shouldPreserve(FileAttribute.PERMISSION)); Assert.assertFalse(options.shouldPreserve(FileAttribute.USER));