Repository: hadoop Updated Branches: refs/heads/branch-2 23bd017a7 -> b6dce3834 refs/heads/trunk 4c9c3955a -> 7f0e1eb43
HADOOP-12460. Add overwrite option for 'get' shell command (Contributed by Jagadesh Kiran N) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7f0e1eb4 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7f0e1eb4 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7f0e1eb4 Branch: refs/heads/trunk Commit: 7f0e1eb43d3fb173e3c7932739ef20095e28ed7b Parents: 4c9c395 Author: Vinayakumar B <vinayakum...@apache.org> Authored: Mon Oct 19 12:15:02 2015 +0530 Committer: Vinayakumar B <vinayakum...@apache.org> Committed: Mon Oct 19 12:16:16 2015 +0530 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../apache/hadoop/fs/shell/CopyCommands.java | 6 ++++-- .../src/site/markdown/FileSystemShell.md | 4 ++++ .../src/test/resources/testConf.xml | 22 +++++++++++++------- 4 files changed, 26 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/7f0e1eb4/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index c9bf4f0..1db02d2 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -894,6 +894,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12481. JWTRedirectAuthenticationHandler doesn't Retain Original Query String (Larry McCay via cnauroth) + HADOOP-12460. Add overwrite option for 'get' shell command + (Jagadesh Kiran N via vinayakumarb) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp http://git-wip-us.apache.org/repos/asf/hadoop/blob/7f0e1eb4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java index d16d27e..c4e42c9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java @@ -191,11 +191,12 @@ class CopyCommands { public static class Get extends CommandWithDestination { public static final String NAME = "get"; public static final String USAGE = - "[-p] [-ignoreCrc] [-crc] <src> ... <localdst>"; + "[-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>"; public static final String DESCRIPTION = "Copy files that match the file pattern <src> " + "to the local name. <src> is kept. When copying multiple " + "files, the destination must be a directory. Passing " + + "-f overwrites the destination if it already exists and " + "-p preserves access and modification times, " + "ownership and the mode.\n"; @@ -203,11 +204,12 @@ class CopyCommands { protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat( - 1, Integer.MAX_VALUE, "crc", "ignoreCrc", "p"); + 1, Integer.MAX_VALUE, "crc", "ignoreCrc", "p", "f"); cf.parse(args); setWriteChecksum(cf.getOpt("crc")); setVerifyChecksum(!cf.getOpt("ignoreCrc")); setPreserve(cf.getOpt("p")); + setOverwrite(cf.getOpt("f")); setRecursive(true); getLocalDestination(args); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/7f0e1eb4/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md b/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md index 2ea5aba..e243dea 100644 --- a/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md +++ b/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md @@ -320,6 +320,10 @@ Exit Code: Returns 0 on success and -1 on error. +Options: + +The -f option will overwrite the destination if it already exists. + getfacl ------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/7f0e1eb4/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml b/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml index 7513843..fd71034 100644 --- a/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml +++ b/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml @@ -165,7 +165,7 @@ <comparators> <comparator> <type>RegexpComparator</type> - <expected-output>^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst> :\s*</expected-output> + <expected-output>^-get( )*\[-f\]( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst> :\s*</expected-output> </comparator> <comparator> <type>RegexpComparator</type> @@ -173,11 +173,15 @@ </comparator> <comparator> <type>RegexpComparator</type> - <expected-output>\s*When copying multiple files, the destination must be a directory. Passing -p\s*</expected-output> + <expected-output>^( |\t)*When copying multiple files, the destination must be a directory. Passing -f( )*</expected-output> </comparator> <comparator> <type>RegexpComparator</type> - <expected-output>^( |\t)*preserves access and modification times, ownership and the mode.*</expected-output> + <expected-output>^( |\t)*overwrites the destination if it already exists and -p preserves access and( )*</expected-output> + </comparator> + <comparator> + <type>RegexpComparator</type> + <expected-output>^( |\t)*modification times, ownership and the mode.*</expected-output> </comparator> </comparators> </test> @@ -566,7 +570,7 @@ <comparators> <comparator> <type>RegexpComparator</type> - <expected-output>^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst> :\s*</expected-output> + <expected-output>^-get( )*\[-f\]( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst> :\s*</expected-output> </comparator> <comparator> <type>RegexpComparator</type> @@ -574,11 +578,15 @@ </comparator> <comparator> <type>RegexpComparator</type> - <expected-output>^( |\t)*When copying multiple files, the destination must be a directory. Passing -p( )*</expected-output> + <expected-output>^( |\t)*When copying multiple files, the destination must be a directory. Passing -f( )*</expected-output> + </comparator> + <comparator> + <type>RegexpComparator</type> + <expected-output>^( |\t)*overwrites the destination if it already exists and -p preserves access and( )*</expected-output> </comparator> <comparator> <type>RegexpComparator</type> - <expected-output>^( |\t)*preserves access and modification times, ownership and the mode.( )*</expected-output> + <expected-output>^( |\t)*modification times, ownership and the mode.*</expected-output> </comparator> </comparators> </test> @@ -680,7 +688,7 @@ <comparators> <comparator> <type>RegexpComparator</type> - <expected-output>^-copyToLocal \[-p\] \[-ignoreCrc\] \[-crc\] <src> \.\.\. <localdst> :\s*</expected-output> + <expected-output>^-copyToLocal \[-f\] \[-p\] \[-ignoreCrc\] \[-crc\] <src> \.\.\. <localdst> :\s*</expected-output> </comparator> <comparator> <type>RegexpComparator</type>