Go ahead wrting your algorithms if possible.  Current implementation just make 
sure not using the same server, but do not consider available

????????LA <[email protected]>
????????dev <[email protected]>
???6?9????2019-10-14 21:18:35
???6?9????[DISCUSSION] Duplicate logs printed when calling 
RetryLoadBalancer#chooseServer method

Hi Team:


In servicecomb-java-chassis, when calling &nbsp;RetryLoadBalancer#chooseServer, 
the method will call LoadBalancer#chooseServer and 17 duplicate logs may be 
printed when all of the following happen:
1. There are 1 or more ServiceCombServer after getting servers from local 
context;
2. There are no ServiceCombServer remained after getting filtered list of 
servers.


Some code in&nbsp;LoadBalancer#chooseServer shown as following:
public ServiceCombServer chooseServer(Invocation invocation) {
  List<ServiceCombServer&gt; servers = 
invocation.getLocalContext(LoadbalanceHandler.CONTEXT_KEY_SERVER_LIST);
  int serversCount = servers.size();
  for (ServerListFilterExt filterExt : filters) {
    servers = filterExt.getFilteredListOfServers(servers, invocation);
    if (servers.isEmpty() &amp;&amp; serversCount &gt; 0) {
      LOGGER.warn("There are not servers exist after filtered by {}.", 
filterExt.getClass());
      break;
    }
  }


Related code in&nbsp;RetryLoadBalancer#chooseServer shown as following:
public Server chooseServer(Object key) {
  boolean isRetry = null != lastServer;
  for (int i = 0; i < COUNT; i++) {
    Server s = delegate.chooseServer((Invocation) key);
    if (s != null &amp;&amp; !s.equals(lastServer)) {
      lastServer = s;
      break;
    }
  }


It seems that the goal of retrying server seventeen times is to make sure 
accessing some server which is different from the current server. But if there 
are no any servers after getting filter list of servers, it makes no sense to 
retry more servers.


I want to add conditional statement to stop retrying another server when no 
server available in&nbsp;RetryLoadBalancer#chooseServer to solve it but not 
sure whether I am correct.
-------------------------------------------------------Ang Li

Reply via email to