ralf0131 commented on a change in pull request #2586: Optimize 
RoundRobinLoadBalance
URL: https://github.com/apache/incubator-dubbo/pull/2586#discussion_r223030536
 
 

 ##########
 File path: 
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/RoundRobinLoadBalance.java
 ##########
 @@ -21,83 +21,64 @@
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 
-import java.util.LinkedHashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 /**
  * Round robin load balance.
- *
  */
 public class RoundRobinLoadBalance extends AbstractLoadBalance {
 
     public static final String NAME = "roundrobin";
 
     private final ConcurrentMap<String, AtomicPositiveInteger> sequences = new 
ConcurrentHashMap<String, AtomicPositiveInteger>();
 
+    private final ConcurrentMap<String, AtomicPositiveInteger> indexSeqs = new 
ConcurrentHashMap<String, AtomicPositiveInteger>();
+
     @Override
     protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, 
Invocation invocation) {
         String key = invokers.get(0).getUrl().getServiceKey() + "." + 
invocation.getMethodName();
         int length = invokers.size(); // Number of invokers
         int maxWeight = 0; // The maximum weight
         int minWeight = Integer.MAX_VALUE; // The minimum weight
-        final LinkedHashMap<Invoker<T>, IntegerWrapper> invokerToWeightMap = 
new LinkedHashMap<Invoker<T>, IntegerWrapper>();
-        int weightSum = 0;
+        final List<Invoker<T>> invokerToWeightList = new ArrayList<>();
 
 Review comment:
   The name `invokerToWeightList` can be improved. I think 
`weightedInvokerList` or `nonZeroWeightedInvokers`  should be better. :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to