Browse Source

HDFS-1910. NameNdoe should not save fsimage twice. Contributed by Konstantin Shvachko.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1225333 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko 13 years ago
parent
commit
5836feb4a0

+ 2 - 0
hdfs/CHANGES.txt

@@ -12,6 +12,8 @@ Release 0.22.1 - Unreleased
 
   BUG FIXES
 
+    HDFS-1910. NameNdoe should not save fsimage twice. (shv)
+
 Release 0.22.0 - 2011-11-29
 
   INCOMPATIBLE CHANGES

+ 1 - 1
hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java

@@ -1421,7 +1421,7 @@ public class FSImage extends Storage {
   void rollFSImage(CheckpointSignature sig, 
       boolean renewCheckpointTime) throws IOException {
     sig.validateStorageInfo(this);
-    rollFSImage(true);
+    rollFSImage(renewCheckpointTime);
   }
 
   private void rollFSImage(boolean renewCheckpointTime)

+ 12 - 0
hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java

@@ -155,6 +155,18 @@ public class TestBackupNode {
           THIS_HOST + ":0");
       backup = startBackupNode(conf, op, 1);
       waitCheckpointDone(backup);
+
+      // Verify fstime files are identical in case of BN and not in case of CN
+      FSImage imageNN = cluster.getNameNode().getFSImage();
+      long cpTimeNN = imageNN.readCheckpointTime(imageNN.dirIterator().next());
+      FSImage imageBN = backup.getFSImage();
+      long cpTimeBN = imageBN.readCheckpointTime(imageBN.dirIterator().next());
+      assertTrue(
+          op == StartupOption.BACKUP ?
+              "NN should have the same checkpointTime as BN" :
+                "NN should have different checkpointTime from CN", 
+          op == StartupOption.BACKUP && cpTimeNN == cpTimeBN ||
+          op == StartupOption.CHECKPOINT && cpTimeNN != cpTimeBN);
     } catch(IOException e) {
       LOG.error("Error in TestBackupNode:", e);
       assertTrue(e.getLocalizedMessage(), false);