Gargi-jais11 commented on code in PR #9092:
URL: https://github.com/apache/ozone/pull/9092#discussion_r2404919900


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java:
##########
@@ -169,8 +178,19 @@ public void notifyLeaderChanged(RaftGroupMemberId 
groupMemberId,
       // warmup cache
       ozoneManager.initializeEdekCache(ozoneManager.getConfiguration());
     }
+    // Store the previous leader before updating
+    RaftPeerId actualPreviousLeader = previousLeaderId;
+
+    // Update the previous leader for next time
+    previousLeaderId = newLeaderId;
     // Initialize OMHAMetrics
     ozoneManager.omHAMetricsInit(newLeaderId.toString());
+
+    Map<String, String> auditParams = new LinkedHashMap<>();
+    auditParams.put(AUDIT_PARAM_PREVIOUS_LEADER, 
String.valueOf(actualPreviousLeader));

Review Comment:
   For very first leader election after a cluster starts, the 
**previousLeaderId** will be **null**. The current code uses 
`String.valueOf(actualPreviousLeader)`, which will log the literal string 
"null". This can be a bit ambiguous for anyone reading the logs.
   So instead of **null** we can use **None** to make the log's intent clearer.
   
   ```suggestion
   auditParams.put(AUDIT_PARAM_PREVIOUS_LEADER, 
       actualPreviousLeader != null ? actualPreviousLeader.toString() : "NONE");



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