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

[GitHub] liubao68 closed pull request #1037: [SCB-1080]Add a log while get empty server list

liubao68 closed pull request #1037: [SCB-1080]Add a log while get empty server list
URL: https://github.com/apache/servicecomb-java-chassis/pull/1037
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancer.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancer.java
index bcc9fea7b..4843fc911 100644
--- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancer.java
+++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancer.java
@@ -22,14 +22,19 @@
 
 import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.netflix.loadbalancer.LoadBalancerStats;
 
+
 /**
  *  A load balancer with RuleExt and ServerListFilterExt
  */
 public class LoadBalancer {
+  private static final Logger LOGGER = LoggerFactory.getLogger(LoadBalancer.class);
+
   private static AtomicInteger id = new AtomicInteger(0);
 
   private RuleExt rule;
@@ -52,8 +57,13 @@ public LoadBalancer(RuleExt rule, String microServiceName) {
 
   public ServiceCombServer chooseServer(Invocation invocation) {
     List<ServiceCombServer> servers = invocation.getLocalContext(LoadbalanceHandler.CONTEXT_KEY_SERVER_LIST);
+    int serversCount = servers.size();
     for (ServerListFilterExt filterExt : filters) {
       servers = filterExt.getFilteredListOfServers(servers, invocation);
+      if (servers.isEmpty() && serversCount > 0) {
+        LOGGER.warn("There are not servers exist after filtered by {}.", filterExt.getClass());
+        break;
+      }
     }
     return rule.choose(servers, invocation);
   }


 

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