hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1145832 - in /hadoop/common/trunk/common: CHANGES.txt src/java/org/apache/hadoop/fs/shell/Delete.java src/test/core/org/apache/hadoop/fs/TestTrash.java
Date Wed, 13 Jul 2011 00:35:56 GMT
Author: mattf
Date: Wed Jul 13 00:35:56 2011
New Revision: 1145832

URL: http://svn.apache.org/viewvc?rev=1145832&view=rev
Log:
HADOOP-7430. Improve error message when moving to trash fails due to quota issue. Contributed
by Ravi Prakash.

Modified:
    hadoop/common/trunk/common/CHANGES.txt
    hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Delete.java
    hadoop/common/trunk/common/src/test/core/org/apache/hadoop/fs/TestTrash.java

Modified: hadoop/common/trunk/common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/CHANGES.txt?rev=1145832&r1=1145831&r2=1145832&view=diff
==============================================================================
--- hadoop/common/trunk/common/CHANGES.txt (original)
+++ hadoop/common/trunk/common/CHANGES.txt Wed Jul 13 00:35:56 2011
@@ -253,6 +253,9 @@ Trunk (unreleased changes)
     HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal
     shell commands.  (Uma Maheswara Rao G via szetszwo)
 
+    HADOOP-7430. Improve error message when moving to trash fails due to 
+    quota issue. (Ravi Prakash via mattf)
+
   OPTIMIZATIONS
   
     HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole

Modified: hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Delete.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Delete.java?rev=1145832&r1=1145831&r2=1145832&view=diff
==============================================================================
--- hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Delete.java (original)
+++ hadoop/common/trunk/common/src/java/org/apache/hadoop/fs/shell/Delete.java Wed Jul 13
00:35:56 2011
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.fs.shell;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.LinkedList;
 
@@ -85,7 +86,13 @@ class Delete extends FsCommand {
     private boolean moveToTrash(PathData item) throws IOException {
       boolean success = false;
       if (!skipTrash) {
-        success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
+        try {
+          success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
+        } catch(FileNotFoundException fnfe) {
+          throw fnfe;
+        } catch (IOException ioe) {
+            throw new IOException(ioe.getMessage() + ". Consider using -skipTrash option",
ioe);
+        }
       }
       return success;
     }

Modified: hadoop/common/trunk/common/src/test/core/org/apache/hadoop/fs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/common/src/test/core/org/apache/hadoop/fs/TestTrash.java?rev=1145832&r1=1145831&r2=1145832&view=diff
==============================================================================
--- hadoop/common/trunk/common/src/test/core/org/apache/hadoop/fs/TestTrash.java (original)
+++ hadoop/common/trunk/common/src/test/core/org/apache/hadoop/fs/TestTrash.java Wed Jul 13
00:35:56 2011
@@ -20,9 +20,11 @@ package org.apache.hadoop.fs;
 
 import static org.apache.hadoop.fs.CommonConfigurationKeys.*;
 
+import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.net.URI;
 import java.util.HashSet;
 import java.util.Set;
@@ -413,6 +415,30 @@ public class TestTrash extends TestCase 
       assertTrue(count==num_runs);
     }
     
+    //Verify skipTrash option is suggested when rm fails due to its absence
+    {
+      String[] args = new String[2];
+      args[0] = "-rmr";
+      args[1] = "/";  //This always contains trash directory
+      PrintStream stdout = System.out;
+      PrintStream stderr = System.err;
+      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+      PrintStream newOut = new PrintStream(byteStream);
+      System.setOut(newOut);
+      System.setErr(newOut);
+      try {
+        shell.run(args);
+      } catch (Exception e) {
+        System.err.println("Exception raised from Trash.run " +
+            e.getLocalizedMessage());
+      }
+      String output = byteStream.toString();
+      System.setOut(stdout);
+      System.setErr(stderr);
+      assertTrue("skipTrash wasn't suggested as remedy to failed rm command",
+        output.indexOf(("Consider using -skipTrash option")) != -1 );
+    }
+
   }
 
   public static void trashNonDefaultFS(Configuration conf) throws IOException {



Mime
View raw message