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/07/06 20:03:48 UTC
svn commit: r1143512 -
/hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
Author: todd
Date: Wed Jul 6 18:03:48 2011
New Revision: 1143512
URL: http://svn.apache.org/viewvc?rev=1143512&view=rev
Log:
Add another unit test for SecondaryNameNode.
Modified:
hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
Modified: hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java?rev=1143512&r1=1143511&r2=1143512&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java (original)
+++ hadoop/common/branches/HDFS-1073/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java Wed Jul 6 18:03:48 2011
@@ -1578,6 +1578,50 @@ public class TestCheckpoint extends Test
}
+ /**
+ * Test case where the secondary does a checkpoint, then stops for a while.
+ * In the meantime, the NN saves its image several times, so that the
+ * logs that connect the 2NN's old checkpoint to the current txid
+ * get archived. Then, the 2NN tries to checkpoint again.
+ */
+ @SuppressWarnings("deprecation")
+ public void testSecondaryHasVeryOutOfDateImage() throws IOException {
+ MiniDFSCluster cluster = null;
+ SecondaryNameNode secondary = null;
+
+ Configuration conf = new HdfsConfiguration();
+
+ try {
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes)
+ .format(true).build();
+
+ secondary = startSecondaryNameNode(conf);
+
+ // Checkpoint once
+ secondary.doCheckpoint();
+
+ // Now primary NN saves namespace 3 times
+ NameNode nn = cluster.getNameNode();
+ nn.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
+ for (int i = 0; i < 3; i++) {
+ nn.saveNamespace();
+ }
+ nn.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
+
+ // Now the secondary tries to checkpoint again with its
+ // old image in memory.
+ secondary.doCheckpoint();
+
+ } finally {
+ if (secondary != null) {
+ secondary.shutdown();
+ }
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ }
+ }
+
@SuppressWarnings("deprecation")
private void cleanup(SecondaryNameNode snn) {
if (snn != null) {