/** * While boostrapping, in_progress transaction entries should be skipped. * Bootstrap usage for BKJM : "-force", "-nonInteractive", "-skipSharedEditsCheck" */ @Test public void testBootstrapStandbyWithActiveNN() throws Exception { // 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(SafeModeAction.SAFEMODE_ENTER, true); cluster.getNameNodeRpc(0).saveNamespace(); cluster.getNameNodeRpc(0).setSafeMode(SafeModeAction.SAFEMODE_LEAVE, true); // check without -skipSharedEditsCheck, Bootstrap should fail for BKJM // immediately after saveNamespace int rc = BootstrapStandby.run(new String[] { "-force", "-nonInteractive" }, confNN1); Assert.assertEquals("Mismatches return code", 6, rc); // check with -skipSharedEditsCheck rc = BootstrapStandby.run(new String[] { "-force", "-nonInteractive", "-skipSharedEditsCheck" }, confNN1); Assert.assertEquals("Mismatches return code", 0, rc); // Checkpoint as fast as we can, in a tight loop. confNN1.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_PERIOD_KEY, 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); }
/** * While boostrapping, in_progress transaction entries should be skipped. * Bootstrap usage for BKJM : "-force", "-nonInteractive", "-skipSharedEditsCheck" */ @Test public void testBootstrapStandbyWithActiveNN() throws Exception { // 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(SafeModeAction.SAFEMODE_ENTER, true); cluster.getNameNodeRpc(0).saveNamespace(0, 0); cluster.getNameNodeRpc(0).setSafeMode(SafeModeAction.SAFEMODE_LEAVE, true); // check without -skipSharedEditsCheck, Bootstrap should fail for BKJM // immediately after saveNamespace int rc = BootstrapStandby.run(new String[] { "-force", "-nonInteractive" }, confNN1); Assert.assertEquals("Mismatches return code", 6, rc); // check with -skipSharedEditsCheck rc = BootstrapStandby.run(new String[] { "-force", "-nonInteractive", "-skipSharedEditsCheck" }, confNN1); Assert.assertEquals("Mismatches return code", 0, rc); // Checkpoint as fast as we can, in a tight loop. confNN1.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_PERIOD_KEY, 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); }