hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1144858 - in /hadoop/common/trunk/common: CHANGES.txt src/java/org/apache/hadoop/fs/shell/CommandWithDestination.java src/java/org/apache/hadoop/fs/shell/CopyCommands.java
Date Sun, 10 Jul 2011 13:28:01 GMT
Author: szetszwo
Date: Sun Jul 10 13:28:01 2011
New Revision: 1144858

URL: http://svn.apache.org/viewvc?rev=1144858&view=rev
Log:
HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal shell commands.  Contributed
by Uma Maheswara Rao G

Modified:
    hadoop/common/trunk/common/CHANGES.txt
    hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CommandWithDestination.java
    hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CopyCommands.java

Modified: hadoop/common/trunk/common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/CHANGES.txt?rev=1144858&r1=1144857&r2=1144858&view=diff
==============================================================================
--- hadoop/common/trunk/common/CHANGES.txt (original)
+++ hadoop/common/trunk/common/CHANGES.txt Sun Jul 10 13:28:01 2011
@@ -248,6 +248,9 @@ Trunk (unreleased changes)
     to Data(In,Out)putBuffer for byte[].  Merge from yahoo-merge branch,
     -r 1079163.  Fix missing Apache license headers. (Chris Douglas via mattf)
 
+    HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal
+    shell commands.  (Uma Maheswara Rao G via szetszwo)
+
   OPTIMIZATIONS
   
     HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole

Modified: hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CommandWithDestination.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CommandWithDestination.java?rev=1144858&r1=1144857&r2=1144858&view=diff
==============================================================================
--- hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CommandWithDestination.java
(original)
+++ hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CommandWithDestination.java
Sun Jul 10 13:28:01 2011
@@ -38,7 +38,12 @@ abstract class CommandWithDestination ex
   protected PathData dst;
   protected boolean overwrite = false;
   
-  // TODO: commands should implement a -f to enable this
+  /**
+   * 
+   * This method is used to enable the force(-f)  option while copying the files.
+   * 
+   * @param flag true/false
+   */
   protected void setOverwrite(boolean flag) {
     overwrite = flag;
   }

Modified: hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CopyCommands.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CopyCommands.java?rev=1144858&r1=1144857&r2=1144858&view=diff
==============================================================================
--- hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CopyCommands.java (original)
+++ hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/CopyCommands.java Sun Jul
10 13:28:01 2011
@@ -94,15 +94,16 @@ class CopyCommands {  
     
     @Override
     protected void processOptions(LinkedList<String> args) throws IOException {
-      CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE);
+      CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "f");
       cf.parse(args);
+      setOverwrite(cf.getOpt("f"));
       getRemoteDestination(args);
     }
 
     @Override
     protected void processPath(PathData src, PathData target)
     throws IOException {
-      if (!FileUtil.copy(src.fs, src.path, target.fs, target.path, false, getConf())) {
+      if (!FileUtil.copy(src.fs, src.path, target.fs, target.path, false, overwrite, getConf()))
{
         // we have no idea what the error is...  FileUtils masks it and in
         // some cases won't even report an error
         throw new PathIOException(src.toString());
@@ -216,8 +217,9 @@ class CopyCommands {  
 
     @Override
     protected void processOptions(LinkedList<String> args) throws IOException {
-      CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE);
+      CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, "f");
       cf.parse(args);
+      setOverwrite(cf.getOpt("f"));
       getRemoteDestination(args);
     }
 
@@ -246,7 +248,7 @@ class CopyCommands {  
     @Override
     protected void processPath(PathData src, PathData target)
     throws IOException {
-      target.fs.copyFromLocalFile(false, false, src.path, target.path);
+      target.fs.copyFromLocalFile(false, overwrite, src.path, target.path);
     }
 
     /** Copies from stdin to the destination file. */



Mime
View raw message