hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1097207 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNameNodeResourceChecker.java
Date Wed, 27 Apr 2011 19:08:44 GMT
Author: eli
Date: Wed Apr 27 19:08:43 2011
New Revision: 1097207

URL: http://svn.apache.org/viewvc?rev=1097207&view=rev
Log:
HDFS-1862. Improve test reliability of HDFS-1594. Contributed by Aaron T. Myers


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

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=1097207&r1=1097206&r2=1097207&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Wed Apr 27 19:08:43 2011
@@ -141,6 +141,8 @@ Trunk (unreleased changes)
     HDFS-1843. Discover file not found early for file append. 
     (Bharath Mundlapudi via jitendra)
 
+    HDFS-1862. Improve test reliability of HDFS-1594. (Aaron T. Myers via eli)
+
   OPTIMIZATIONS
 
     HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1097207&r1=1097206&r2=1097207&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Wed
Apr 27 19:08:43 2011
@@ -255,7 +255,7 @@ public class FSNamesystem implements FSC
   private long resourceRecheckInterval;
 
   // The actual resource checker instance.
-  private NameNodeResourceChecker nnResourceChecker;
+  NameNodeResourceChecker nnResourceChecker;
 
   private FsServerDefaults serverDefaults;
   // allow appending to hdfs files

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNameNodeResourceChecker.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNameNodeResourceChecker.java?rev=1097207&r1=1097206&r2=1097207&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNameNodeResourceChecker.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNameNodeResourceChecker.java
Wed Apr 27 19:08:43 2011
@@ -18,27 +18,23 @@
 package org.apache.hadoop.hdfs.server.namenode;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Set;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.DF;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NameNodeResourceMonitor;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 public class TestNameNodeResourceChecker {
-  private static final int BIG_TMP_FILE_SIZE = 1024 * 1024 * 20; // 20MB
-
   private Configuration conf;
-  private byte[] bigBuffer = new byte[BIG_TMP_FILE_SIZE];
   private File baseDir;
   private File nameDir;
 
@@ -49,11 +45,6 @@ public class TestNameNodeResourceChecker
     nameDir = new File(baseDir, "resource-check-name-dir");
     nameDir.mkdirs();
     conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, nameDir.getAbsolutePath());
-
-    // Initialize bigBuffer to non-zero values so we don't make a sparse file.
-    for(int i = 0; i < bigBuffer.length; i++) {
-      bigBuffer[i] = 0x01;
-    }
   }
 
   /**
@@ -100,16 +91,17 @@ public class TestNameNodeResourceChecker
   public void testCheckThatNameNodeResourceMonitorIsRunning()
       throws IOException, InterruptedException {
     MiniDFSCluster cluster = null;
-    File bigTmpFile = File.createTempFile("nnrm-big-tmp-file", null, baseDir);
     try {
       conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, nameDir.getAbsolutePath());
-      conf.setLong(DFSConfigKeys.DFS_NAMENODE_RESOURCE_CHECK_INTERVAL_KEY, 0);
-      DF df = new DF(nameDir, conf);
-      conf.setLong(DFSConfigKeys.DFS_NAMENODE_DU_RESERVED_KEY,
-          df.getAvailable() - (BIG_TMP_FILE_SIZE / 2));
+      conf.setLong(DFSConfigKeys.DFS_NAMENODE_RESOURCE_CHECK_INTERVAL_KEY, 1);
       
       cluster = new MiniDFSCluster.Builder(conf)
           .numDataNodes(1).build();
+
+      NameNodeResourceChecker mockResourceChecker = Mockito.mock(NameNodeResourceChecker.class);
+      Mockito.when(mockResourceChecker.hasAvailableDiskSpace()).thenReturn(true);
+      cluster.getNameNode().getNamesystem().nnResourceChecker = mockResourceChecker;
+
       cluster.waitActive();
 
       String name = NameNodeResourceMonitor.class.getName();
@@ -119,6 +111,7 @@ public class TestNameNodeResourceChecker
       for (Thread runningThread : runningThreads) {
         if (runningThread.toString().startsWith("Thread[" + name)) {
           isNameNodeMonitorRunning = true;
+          break;
         }
       }
       assertTrue("NN resource monitor should be running",
@@ -126,7 +119,7 @@ public class TestNameNodeResourceChecker
       assertFalse("NN should not presently be in safe mode",
           cluster.getNameNode().isInSafeMode());
       
-      new FileOutputStream(bigTmpFile).write(bigBuffer);
+      Mockito.when(mockResourceChecker.hasAvailableDiskSpace()).thenReturn(false);
 
       // Make sure the NNRM thread has a chance to run.
       long startMillis = System.currentTimeMillis();
@@ -140,8 +133,6 @@ public class TestNameNodeResourceChecker
     } finally {
       if (cluster != null)
         cluster.shutdown();
-      if (bigTmpFile != null)
-        bigTmpFile.delete();
     }
   }
 



Mime
View raw message