HADOOP-7430. Improve error message when moving to trash fails due to quota issue. Contributed by Ravi Prakash.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1145832 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Foley 2011-07-13 00:35:56 +00:00
parent 94f3b578ef
commit faf8747e3e
3 changed files with 37 additions and 1 deletions

View File

@ -253,6 +253,9 @@ Trunk (unreleased changes)
HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal
shell commands. (Uma Maheswara Rao G via szetszwo) 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 OPTIMIZATIONS
HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.fs.shell; package org.apache.hadoop.fs.shell;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
@ -85,7 +86,13 @@ class Delete extends FsCommand {
private boolean moveToTrash(PathData item) throws IOException { private boolean moveToTrash(PathData item) throws IOException {
boolean success = false; boolean success = false;
if (!skipTrash) { 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; return success;
} }

View File

@ -20,9 +20,11 @@ package org.apache.hadoop.fs;
import static org.apache.hadoop.fs.CommonConfigurationKeys.*; import static org.apache.hadoop.fs.CommonConfigurationKeys.*;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream;
import java.net.URI; import java.net.URI;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -413,6 +415,30 @@ public class TestTrash extends TestCase {
assertTrue(count==num_runs); 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 { public static void trashNonDefaultFS(Configuration conf) throws IOException {