hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r629548 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FsShell.java src/test/org/apache/hadoop/dfs/TestDFSShell.java
Date Wed, 20 Feb 2008 18:10:48 GMT
Author: dhruba
Date: Wed Feb 20 10:10:38 2008
New Revision: 629548

URL: http://svn.apache.org/viewvc?rev=629548&view=rev
Log:
HADOOP-2192. Error messages from "dfs mv" command improved.
(Mahadev Konar via dhruba)


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=629548&r1=629547&r2=629548&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Feb 20 10:10:38 2008
@@ -10,6 +10,9 @@
     HADOOP-2345.  New HDFS transactions to support appending 
     to files.  Disk layout version changed from -11 to -12. (dhruba)
 
+    HADOOP-2192. Error messages from "dfs mv" command improved.
+    (Mahadev Konar via dhruba)
+
   NEW FEATURES
 
     HADOOP-1398.  Add HBase in-memory block cache.  (tomwhite)

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java?rev=629548&r1=629547&r2=629548&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/fs/FsShell.java Wed Feb 20 10:10:38 2008
@@ -39,6 +39,7 @@
 import org.apache.hadoop.ipc.RPC;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 
@@ -816,10 +817,26 @@
                             + "destination should be a directory.");
     }
     for(int i=0; i<srcs.length; i++) {
-      if (srcFs.rename(srcs[i], dst)) {
-        System.out.println("Renamed " + srcs[i] + " to " + dstf);
-      } else {
-        throw new IOException("Rename failed " + srcs[i]);
+      if (!srcFs.rename(srcs[i], dst)) {
+        FileStatus srcFstatus = null;
+        FileStatus dstFstatus = null;
+        try {
+          srcFstatus = srcFs.getFileStatus(srcs[i]);
+        } catch(FileNotFoundException e) {
+          throw new FileNotFoundException(srcs[i] + 
+          ": No such file or directory");
+        }
+        try {
+          dstFstatus = dstFs.getFileStatus(dst);
+        } catch(IOException e) {
+          //hide this
+        }
+        if((srcFstatus!= null) && (dstFstatus!= null)) {
+          if (srcFstatus.isDir()  && !dstFstatus.isDir()) {
+            throw new IOException("cannot overwrite non directory "
+                + dst + " with directory " + srcs[i]);
+          }
+        }
       }
     }
   }

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java?rev=629548&r1=629547&r2=629548&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestDFSShell.java Wed Feb 20 10:10:38
2008
@@ -175,7 +175,7 @@
   }
 
 
-  /** check if we have any exceptions in cat command output */
+  /** check command error outputs and exit statuses. */
   public void testErrOutPut() throws Exception {
     Configuration conf = new Configuration();
     MiniDFSCluster cluster = null;
@@ -276,6 +276,22 @@
       assertTrue(" -mkdir returned this is a file ",
           (returned.lastIndexOf("not a directory") != -1));
       out.reset();
+      argv = new String[3];
+      argv[0] = "-mv";
+      argv[1] = "/testfile";
+      argv[2] = "/testfiletest";
+      ret = ToolRunner.run(shell, argv);
+      returned = out.toString();
+      assertTrue("no output from rename", 
+          (returned.lastIndexOf("Renamed") == -1));
+      out.reset();
+      argv[0] = "-mv";
+      argv[1] = "/testfile";
+      argv[2] = "/testfiletmp";
+      ret = ToolRunner.run(shell, argv);
+      returned = out.toString();
+      assertTrue(" unix like output",
+          (returned.lastIndexOf("No such file or") != -1));
     } finally {
       if (bak != null) {
         System.setErr(bak);



Mime
View raw message