You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by vi...@apache.org on 2015/10/19 08:47:12 UTC
[2/2] hadoop git commit: HADOOP-12460. Add overwrite option for 'get'
shell command (Contributed by Jagadesh Kiran N)
HADOOP-12460. Add overwrite option for 'get' shell command (Contributed by Jagadesh Kiran N)
(cherry picked from commit 7f0e1eb43d3fb173e3c7932739ef20095e28ed7b)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b6dce383
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b6dce383
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b6dce383
Branch: refs/heads/branch-2
Commit: b6dce3834d7d95ed1d6ba52680ebce4d7bbe6d14
Parents: 23bd017
Author: Vinayakumar B <vi...@apache.org>
Authored: Mon Oct 19 12:15:02 2015 +0530
Committer: Vinayakumar B <vi...@apache.org>
Committed: Mon Oct 19 12:16:44 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/b6dce383/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 a19c4b8..a61e3cd 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -306,6 +306,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/b6dce383/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/b6dce383/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 2f4b0ed..5aefd49 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/b6dce383/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 714f6c6..f92d436 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>