hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1081598 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/Trash.java src/test/core/org/apache/hadoop/fs/TestTrash.java
Date Mon, 14 Mar 2011 22:42:53 GMT
Author: szetszwo
Date: Mon Mar 14 22:42:53 2011
New Revision: 1081598

URL: http://svn.apache.org/viewvc?rev=1081598&view=rev
Log:
HADOOP-7175. Add isEnabled() to Trash.  Contributed by Daryn Sharp

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

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1081598&r1=1081597&r2=1081598&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Mon Mar 14 22:42:53 2011
@@ -79,6 +79,8 @@ Trunk (unreleased changes)
     HADOOP-7167. Amend previous commit under this JIRA to fix issue on
     cygwin. (todd)
 
+    HADOOP-7175. Add isEnabled() to Trash.  (Daryn Sharp via szetszwo)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/Trash.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/Trash.java?rev=1081598&r1=1081597&r2=1081598&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/Trash.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/Trash.java Mon Mar 14 22:42:53 2011
@@ -102,11 +102,18 @@ public class Trash extends Configured {
     return new Path(basePath + rmFilePath.toUri().getPath());
   }
 
+  /**
+   * Returns whether the trash is enabled for this filesystem
+   */
+  public boolean isEnabled() {
+    return (deletionInterval != 0);
+  }
+
   /** Move a file or directory to the current trash directory.
    * @return false if the item is already in the trash or trash is disabled
    */ 
   public boolean moveToTrash(Path path) throws IOException {
-    if (deletionInterval == 0)
+    if (!isEnabled())
       return false;
 
     if (!path.isAbsolute())                       // make path absolute

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java?rev=1081598&r1=1081597&r2=1081598&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestTrash.java Mon Mar 14 22:42:53
2011
@@ -93,8 +93,14 @@ public class TestTrash extends TestCase 
   protected static void trashShell(final FileSystem fs, final Path base)
       throws IOException {
     Configuration conf = new Configuration();
-    conf.set(FS_TRASH_INTERVAL_KEY, "10"); // 10 minute
     conf.set("fs.default.name", fs.getUri().toString());
+
+    conf.set(FS_TRASH_INTERVAL_KEY, "0"); // disabled
+    assertFalse(new Trash(conf).isEnabled());
+
+    conf.set(FS_TRASH_INTERVAL_KEY, "10"); // 10 minute
+    assertTrue(new Trash(conf).isEnabled());
+
     FsShell shell = new FsShell();
     shell.setConf(conf);
     Path trashRoot = null;



Mime
View raw message