xiaoyuyao commented on a change in pull request #1191:
URL: https://github.com/apache/hadoop-ozone/pull/1191#discussion_r463348101



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAManagerImpl.java
##########
@@ -67,6 +101,44 @@ public SCMRatisServer getRatisServer() {
     return ratisServer;
   }
 
+  private RaftPeerId getPeerIdFromRoleInfo(RaftServerImpl serverImpl) {
+    if (serverImpl.isLeader()) {
+      return RaftPeerId.getRaftPeerId(
+          serverImpl.getRoleInfoProto().getLeaderInfo().toString());
+    } else if (serverImpl.isFollower()) {
+      return RaftPeerId.valueOf(
+          serverImpl.getRoleInfoProto().getFollowerInfo()
+              .getLeaderInfo().getId().getId());
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public RaftPeer getSuggestedLeader() {
+    RaftServer server = ratisServer.getServer();
+    Preconditions.checkState(server instanceof RaftServerProxy);
+    RaftServerImpl serverImpl = null;
+    try {
+      // SCM only has one raft group.
+      serverImpl = ((RaftServerProxy) server)
+          .getImpl(ratisServer.getRaftGroupId());
+    } catch (IOException ioe) {
+      LOG.error("Fail to get RaftServer impl and therefore it's not clear " +
+          "whether it's leader. ", ioe);
+    } finally {
+      if (serverImpl != null) {

Review comment:
       Same as above, can we move this to the try block?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to