GlenGeng commented on a change in pull request #1737:
URL: https://github.com/apache/ozone/pull/1737#discussion_r551107014
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java
##########
@@ -89,4 +103,27 @@ private Message process(final SCMRatisRequest request)
}
}
+ @Override
+ public void notifyNotLeader(Collection<TransactionContext> pendingEntries) {
+ LOG.info("current leader SCM steps down.");
+ scm.getScmContext().updateIsLeaderAndTerm(false, 0);
+ }
+
+ @Override
+ public void notifyLeaderChanged(RaftGroupMemberId groupMemberId,
+ RaftPeerId newLeaderId) {
+ if (!groupMemberId.getPeerId().equals(newLeaderId)) {
+ LOG.info("leader changed, yet current SCM is still follower.");
+ return;
+ }
+
+ long term = scm.getScmHAManager()
+ .getRatisServer()
+ .getDivision()
+ .getInfo()
+ .getCurrentTerm();
Review comment:
We use SCMContext to encapsulate raft related info, so that components
in SCM won't need to hold a reference of SCMHAManager or SCMRatisServer.
For non-HA mode or unit test, we just need an empty SCMContext, instead of a
mocked SCMHAManager or a mocked SCMRatisServer.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]