neils-dev commented on code in PR #4140:
URL: https://github.com/apache/ozone/pull/4140#discussion_r1112477407


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -1826,6 +1828,20 @@ public void updatePeerList(List<String> newPeers) {
         }
       }
     }
+    String leaderId = "";
+    if (isRatisEnabled) {
+      RaftPeer leader = null;
+      try {
+        leader = omRatisServer.getLeader();
+      } catch (IOException ex) {
+        LOG.error("IOException while getting the " +
+            "Ratis server leader.", ex);
+      }
+      if (Objects.nonNull(leader)) {
+        leaderId = leader.getId().toString();
+      }
+    }
+    omHAMetricsInit(leaderId);

Review Comment:
   > If leaderId is empty, then there is no leader and setting state to 
follower seems reasonable to me.
   
   Thanks @xBis7 for the comments on this.  In this case, the leader is 
undefined.  Undefined in neither follower nor leader.  We should indicate this 
as such in the `OMHAMetrics `- handling this empty string `leaderId` in the 
`OMHAMetrics.create()`, checking the condition here and _not_ callling 
`omHAMetricsInit()` or similar.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to