This is an automated email from the ASF dual-hosted git repository.

yiyang0203 pushed a commit to branch notifyLeaderReady
in repository https://gitbox.apache.org/repos/asf/ozone.git

commit a37ab65c2885e845bd5cc830e0dee14396258f02
Author: Symious <[email protected]>
AuthorDate: Mon Apr 15 10:21:02 2024 +0800

    Change to use notifyLeaderReady
---
 .../apache/hadoop/hdds/scm/ha/SCMStateMachine.java | 41 +++++++++++-----------
 1 file changed, 21 insertions(+), 20 deletions(-)

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 9d9bf07fda..99b1de317a 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
@@ -352,30 +352,31 @@ public class SCMStateMachine extends BaseStateMachine {
     if (transactionBuffer != null) {
       transactionBuffer.updateLatestTrxInfo(TransactionInfo.valueOf(term, 
index));
     }
+  }
 
-    if (currentLeaderTerm.get() == term) {
-      // On leader SCM once after it is ready, notify SCM services and also set
-      // leader ready  in SCMContext.
-      if (scm.getScmHAManager().getRatisServer().getDivision().getInfo()
-          .isLeaderReady()) {
-        scm.getScmContext().setLeaderReady();
-        scm.getSCMServiceManager().notifyStatusChanged();
-        scm.getFinalizationManager().onLeaderReady();
-      }
+  @Override
+  public void notifyLeaderRead() {
+    // On leader SCM once after it is ready, notify SCM services and also set
+    // leader ready  in SCMContext.
+    if (scm.getScmHAManager().getRatisServer().getDivision().getInfo()
+        .isLeaderReady()) {
+      scm.getScmContext().setLeaderReady();
+      scm.getSCMServiceManager().notifyStatusChanged();
+      scm.getFinalizationManager().onLeaderReady();
+    }
 
-      // Means all transactions before this term have been applied.
-      // This means after a restart, all pending transactions have been 
applied.
-      // Perform
-      // 1. Refresh Safemode rules state.
-      // 2. Start DN Rpc server.
-      if (!refreshedAfterLeaderReady.get()) {
-        scm.getScmSafeModeManager().refresh();
-        scm.getDatanodeProtocolServer().start();
+    // Means all transactions before this term have been applied.
+    // This means after a restart, all pending transactions have been applied.
+    // Perform
+    // 1. Refresh Safemode rules state.
+    // 2. Start DN Rpc server.
+    if (!refreshedAfterLeaderReady.get()) {
+      scm.getScmSafeModeManager().refresh();
+      scm.getDatanodeProtocolServer().start();
 
-        refreshedAfterLeaderReady.set(true);
-      }
-      currentLeaderTerm.set(-1L);
+      refreshedAfterLeaderReady.set(true);
     }
+    currentLeaderTerm.set(-1L);
   }
 
   @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to