From dd9b8af9c497808116d0e156c488df13373b3576 Mon Sep 17 00:00:00 2001 From: GuoPhilipse <46367746+GuoPhilipse@users.noreply.github.com> Date: Mon, 30 May 2022 21:02:47 +0800 Subject: [PATCH] HADOOP-18269. Misleading method name in DistCpOptions.(#4216) Contributed by guophilipse Change-Id: I5e75d030406997339c20e970483825e529d9cd10 --- .../org/apache/hadoop/tools/DistCpOptions.java | 17 +++++++++++++++++ .../org/apache/hadoop/tools/OptionsParser.java | 2 +- .../apache/hadoop/tools/TestDistCpOptions.java | 4 ++-- .../contract/AbstractContractDistCpTest.java | 2 +- .../hadoop/tools/mapred/TestCopyCommitter.java | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCpOptions.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCpOptions.java index 094c21d8d78..c9c7661569a 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCpOptions.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCpOptions.java @@ -669,11 +669,28 @@ public final class DistCpOptions { return this; } + /** + * whether builder with crc. + * @param newSkipCRC whether to skip crc check + * @return Builder object whether to skip crc check + * @deprecated Use {@link #withSkipCRC(boolean)} instead. + */ + @Deprecated public Builder withCRC(boolean newSkipCRC) { this.skipCRC = newSkipCRC; return this; } + /** + * whether builder with crc. + * @param newSkipCRC whether to skip crc check + * @return Builder object whether to skip crc check + */ + public Builder withSkipCRC(boolean newSkipCRC) { + this.skipCRC = newSkipCRC; + return this; + } + public Builder withBlocking(boolean newBlocking) { this.blocking = newBlocking; return this; 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 a4c3b0f851f..a596d9c7986 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 @@ -108,7 +108,7 @@ public class OptionsParser { command.hasOption(DistCpOptionSwitch.OVERWRITE.getSwitch())) .withAppend( command.hasOption(DistCpOptionSwitch.APPEND.getSwitch())) - .withCRC( + .withSkipCRC( command.hasOption(DistCpOptionSwitch.SKIP_CRC.getSwitch())) .withBlocking( !command.hasOption(DistCpOptionSwitch.BLOCKING.getSwitch())) diff --git a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpOptions.java b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpOptions.java index 13497029a07..37b84f1d7a8 100644 --- a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpOptions.java +++ b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpOptions.java @@ -128,7 +128,7 @@ public class TestDistCpOptions { new Path("hdfs://localhost:8020/target/")); Assert.assertFalse(builder.build().shouldSkipCRC()); - final DistCpOptions options = builder.withSyncFolder(true).withCRC(true) + final DistCpOptions options = builder.withSyncFolder(true).withSkipCRC(true) .build(); Assert.assertTrue(options.shouldSyncFolder()); Assert.assertTrue(options.shouldSkipCRC()); @@ -391,7 +391,7 @@ public class TestDistCpOptions { new Path("hdfs://localhost:8020/target/")) .withSyncFolder(true) .withAppend(true) - .withCRC(true) + .withSkipCRC(true) .build(); fail("Append should fail if skipCrc option is specified"); } catch (IllegalArgumentException e) { diff --git a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/contract/AbstractContractDistCpTest.java b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/contract/AbstractContractDistCpTest.java index 04aeea665c2..8545df30bac 100644 --- a/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/contract/AbstractContractDistCpTest.java +++ b/hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/contract/AbstractContractDistCpTest.java @@ -349,7 +349,7 @@ public abstract class AbstractContractDistCpTest Collections.singletonList(srcDir), destDir) .withDeleteMissing(true) .withSyncFolder(true) - .withCRC(true) + .withSkipCRC(true) .withDirectWrite(shouldUseDirectWrite()) .withOverwrite(false))); } 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 62940f64b34..599f3ec2db6 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 @@ -536,7 +536,7 @@ public class TestCopyCommitter { Collections.singletonList(new Path(sourceBase)), new Path("/out")) .withBlocksPerChunk(blocksPerChunk) - .withCRC(skipCrc) + .withSkipCRC(skipCrc) .build(); options.appendToConf(conf); conf.setBoolean(