dengzhhu653 commented on code in PR #6142:
URL: https://github.com/apache/hive/pull/6142#discussion_r2464393374


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/leader/LeaderElectionContext.java:
##########
@@ -97,40 +95,32 @@ private LeaderElectionContext(String servHost, 
Configuration conf,
   }
 
   public void start() throws Exception {
-    Map<TTYPE, List<LeadershipStateListener>> listenerMap = this.listeners;
-    if (conf.getBoolean(LEADER_IN_TEST, false)) {
-      Map<TTYPE, List<LeadershipStateListener>> newListeners = new HashMap<>();
-      newListeners.put(TTYPE.HOUSEKEEPING, new ArrayList<>());
-      listenerMap.forEach((k, v) -> 
newListeners.get(TTYPE.HOUSEKEEPING).addAll(v));
-      listenerMap = newListeners;
-    }
-    for (Map.Entry<TTYPE, List<LeadershipStateListener>> entry :
-        listenerMap.entrySet()) {
-      List<LeadershipStateListener> listenerList = entry.getValue();
+    List<TTYPE> ttypes = new ArrayList<>(listeners.keySet());
+    Collections.shuffle(ttypes);

Review Comment:
   there are two types of leaders, shuffling the types let other HMS instances 
have a chance to win the election on different types.



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