hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r734589 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/fs/Trash.java src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java src/test/org/apache/hadoop/hdfs/TestTrash.java
Date Thu, 15 Jan 2009 01:21:13 GMT
Author: shv
Date: Wed Jan 14 17:21:13 2009
New Revision: 734589

URL: http://svn.apache.org/viewvc?rev=734589&view=rev
Log:
HADOOP-2337. Trash should close FileSystem on exit and should not start emtying thread if
disabled. Contributed by Konstantin Shvachko.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/core/org/apache/hadoop/fs/Trash.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestTrash.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=734589&r1=734588&r2=734589&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Jan 14 17:21:13 2009
@@ -36,6 +36,9 @@
     HADOOP-4963. Fixes a logging to do with getting the location of
     map output file. (Amareshwari Sriramadasu via ddas)
 
+    HADOOP-2337. Trash should close FileSystem on exit and should not start 
+    emtying thread if disabled. (shv)
+
 Release 0.20.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/Trash.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/Trash.java?rev=734589&r1=734588&r2=734589&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/Trash.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/Trash.java Wed Jan 14 17:21:13 2009
@@ -195,16 +195,14 @@
     return new Emptier(getConf());
   }
 
-  private static class Emptier implements Runnable {
+  private class Emptier implements Runnable {
 
     private Configuration conf;
-    private FileSystem fs;
     private long interval;
 
-    public Emptier(Configuration conf) throws IOException {
+    Emptier(Configuration conf) throws IOException {
       this.conf = conf;
-      this.interval = conf.getLong("fs.trash.interval", 60) * MSECS_PER_MINUTE;
-      this.fs = FileSystem.get(conf);
+      this.interval = conf.getLong("fs.trash.interval", 0) * MSECS_PER_MINUTE;
     }
 
     public void run() {
@@ -218,7 +216,7 @@
         try {                                     // sleep for interval
           Thread.sleep(end - now);
         } catch (InterruptedException e) {
-          return;                                 // exit on interrupt
+          break;                                  // exit on interrupt
         }
           
         try {
@@ -253,6 +251,12 @@
                    StringUtils.stringifyException(e));
         }
       }
+      try {
+        fs.close();
+      } catch(IOException e) {
+        LOG.warn("Trash cannot close FileSystem. " +
+            StringUtils.stringifyException(e));
+      }
     }
 
     private long ceiling(long time, long interval) {

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=734589&r1=734588&r2=734589&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java Wed Jan
14 17:21:13 2009
@@ -205,6 +205,9 @@
   }
 
   private void startTrashEmptier(Configuration conf) throws IOException {
+    long trashInterval = conf.getLong("fs.trash.interval", 0);
+    if(trashInterval == 0)
+      return;
     this.emptier = new Thread(new Trash(conf).getEmptier(), "Trash Emptier");
     this.emptier.setDaemon(true);
     this.emptier.start();

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestTrash.java?rev=734589&r1=734588&r2=734589&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestTrash.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestTrash.java Wed Jan 14 17:21:13 2009
@@ -18,12 +18,13 @@
 package org.apache.hadoop.hdfs;
 
 import junit.framework.TestCase;
-import java.io.*;
-import java.util.*;
+import java.io.IOException;
+import java.io.DataOutputStream;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.*;
-import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FsShell;
 
 /**
  * This class tests commands from Trash.
@@ -71,7 +72,6 @@
     conf.set("fs.trash.interval", "10"); // 10 minute
     MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
     FileSystem fs = cluster.getFileSystem();
-    DistributedFileSystem fileSys = (DistributedFileSystem) fs;
     FsShell shell = new FsShell();
     shell.setConf(conf);
     Path trashRoot = null;



Mime
View raw message