ruanwenjun commented on code in PR #15993:
URL: 
https://github.com/apache/dolphinscheduler/pull/15993#discussion_r1599368431


##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/MasterPriorityQueue.java:
##########
@@ -80,15 +81,14 @@ public void clear() {
 
     private void refreshMasterList() {
         hostIndexMap.clear();
-        Iterator<Server> iterator = queue.iterator();
+        Server[] nQueue = queue.toArray(new Server[0]);
+        Arrays.sort(nQueue, new ServerComparator());
         int index = 0;
-        while (iterator.hasNext()) {
-            Server server = iterator.next();
+        for (Server server: nQueue) {
             String addr = NetUtils.getAddr(server.getHost(), server.getPort());
             hostIndexMap.put(addr, index);
             index += 1;
         }
-
     }

Review Comment:
   It's needed to add a private method to get the Elements from queue, and add 
UT for this.



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

Reply via email to