diecui1202 commented on issue #934: Extension of  LoadBalance (a small 
suggestion for loadbalance policy when there's less than 2 providers)
URL: https://github.com/apache/incubator-dubbo/issues/934#issuecomment-386971248
 
 
   After discussing with @chickenlj , we decide to remove 140-142 lines, as the 
following shows: 
   
   ```java
   private Invoker<T> doSelect(LoadBalance loadbalance, Invocation invocation, 
List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
           if (invokers == null || invokers.isEmpty())
               return null;
           if (invokers.size() == 1)
               return invokers.get(0);
           // If we only have two invokers, use round-robin instead.
           //if (invokers.size() == 2 && selected != null && 
!selected.isEmpty()) {
           //    return selected.get(0) == invokers.get(0) ? invokers.get(1) : 
invokers.get(0);
           //}
           if (loadbalance == null) {
               loadbalance = 
ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(Constants.DEFAULT_LOADBALANCE);
           }
           Invoker<T> invoker = loadbalance.select(invokers, getUrl(), 
invocation);
   
           //If the `invoker` is in the  `selected` or invoker is unavailable 
&& availablecheck is true, reselect.
           if ((selected != null && selected.contains(invoker))
   ```
   
   Because the `selected` param is only not null when retry or in 
ForkingClusterInvoker. And the reselect function will finally select a 
avaliable invoker. 
   
   So these 3 lines code seems unnecessary. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to