public virtual void TestBootstrapStandbyWithActiveNN() { // make nn0 active cluster.TransitionToActive(0); // do ops and generate in-progress edit log data Configuration confNN1 = cluster.GetConfiguration(1); DistributedFileSystem dfs = (DistributedFileSystem)HATestUtil.ConfigureFailoverFs (cluster, confNN1); for (int i = 1; i <= 10; i++) { dfs.Mkdirs(new Path("/test" + i)); } dfs.Close(); // shutdown nn1 and delete its edit log files cluster.ShutdownNameNode(1); DeleteEditLogIfExists(confNN1); cluster.GetNameNodeRpc(0).SetSafeMode(HdfsConstants.SafeModeAction.SafemodeEnter, true); cluster.GetNameNodeRpc(0).SaveNamespace(); cluster.GetNameNodeRpc(0).SetSafeMode(HdfsConstants.SafeModeAction.SafemodeLeave, true); // check without -skipSharedEditsCheck, Bootstrap should fail for BKJM // immediately after saveNamespace int rc = BootstrapStandby.Run(new string[] { "-force", "-nonInteractive" }, confNN1 ); NUnit.Framework.Assert.AreEqual("Mismatches return code", 6, rc); // check with -skipSharedEditsCheck rc = BootstrapStandby.Run(new string[] { "-force", "-nonInteractive", "-skipSharedEditsCheck" }, confNN1); NUnit.Framework.Assert.AreEqual("Mismatches return code", 0, rc); // Checkpoint as fast as we can, in a tight loop. confNN1.SetInt(DFSConfigKeys.DfsNamenodeCheckpointPeriodKey, 1); cluster.RestartNameNode(1); cluster.TransitionToStandby(1); NameNode nn0 = cluster.GetNameNode(0); HATestUtil.WaitForStandbyToCatchUp(nn0, cluster.GetNameNode(1)); long expectedCheckpointTxId = NameNodeAdapter.GetNamesystem(nn0).GetFSImage().GetMostRecentCheckpointTxId (); HATestUtil.WaitForCheckpoint(cluster, 1, ImmutableList.Of((int)expectedCheckpointTxId )); // Should have copied over the namespace FSImageTestUtil.AssertNNHasCheckpoints(cluster, 1, ImmutableList.Of((int)expectedCheckpointTxId )); FSImageTestUtil.AssertNNFilesMatch(cluster); }