You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by co...@apache.org on 2010/01/11 19:06:05 UTC

svn commit: r897975 - in /hadoop/hdfs/trunk: CHANGES.txt src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java

Author: cos
Date: Mon Jan 11 18:06:05 2010
New Revision: 897975

URL: http://svn.apache.org/viewvc?rev=897975&view=rev
Log:
HDFS-880. TestNNLeaseRecovery fails on windows. Contributed by Konstantin Boudnik, Konstantin Shvachko.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=897975&r1=897974&r2=897975&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Mon Jan 11 18:06:05 2010
@@ -21,7 +21,7 @@
     HDFS-703. Replace current fault injection implementation with one
     from (cos)
 
-    HDFS-754. Reduce ivy console output to ovservable level (cos)
+    HDFS-754. Reduce ivy console output to observable level (cos)
 
     HDFS-832. HDFS side of HADOOP-6222. (cos)
 
@@ -607,6 +607,8 @@
     (Cristian Ivascu via dhruba)
 
     HDFS-868. Fix link to Hadoop Upgrade Wiki. (Chris A. Mattmann via shv)
+    
+    HDFS-880. TestNNLeaseRecovery fails on windows (cos, shv)
 
 Release 0.20.2 - Unreleased
 

Modified: hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java?rev=897975&r1=897974&r2=897975&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java (original)
+++ hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java Mon Jan 11 18:06:05 2010
@@ -24,11 +24,13 @@
 import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.PermissionStatus;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.hdfs.HdfsConfiguration;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
 import org.apache.hadoop.hdfs.protocol.DatanodeID;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants;
@@ -46,7 +48,10 @@
 import java.io.IOException;
 
 public class TestNNLeaseRecovery {
-  public static final Log LOG = LogFactory.getLog(TestNNLeaseRecovery.class);
+  private static final Log LOG = LogFactory.getLog(TestNNLeaseRecovery.class);
+  private static final String NAME_DIR =
+    MiniDFSCluster.getBaseDirectory() + "name";
+
   FSNamesystem fsn;
   Configuration conf;
   
@@ -62,6 +67,8 @@
   @Before
   public void startUp() throws IOException {
     conf = new HdfsConfiguration();
+    conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, NAME_DIR);
+    conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, NAME_DIR);
     // avoid stubbing access control
     conf.setBoolean(DFSConfigKeys.DFS_PERMISSIONS_ENABLED_KEY, false); 
     NameNode.initMetrics(conf, NamenodeRole.ACTIVE);
@@ -80,11 +87,13 @@
   public void tearDown() throws IOException {
     if (fsn != null) {
       try {
-        if (fsn.getFSImage() != null) fsn.getFSImage().close();
         fsn.close();
+      } catch(Exception e) {
+        LOG.error("Cannot close: ", e);
       } finally {
-        File dir = new File(conf.get("hadoop.tmp.dir"));
-        if (dir != null) deleteDir(dir);
+        File dir = new File(NAME_DIR);
+        if (dir != null)
+          assertTrue("Cannot delete name-node dirs", FileUtil.fullyDelete(dir));
       }
     }
   }
@@ -371,6 +380,7 @@
     FSDirectory fsDir = mock(FSDirectory.class);
     INodeFileUnderConstruction iNFmock = mock(INodeFileUnderConstruction.class);
 
+    fsn.dir.close();
     fsn.dir = fsDir;
     FSImage fsImage = mock(FSImage.class);
     FSEditLog editLog = mock(FSEditLog.class);
@@ -409,21 +419,4 @@
 
     when(fsDir.getFileINode(anyString())).thenReturn(iNFmock);
   }
-
-  private static boolean deleteDir(File dir) {
-    if (dir == null) return false;
-    
-    if (dir.isDirectory()) {
-      String[] children = dir.list();
-      for (String aChildren : children) {
-        boolean success = deleteDir(new File(dir, aChildren));
-        if (!success) {
-          return false;
-        }
-      }
-    }
-
-    // The directory is now empty so delete it
-    return dir.delete();
-  }
 }