You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/08/14 08:52:00 UTC

[incubator-servicecomb-java-chassis] 02/03: [SCB-802]minor fix, add a log to better analyze no server problem

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 5f813c998af5286096aadf1d2f1c89f1a7158d7e
Author: liubao <ba...@huawei.com>
AuthorDate: Wed Aug 8 10:35:19 2018 +0800

    [SCB-802]minor fix, add a log to better analyze no server problem
---
 .../apache/servicecomb/loadbalance/LoadBalancerCreator.java    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancerCreator.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancerCreator.java
index 78baad4..eedbb9c 100644
--- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancerCreator.java
+++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadBalancerCreator.java
@@ -22,6 +22,8 @@ import java.util.List;
 
 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.IRule;
@@ -43,6 +45,8 @@ import com.netflix.loadbalancer.WeightedResponseTimeRule;
  *  on the result of ServerListFilter, they should not contain operation level state information in instance fields.
  */
 public class LoadBalancerCreator {
+  private static final Logger LOGGER = LoggerFactory.getLogger(LoadBalancerCreator.class);
+
   private List<Server> serverList = Collections.emptyList();
 
   private IRule rule;
@@ -72,6 +76,9 @@ public class LoadBalancerCreator {
   // serverList almost not changed for different invocation
   // so every invocation will call setServerList, this is no problem
   public void setServerList(List<Server> serverList) {
+    if (serverList.isEmpty()) {
+      LOGGER.warn("Set empty server list.");
+    }
     this.serverList = Collections.unmodifiableList(serverList);
   }
 
@@ -86,6 +93,9 @@ public class LoadBalancerCreator {
     for (ServerListFilterExt filter : this.filters) {
       filter.setLoadBalancer(loadBalancer);
       servers = filter.getFilteredListOfServers(servers, invocation);
+      if (servers.isEmpty()) {
+        LOGGER.warn("Filter {} get empty list.", filter.getClass().getName());
+      }
     }
     loadBalancer.setServerList(servers);
     return loadBalancer;