|
@@ -40,6 +40,7 @@ import org.apache.hadoop.hdfs.server.common.HttpGetFailedException;
|
|
import org.apache.hadoop.hdfs.server.namenode.FSImage;
|
|
import org.apache.hadoop.hdfs.server.namenode.FSImage;
|
|
import org.apache.hadoop.hdfs.server.namenode.NameNodeLayoutVersion;
|
|
import org.apache.hadoop.hdfs.server.namenode.NameNodeLayoutVersion;
|
|
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
|
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
|
|
|
+import org.apache.hadoop.test.LambdaTestUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -189,7 +190,8 @@ public class TestBootstrapStandby {
|
|
*/
|
|
*/
|
|
@Test
|
|
@Test
|
|
public void testRollingUpgradeBootstrapStandby() throws Exception {
|
|
public void testRollingUpgradeBootstrapStandby() throws Exception {
|
|
- removeStandbyNameDirs();
|
|
|
|
|
|
+ // This node is needed to create the rollback fsimage
|
|
|
|
+ cluster.restartNameNode(1);
|
|
|
|
|
|
int futureVersion = NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION - 1;
|
|
int futureVersion = NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION - 1;
|
|
|
|
|
|
@@ -208,12 +210,18 @@ public class TestBootstrapStandby {
|
|
|
|
|
|
// BootstrapStandby should fail if the node has a future version
|
|
// BootstrapStandby should fail if the node has a future version
|
|
// and the cluster isn't in rolling upgrade
|
|
// and the cluster isn't in rolling upgrade
|
|
- bs.setConf(cluster.getConfiguration(1));
|
|
|
|
|
|
+ bs.setConf(cluster.getConfiguration(2));
|
|
assertEquals("BootstrapStandby should return ERR_CODE_INVALID_VERSION",
|
|
assertEquals("BootstrapStandby should return ERR_CODE_INVALID_VERSION",
|
|
ERR_CODE_INVALID_VERSION, bs.run(new String[]{"-force"}));
|
|
ERR_CODE_INVALID_VERSION, bs.run(new String[]{"-force"}));
|
|
|
|
|
|
// Start rolling upgrade
|
|
// Start rolling upgrade
|
|
fs.rollingUpgrade(RollingUpgradeAction.PREPARE);
|
|
fs.rollingUpgrade(RollingUpgradeAction.PREPARE);
|
|
|
|
+ LambdaTestUtils.await(60000, 1000, () ->
|
|
|
|
+ fs.rollingUpgrade(RollingUpgradeAction.QUERY).createdRollbackImages());
|
|
|
|
+ // After the rollback image is created the standby is not needed
|
|
|
|
+ cluster.shutdownNameNode(1);
|
|
|
|
+ removeStandbyNameDirs();
|
|
|
|
+
|
|
nn0 = spy(nn0);
|
|
nn0 = spy(nn0);
|
|
|
|
|
|
// Make nn0 think it is a future version
|
|
// Make nn0 think it is a future version
|
|
@@ -237,6 +245,9 @@ public class TestBootstrapStandby {
|
|
|
|
|
|
long expectedCheckpointTxId = NameNodeAdapter.getNamesystem(nn0)
|
|
long expectedCheckpointTxId = NameNodeAdapter.getNamesystem(nn0)
|
|
.getFSImage().getMostRecentCheckpointTxId();
|
|
.getFSImage().getMostRecentCheckpointTxId();
|
|
|
|
+ long expectedRollbackTxId = NameNodeAdapter.getNamesystem(nn0)
|
|
|
|
+ .getFSImage().getMostRecentNameNodeFileTxId(
|
|
|
|
+ NNStorage.NameNodeFile.IMAGE_ROLLBACK);
|
|
assertEquals(11, expectedCheckpointTxId);
|
|
assertEquals(11, expectedCheckpointTxId);
|
|
|
|
|
|
for (int i = 1; i < maxNNCount; i++) {
|
|
for (int i = 1; i < maxNNCount; i++) {
|
|
@@ -245,6 +256,8 @@ public class TestBootstrapStandby {
|
|
bs.run(new String[]{"-force"});
|
|
bs.run(new String[]{"-force"});
|
|
FSImageTestUtil.assertNNHasCheckpoints(cluster, i,
|
|
FSImageTestUtil.assertNNHasCheckpoints(cluster, i,
|
|
ImmutableList.of((int) expectedCheckpointTxId));
|
|
ImmutableList.of((int) expectedCheckpointTxId));
|
|
|
|
+ FSImageTestUtil.assertNNHasRollbackCheckpoints(cluster, i,
|
|
|
|
+ ImmutableList.of((int) expectedRollbackTxId));
|
|
}
|
|
}
|
|
|
|
|
|
// Make sure the bootstrap was successful
|
|
// Make sure the bootstrap was successful
|
|
@@ -253,6 +266,14 @@ public class TestBootstrapStandby {
|
|
// We should now be able to start the standby successfully
|
|
// We should now be able to start the standby successfully
|
|
restartNameNodesFromIndex(1, "-rollingUpgrade", "started");
|
|
restartNameNodesFromIndex(1, "-rollingUpgrade", "started");
|
|
|
|
|
|
|
|
+ for (int i = 1; i < maxNNCount; i++) {
|
|
|
|
+ NameNode nn = cluster.getNameNode(i);
|
|
|
|
+ assertTrue("NameNodes should all have the rollback FSImage",
|
|
|
|
+ nn.getFSImage().hasRollbackFSImage());
|
|
|
|
+ assertTrue("NameNodes should all be inRollingUpgrade",
|
|
|
|
+ nn.getNamesystem().isRollingUpgrade());
|
|
|
|
+ }
|
|
|
|
+
|
|
// Cleanup standby dirs
|
|
// Cleanup standby dirs
|
|
for (int i = 1; i < maxNNCount; i++) {
|
|
for (int i = 1; i < maxNNCount; i++) {
|
|
cluster.shutdownNameNode(i);
|
|
cluster.shutdownNameNode(i);
|