diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java index bef743b5ccb5..3ee400a01f20 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java @@ -294,6 +294,14 @@ public void pause() { getLifeCycle().transition(LifeCycle.State.PAUSED); } + @Override + public void reinitialize() { + if (getLifeCycleState() == LifeCycle.State.PAUSED) { + getLifeCycle().transition(LifeCycle.State.STARTING); + getLifeCycle().transition(LifeCycle.State.RUNNING); + } + } + @Override public void close() throws IOException { if (!isInitialized) { diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSCMInstallSnapshotWithHA.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSCMInstallSnapshotWithHA.java index a0196c98e436..1ecc50c8c2da 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSCMInstallSnapshotWithHA.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSCMInstallSnapshotWithHA.java @@ -45,6 +45,7 @@ import org.apache.ratis.server.protocol.TermIndex; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import org.junit.Assert; import org.junit.jupiter.api.AfterEach; @@ -121,7 +122,7 @@ public void testInstallSnapshot() throws Exception { // Find the inactive SCM String followerId = getInactiveSCM(cluster).getScmId(); - StorageContainerManager follower = cluster.getSCM(followerId); + StorageContainerManager followerSCM = cluster.getSCM(followerId); // Do some transactions so that the log index increases List containers = writeToIncreaseLogIndex(leaderSCM, 200); @@ -131,15 +132,16 @@ public void testInstallSnapshot() throws Exception { cluster.startInactiveSCM(followerId); // The recently started should be lagging behind the leader . + SCMStateMachine followerSM = + followerSCM.getScmHAManager().getRatisServer().getSCMStateMachine(); long followerLastAppliedIndex = - follower.getScmHAManager().getRatisServer().getSCMStateMachine() - .getLastAppliedTermIndex().getIndex(); - assertTrue( - followerLastAppliedIndex >= 200); + followerSM.getLastAppliedTermIndex().getIndex(); + assertTrue(followerLastAppliedIndex >= 200); + assertFalse(followerSM.getLifeCycleState().isPausingOrPaused()); // Verify that the follower 's DB contains the transactions which were // made while it was inactive. - SCMMetadataStore followerMetaStore = follower.getScmMetadataStore(); + SCMMetadataStore followerMetaStore = followerSCM.getScmMetadataStore(); for (ContainerInfo containerInfo : containers) { Assert.assertNotNull(followerMetaStore.getContainerTable() .get(containerInfo.containerID())); @@ -154,9 +156,9 @@ public void testInstallOldCheckpointFailure() throws Exception { String followerId = getInactiveSCM(cluster).getScmId(); // Find the inactive SCM - StorageContainerManager follower = cluster.getSCM(followerId); + StorageContainerManager followerSCM = cluster.getSCM(followerId); cluster.startInactiveSCM(followerId); - follower.exitSafeMode(); + followerSCM.exitSafeMode(); DBCheckpoint leaderDbCheckpoint = leaderSCM.getScmMetadataStore().getStore() .getCheckpoint(false); @@ -165,8 +167,8 @@ public void testInstallOldCheckpointFailure() throws Exception { TermIndex lastTermIndex = leaderSM.getLastAppliedTermIndex(); SCMStateMachine followerSM = - follower.getScmHAManager().getRatisServer().getSCMStateMachine(); - follower.getScmMetadataStore().getTransactionInfoTable(). + followerSCM.getScmHAManager().getRatisServer().getSCMStateMachine(); + followerSCM.getScmMetadataStore().getTransactionInfoTable(). put(OzoneConsts.TRANSACTION_INFO_KEY, TransactionInfo.builder() .setCurrentTerm(lastTermIndex.getTerm()) .setTransactionIndex(lastTermIndex.getIndex() + 100).build()); @@ -183,7 +185,7 @@ public void testInstallOldCheckpointFailure() throws Exception { // state should be reloaded. TermIndex followerTermIndex = followerSM.getLastAppliedTermIndex(); SCMHAManagerImpl scmhaManager = - (SCMHAManagerImpl) (follower.getScmHAManager()); + (SCMHAManagerImpl) (followerSCM.getScmHAManager()); TermIndex newTermIndex = scmhaManager.installCheckpoint(leaderNodeId, leaderDbCheckpoint); diff --git a/pom.xml b/pom.xml index 2a38358afe9b..f044ab6eac96 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs ${ozone.version} - 2.1.0-43915d2-SNAPSHOT + 2.1.0-ff8aa66-SNAPSHOT 0.7.0-a398b19-SNAPSHOT