You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "neils-dev (via GitHub)" <gi...@apache.org> on 2023/02/07 00:03:04 UTC

[GitHub] [ozone] neils-dev commented on a diff in pull request #3409: HDDS-6743. Specify leader node for OM failover

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


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProviderBase.java:
##########
@@ -172,12 +175,23 @@ public RetryAction shouldRetry(Exception exception, int retries,
           OMNotLeaderException notLeaderException =
               getNotLeaderException(exception);
           if (notLeaderException != null) {
-            // TODO: NotLeaderException should include the host
-            //  address of the suggested leader along with the nodeID.
-            //  Failing over just based on nodeID is not very robust.
-
             // Prepare the next OM to be tried. This will help with calculation
             // of the wait times needed get creating the retryAction.
+            if (notLeaderException.getSuggestedLeaderAddress() != null &&
+                notLeaderException.getSuggestedLeaderNodeId() != null) {
+              String suggestedLeaderAddress =
+                  notLeaderException.getSuggestedLeaderAddress();
+              String suggestedNodeId =
+                  notLeaderException.getSuggestedLeaderNodeId();
+              if (omNodeAddressMap.containsKey(suggestedNodeId) &&

Review Comment:
   _Instead_ of calling `notLeaderException.getSuggestedLeaderAddress() `and `getSuggestedLeaderNodeId() ` twice, first checking if non-null then setting variables `suggestedLeaderAddress` and `suggestedNodeID`, _we can just_ call once setting the local variables and check if variables are non-null later before `setNextOmProxy()`.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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