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 2011/06/21 22:09:57 UTC
svn commit: r1138160 [6/6] - in /hadoop/common/branches/HDFS-1073/hdfs: ./
bin/ src/c++/libhdfs/ src/c++/libhdfs/tests/ src/contrib/
src/contrib/fuse-dfs/ src/contrib/fuse-dfs/src/ src/contrib/hdfsproxy/
src/docs/src/documentation/content/xdocs/ src/ja...
Modified: hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java?rev=1138160&r1=1138159&r2=1138160&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java (original)
+++ hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSafeMode.java Tue Jun 21 20:09:54 2011
@@ -20,109 +20,31 @@ package org.apache.hadoop.hdfs.server.na
import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.protocol.FSConstants.SafeModeAction;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.hdfs.DFSTestUtil;
-import junit.framework.TestCase;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* Tests to verify safe mode correctness.
*/
-public class TestSafeMode extends TestCase {
+public class TestSafeMode {
- static Log LOG = LogFactory.getLog(TestSafeMode.class);
-
- /**
- * This test verifies that if SafeMode is manually entered, name-node does not
- * come out of safe mode even after the startup safe mode conditions are met.
- * <ol>
- * <li>Start cluster with 1 data-node.</li>
- * <li>Create 2 files with replication 1.</li>
- * <li>Re-start cluster with 0 data-nodes.
- * Name-node should stay in automatic safe-mode.</li>
- * <li>Enter safe mode manually.</li>
- * <li>Start the data-node.</li>
- * <li>Wait longer than <tt>dfs.namenode.safemode.extension</tt> and
- * verify that the name-node is still in safe mode.</li>
- * </ol>
- *
- * @throws IOException
- */
- public void testManualSafeMode() throws IOException {
- MiniDFSCluster cluster = null;
- DistributedFileSystem fs = null;
- try {
- Configuration conf = new HdfsConfiguration();
- // disable safemode extension to make the test run faster.
- conf.set(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, "1");
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
-
- fs = (DistributedFileSystem)cluster.getFileSystem();
- Path file1 = new Path("/tmp/testManualSafeMode/file1");
- Path file2 = new Path("/tmp/testManualSafeMode/file2");
-
- LOG.info("Created file1 and file2.");
-
- // create two files with one block each.
- DFSTestUtil.createFile(fs, file1, 1000, (short)1, 0);
- DFSTestUtil.createFile(fs, file2, 2000, (short)1, 0);
- fs.close();
- cluster.shutdown();
-
- // now bring up just the NameNode.
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).format(false).build();
- cluster.waitActive();
- fs = (DistributedFileSystem)cluster.getFileSystem();
-
- LOG.info("Restarted cluster with just the NameNode");
-
- assertTrue("No datanode is started. Should be in SafeMode",
- fs.setSafeMode(SafeModeAction.SAFEMODE_GET));
-
- // manually set safemode.
- fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
-
- // now bring up the datanode and wait for it to be active.
- cluster.startDataNodes(conf, 1, true, null, null);
- cluster.waitActive();
-
- LOG.info("Datanode is started.");
-
- // wait longer than dfs.namenode.safemode.extension
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ignored) {}
-
- assertTrue("should still be in SafeMode",
- fs.setSafeMode(SafeModeAction.SAFEMODE_GET));
-
- fs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
- assertFalse("should not be in SafeMode",
- fs.setSafeMode(SafeModeAction.SAFEMODE_GET));
- } finally {
- if(fs != null) fs.close();
- if(cluster!= null) cluster.shutdown();
- }
- }
-
-
/**
* 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 {
MiniDFSCluster cluster = null;
DistributedFileSystem fs = null;
try {
- Configuration conf = new Configuration();
+ Configuration conf = new HdfsConfiguration();
conf.setInt(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, 0);
conf.setInt(DFSConfigKeys.DFS_NAMENODE_SAFEMODE_MIN_DATANODES_KEY, 1);
Copied: hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java (from r1134991, hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java)
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java?p2=hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java&p1=hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java&r1=1134991&r2=1138160&rev=1138160&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java (original)
+++ hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestStartupOptionUpgrade.java Tue Jun 21 20:09:54 2011
@@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hdfs.server.namenode;
+import java.net.URI;
+import java.util.Collections;
import junit.framework.Assert;
import org.apache.hadoop.conf.Configuration;
@@ -43,7 +45,9 @@ public class TestStartupOptionUpgrade {
conf = new HdfsConfiguration();
startOpt = StartupOption.UPGRADE;
startOpt.setClusterId(null);
- storage = new NNStorage(conf);
+ storage = new NNStorage(conf,
+ Collections.<URI>emptyList(),
+ Collections.<URI>emptyList());
}
@After
@@ -136,4 +140,4 @@ public class TestStartupOptionUpgrade {
Assert.assertEquals("Clusterid should match with the existing one",
"currentcid", storage.getClusterID());
}
-}
\ No newline at end of file
+}
Modified: hadoop/common/branches/HDFS-1073/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1073/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java?rev=1138160&r1=1138159&r2=1138160&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1073/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java (original)
+++ hadoop/common/branches/HDFS-1073/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java Tue Jun 21 20:09:54 2011
@@ -39,7 +39,8 @@ import org.apache.hadoop.hdfs.server.com
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.log4j.Level;
import org.junit.After;
-import static org.junit.Assert.assertFalse;
+
+import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.Matchers.anyString;
@@ -99,6 +100,17 @@ public class TestNNLeaseRecovery {
}
}
+ // Release the lease for the given file
+ private boolean releaseLease(FSNamesystem ns, LeaseManager.Lease lm,
+ Path file) throws IOException {
+ fsn.writeLock();
+ try {
+ return fsn.internalReleaseLease(lm, file.toString(), null);
+ } finally {
+ fsn.writeUnlock();
+ }
+ }
+
/**
* Mocks FSNamesystem instance, adds an empty file and invokes lease recovery
* method.
@@ -118,7 +130,7 @@ public class TestNNLeaseRecovery {
fsn.dir.addFile(file.toString(), ps, (short)3, 1l,
"test", "test-machine", dnd, 1001l);
assertTrue("True has to be returned in this case",
- fsn.internalReleaseLease(lm, file.toString(), null));
+ releaseLease(fsn, lm, file));
}
/**
@@ -143,9 +155,9 @@ public class TestNNLeaseRecovery {
mockFileBlocks(2, null,
HdfsConstants.BlockUCState.UNDER_CONSTRUCTION, file, dnd, ps, false);
- fsn.internalReleaseLease(lm, file.toString(), null);
- assertTrue("FSNamesystem.internalReleaseLease suppose to throw " +
- "IOException here", false);
+ releaseLease(fsn, lm, file);
+ fail("FSNamesystem.internalReleaseLease suppose to throw " +
+ "IOException here");
}
/**
@@ -169,15 +181,14 @@ public class TestNNLeaseRecovery {
mockFileBlocks(2, HdfsConstants.BlockUCState.COMMITTED,
HdfsConstants.BlockUCState.COMMITTED, file, dnd, ps, false);
- fsn.internalReleaseLease(lm, file.toString(), null);
- assertTrue("FSNamesystem.internalReleaseLease suppose to throw " +
- "AlreadyBeingCreatedException here", false);
+ releaseLease(fsn, lm, file);
+ fail("FSNamesystem.internalReleaseLease suppose to throw " +
+ "IOException here");
}
/**
* Mocks FSNamesystem instance, adds an empty file with 0 blocks
* and invokes lease recovery method.
- *
*/
@Test
public void testInternalReleaseLease_0blocks () throws IOException {
@@ -194,7 +205,7 @@ public class TestNNLeaseRecovery {
mockFileBlocks(0, null, null, file, dnd, ps, false);
assertTrue("True has to be returned in this case",
- fsn.internalReleaseLease(lm, file.toString(), null));
+ releaseLease(fsn, lm, file));
}
/**
@@ -217,9 +228,9 @@ public class TestNNLeaseRecovery {
mockFileBlocks(1, null, HdfsConstants.BlockUCState.COMMITTED, file, dnd, ps, false);
- fsn.internalReleaseLease(lm, file.toString(), null);
- assertTrue("FSNamesystem.internalReleaseLease suppose to throw " +
- "AlreadyBeingCreatedException here", false);
+ releaseLease(fsn, lm, file);
+ fail("FSNamesystem.internalReleaseLease suppose to throw " +
+ "IOException here");
}
/**
@@ -244,7 +255,7 @@ public class TestNNLeaseRecovery {
HdfsConstants.BlockUCState.UNDER_CONSTRUCTION, file, dnd, ps, false);
assertFalse("False is expected in return in this case",
- fsn.internalReleaseLease(lm, file.toString(), null));
+ releaseLease(fsn, lm, file));
}
@Test
Propchange: hadoop/common/branches/HDFS-1073/hdfs/src/webapps/datanode/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 21 20:09:54 2011
@@ -1,6 +1,7 @@
+/hadoop/common/trunk/hdfs/src/webapps/datanode:1134994-1138149
/hadoop/core/branches/branch-0.19/hdfs/src/webapps/datanode:713112
/hadoop/core/trunk/src/webapps/datanode:776175-784663
/hadoop/hdfs/branches/HDFS-1052/src/webapps/datanode:987665-1095512
/hadoop/hdfs/branches/HDFS-265/src/webapps/datanode:796829-820463
/hadoop/hdfs/branches/branch-0.21/src/webapps/datanode:820487
-/hadoop/hdfs/trunk/src/webapps/datanode:1086482-1134136
+/hadoop/hdfs/trunk/src/webapps/datanode:1086482-1134991
Propchange: hadoop/common/branches/HDFS-1073/hdfs/src/webapps/hdfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 21 20:09:54 2011
@@ -1,6 +1,7 @@
+/hadoop/common/trunk/hdfs/src/webapps/hdfs:1134994-1138149
/hadoop/core/branches/branch-0.19/hdfs/src/webapps/hdfs:713112
/hadoop/core/trunk/src/webapps/hdfs:776175-784663
/hadoop/hdfs/branches/HDFS-1052/src/webapps/hdfs:987665-1095512
/hadoop/hdfs/branches/HDFS-265/src/webapps/hdfs:796829-820463
/hadoop/hdfs/branches/branch-0.21/src/webapps/hdfs:820487
-/hadoop/hdfs/trunk/src/webapps/hdfs:1086482-1134136
+/hadoop/hdfs/trunk/src/webapps/hdfs:1086482-1134991
Modified: hadoop/common/branches/HDFS-1073/hdfs/src/webapps/hdfs/dfshealth.jsp
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1073/hdfs/src/webapps/hdfs/dfshealth.jsp?rev=1138160&r1=1138159&r2=1138160&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1073/hdfs/src/webapps/hdfs/dfshealth.jsp (original)
+++ hadoop/common/branches/HDFS-1073/hdfs/src/webapps/hdfs/dfshealth.jsp Tue Jun 21 20:09:54 2011
@@ -50,9 +50,7 @@
<b> <%= NamenodeJspHelper.getSecurityModeText()%> </b>
<b> <%= NamenodeJspHelper.getSafeModeText(fsn)%> </b>
<b> <%= NamenodeJspHelper.getInodeLimitText(fsn)%> </b>
-<a class="warning" href="/corrupt_files.jsp" title="List corrupt files">
- <%= NamenodeJspHelper.getWarningText(fsn)%>
-</a>
+<%= NamenodeJspHelper.getCorruptFilesWarning(fsn)%>
<% healthjsp.generateHealthReport(out, nn, request); %>
<hr>
Propchange: hadoop/common/branches/HDFS-1073/hdfs/src/webapps/secondary/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 21 20:09:54 2011
@@ -1,6 +1,7 @@
+/hadoop/common/trunk/hdfs/src/webapps/secondary:1134994-1138149
/hadoop/core/branches/branch-0.19/hdfs/src/webapps/secondary:713112
/hadoop/core/trunk/src/webapps/secondary:776175-784663
/hadoop/hdfs/branches/HDFS-1052/src/webapps/secondary:987665-1095512
/hadoop/hdfs/branches/HDFS-265/src/webapps/secondary:796829-820463
/hadoop/hdfs/branches/branch-0.21/src/webapps/secondary:820487
-/hadoop/hdfs/trunk/src/webapps/secondary:1086482-1134136
+/hadoop/hdfs/trunk/src/webapps/secondary:1086482-1134991