HADOOP-12460. Add overwrite option for 'get' shell command (Contributed by Jagadesh Kiran N)

(cherry picked from commit 7f0e1eb43d)
This commit is contained in:
Vinayakumar B 2015-10-19 12:15:02 +05:30
parent 23bd017a7b
commit b6dce3834d
4 changed files with 26 additions and 9 deletions

View File

@ -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

View File

@ -191,11 +191,12 @@ private void popPreserveOption(List<String> args) {
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 @@ public static class Get extends CommandWithDestination {
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);
}

View File

@ -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
-------

View File

@ -165,7 +165,7 @@
<comparators>
<comparator>
<type>RegexpComparator</type>
<expected-output>^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*&lt;src&gt; \.\.\. &lt;localdst&gt; :\s*</expected-output>
<expected-output>^-get( )*\[-f\]( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*&lt;src&gt; \.\.\. &lt;localdst&gt; :\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\]( )*&lt;src&gt; \.\.\. &lt;localdst&gt; :\s*</expected-output>
<expected-output>^-get( )*\[-f\]( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*&lt;src&gt; \.\.\. &lt;localdst&gt; :\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)*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>
@ -680,7 +688,7 @@
<comparators>
<comparator>
<type>RegexpComparator</type>
<expected-output>^-copyToLocal \[-p\] \[-ignoreCrc\] \[-crc\] &lt;src&gt; \.\.\. &lt;localdst&gt; :\s*</expected-output>
<expected-output>^-copyToLocal \[-f\] \[-p\] \[-ignoreCrc\] \[-crc\] &lt;src&gt; \.\.\. &lt;localdst&gt; :\s*</expected-output>
</comparator>
<comparator>
<type>RegexpComparator</type>