From d09ade4d0b64c1f0f629fe9361d511ed905732c6 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Tue, 8 Sep 2009 01:41:17 +0000 Subject: [PATCH] HADOOP-6203. FsShell rm/rmr error message indicates exceeding Trash quota and suggests using -skpTrash, when moving to trash fails. Contributed by Boris Shkolnik. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@812317 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ src/java/org/apache/hadoop/fs/FsShell.java | 18 ++++++++++++++---- src/java/org/apache/hadoop/fs/Trash.java | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a32e6c79056..f90a206c27d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -81,6 +81,10 @@ Trunk (unreleased changes) HADOOP-6230. Moved process tree and memory calculator related classes from Common to Map/Reduce. (Vinod Kumar Vavilapalli via yhemanth) + HADOOP-6203. FsShell rm/rmr error message indicates exceeding Trash quota + and suggests using -skpTrash, when moving to trash fails. + (Boris Shkolnik via suresh) + NEW FEATURES HADOOP-4268. Change fsck to use ClientProtocol methods so that the diff --git a/src/java/org/apache/hadoop/fs/FsShell.java b/src/java/org/apache/hadoop/fs/FsShell.java index ab7b370a759..9676c7b494f 100644 --- a/src/java/org/apache/hadoop/fs/FsShell.java +++ b/src/java/org/apache/hadoop/fs/FsShell.java @@ -1130,10 +1130,20 @@ public class FsShell extends Configured implements Tool { } if(!skipTrash) { - Trash trashTmp = new Trash(srcFs, getConf()); - if (trashTmp.moveToTrash(src)) { - System.out.println("Moved to trash: " + src); - return; + try { + Trash trashTmp = new Trash(srcFs, getConf()); + if (trashTmp.moveToTrash(src)) { + System.out.println("Moved to trash: " + src); + return; + } + } catch (IOException e) { + Exception cause = (Exception) e.getCause(); + String msg = ""; + if(cause != null) { + msg = cause.getLocalizedMessage(); + } + System.err.println("Problem with Trash." + msg +". Consider using -skipTrash option"); + throw e; } } diff --git a/src/java/org/apache/hadoop/fs/Trash.java b/src/java/org/apache/hadoop/fs/Trash.java index 597946991b8..0e269e7fe4b 100644 --- a/src/java/org/apache/hadoop/fs/Trash.java +++ b/src/java/org/apache/hadoop/fs/Trash.java @@ -123,7 +123,7 @@ public class Trash extends Configured { for (int i = 0; i < 2; i++) { try { if (!fs.mkdirs(baseTrashPath, PERMISSION)) { // create current - LOG.warn("Can't create trash directory: "+baseTrashPath); + LOG.warn("Can't create(mkdir) trash directory: "+baseTrashPath); return false; } } catch (IOException e) {