wary commented on code in PR #329:
URL: 
https://github.com/apache/doris-spark-connector/pull/329#discussion_r2191368521


##########
spark-doris-connector/spark-doris-connector-base/src/main/java/org/apache/doris/spark/util/LoadBalanceList.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.doris.spark.util;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+
+public class LoadBalanceList<T> implements Iterable<T> {
+
+       private final List<T> list;
+
+       public LoadBalanceList(List<T> servers) {
+               this.list = Collections.unmodifiableList(servers);
+       }
+
+       @Override
+       public Iterator<T> iterator() {
+               return new Iterator<T>() {
+                       final int offset = Math.abs(new Random().nextInt());

Review Comment:
   Yes, similar to the effect of direct randomness; compare last version which 
using Collections.shuffe(list), I think the performance should be slightly 
better. Any way, I think it can achieve load balancing effects. Additionally, 
by reporting the failed node through the method reportFailed, LoadBalanceList 
will automatically prioritize nodes without issues, achieving the same effect 
as the collection pool's heartbeat mechanism, and it is more lightweight and 
suitable for the current scenario.
    



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