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 to...@apache.org on 2012/01/21 01:42:04 UTC
svn commit: r1234220 - in
/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs:
CHANGES.txt src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java
src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java
Author: todd
Date: Sat Jan 21 00:42:03 2012
New Revision: 1234220
URL: http://svn.apache.org/viewvc?rev=1234220&view=rev
Log:
HDFS-2817. Combine the two TestSafeMode test suites. Contributed by Todd Lipcon.
Removed:
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java
Modified:
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java
Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1234220&r1=1234219&r2=1234220&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Jan 21 00:42:03 2012
@@ -92,6 +92,8 @@ Release 0.23.1 - UNRELEASED
HDFS-2803. Add logging to LeaseRenewer for better lease expiration debugging.
(Jimmy Xiang via todd)
+ HDFS-2817. Combine the two TestSafeMode test suites. (todd)
+
OPTIMIZATIONS
HDFS-2130. Switch default checksum to CRC32C. (todd)
Modified: hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java?rev=1234220&r1=1234219&r2=1234220&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java (original)
+++ hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java Sat Jan 21 00:42:03 2012
@@ -113,6 +113,21 @@ public class TestSafeMode {
dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE));
}
+ /**
+ * Test that, if there are no blocks in the filesystem,
+ * the NameNode doesn't enter the "safemode extension" period.
+ */
+ @Test(timeout=45000)
+ public void testNoExtensionIfNoBlocks() throws IOException {
+ cluster.getConfiguration(0).setInt(
+ DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, 60000);
+ cluster.restartNameNode();
+ // Even though we have safemode extension set high, we should immediately
+ // exit safemode on startup because there are no blocks in the namespace.
+ String status = cluster.getNameNode().getNamesystem().getSafemode();
+ assertEquals("", status);
+ }
+
public interface FSRun {
public abstract void run(FileSystem fs) throws IOException;
}
@@ -193,5 +208,37 @@ public class TestSafeMode {
assertFalse("Could not leave SM",
dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE));
}
-
+
+ /**
+ * Verify that the NameNode stays in safemode when dfs.safemode.datanode.min
+ * is set to a number greater than the number of live datanodes.
+ */
+ @Test
+ public void testDatanodeThreshold() throws IOException {
+ cluster.shutdown();
+ Configuration conf = cluster.getConfiguration(0);
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, 0);
+ conf.setInt(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY, 1);
+
+ cluster.restartNameNode();
+ fs = (DistributedFileSystem)cluster.getFileSystem();
+
+ String tipMsg = cluster.getNamesystem().getSafemode();
+ assertTrue("Safemode tip message looks right: " + tipMsg,
+ tipMsg.contains("The number of live datanodes 0 needs an additional " +
+ "2 live datanodes to reach the minimum number 1. " +
+ "Safe mode will be turned off automatically."));
+
+ // Start a datanode
+ cluster.startDataNodes(conf, 1, true, null, null);
+
+ // Wait long enough for safemode check to refire
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {}
+
+ // We now should be out of safe mode.
+ assertEquals("", cluster.getNamesystem().getSafemode());
+ }
+
}
\ No newline at end of file