You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/12/30 12:17:32 UTC

[GitHub] licl2014 opened a new issue #6790: chooseBestServer bug in CostBalancerStrategy

licl2014 opened a new issue #6790: chooseBestServer bug in CostBalancerStrategy
URL: https://github.com/apache/incubator-druid/issues/6790
 
 
   Related code as follows:
   
   >     try {
   >      for (Pair<Double, ServerHolder> server : resultsFuture.get()) {
   >        if (server.lhs <= bestServers.get(0).lhs) {
   >          if (server.lhs < bestServers.get(0).lhs) {
   >           bestServers.clear();
   >          }
   >          bestServers.add(server);
   >        }
   >      }
   >      // Randomly choose a server from the best servers
   >      bestServer = bestServers.get(ThreadLocalRandom.current().nextInt(bestServers.size()));
   >    }
   
   Hereļ¼Œ we're not considering if `resultsFuture.get()` has one element. i have a simple fix.
   
   >     try {
   >      List<Pair<Double, ServerHolder>> servers = resultsFuture.get();
   >      if (servers.size() == 1) {
   >        if (servers.get(0).lhs < bestServers.get(0).lhs) {
   >          bestServers.clear();
   >          bestServers.add(servers.get(0));
   >        }
   >      } else {
   >        for (Pair<Double, ServerHolder> server : servers) {
   >          if (server.lhs <= bestServers.get(0).lhs) {
   >            if (server.lhs < bestServers.get(0).lhs) {
   >              bestServers.clear();
   >            }
   >            bestServers.add(server);
   >          }
   >        }
   >      }
   >      // Randomly choose a server from the best servers
   >      bestServer = bestServers.get(ThreadLocalRandom.current().nextInt(bestServers.size()));
   >    }

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org