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/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a42a588e [SCB-2792]router should get properties from instance to 
decide the ro… (#3780)
9a42a588e is described below

commit 9a42a588e9fcdb3fefda6db263205e7fda1a71ae
Author: liubao68 <[email protected]>
AuthorDate: Tue May 9 14:42:59 2023 +0800

    [SCB-2792]router should get properties from instance to decide the ro… 
(#3780)
---
 demo/demo-cse-v1/pom.xml                           |  4 +
 .../apache/servicecomb/router/RouterFilter.java    |  6 +-
 .../distribute/AbstractRouterDistributor.java      | 60 +++++++--------
 .../router/distribute/RouterDistributor.java       | 11 +--
 .../servicecomb/router/ExampleDistributor.java     |  4 +-
 .../RouterDistributorDynamicConfig2Test.java       |  4 +-
 .../router/RouterDistributorDynamicConfigTest.java |  4 +-
 .../router/RouterDistributorFileConfigTest.java    |  4 +-
 ...nvokeFilter.java => RouterAddHeaderFilter.java} | 90 +++++++++++++---------
 .../router/custom/RouterServerListFilter.java      |  3 +-
 .../custom/ServiceCombRouterConfiguration.java     |  9 ++-
 ...uter.java => ServiceCombRouterDistributor.java} | 27 ++++---
 ...servicecomb.common.rest.filter.HttpServerFilter |  2 +-
 .../resources/META-INF/spring/services.bean.xml    |  1 -
 14 files changed, 129 insertions(+), 100 deletions(-)

diff --git a/demo/demo-cse-v1/pom.xml b/demo/demo-cse-v1/pom.xml
index a8f3a77a7..f4b9d965b 100644
--- a/demo/demo-cse-v1/pom.xml
+++ b/demo/demo-cse-v1/pom.xml
@@ -49,6 +49,10 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>servicestage-environment</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+    </dependency>
   </dependencies>
 
   <modules>
diff --git 
a/governance/src/main/java/org/apache/servicecomb/router/RouterFilter.java 
b/governance/src/main/java/org/apache/servicecomb/router/RouterFilter.java
index a6ec35d76..f544dd71c 100644
--- a/governance/src/main/java/org/apache/servicecomb/router/RouterFilter.java
+++ b/governance/src/main/java/org/apache/servicecomb/router/RouterFilter.java
@@ -41,8 +41,8 @@ public class RouterFilter {
     this.routerRuleCache = routerRuleCache;
   }
 
-  public <T, E> List<T> getFilteredListOfServers(List<T> list,
-      String targetServiceName, Map<String, String> headers, 
RouterDistributor<T, E> distributer) {
+  public <T> List<T> getFilteredListOfServers(List<T> list,
+      String targetServiceName, Map<String, String> headers, 
RouterDistributor<T> distributor) {
     if (CollectionUtils.isEmpty(list)) {
       return list;
     }
@@ -65,7 +65,7 @@ public class RouterFilter {
     LOGGER.debug("route management match rule success: {}", invokeRule);
 
     // 3.distribute select endpoint
-    List<T> resultList = distributer.distribute(targetServiceName, list, 
invokeRule);
+    List<T> resultList = distributor.distribute(targetServiceName, list, 
invokeRule);
 
     LOGGER.debug("route management distribute rule success: {}", resultList);
 
diff --git 
a/governance/src/main/java/org/apache/servicecomb/router/distribute/AbstractRouterDistributor.java
 
b/governance/src/main/java/org/apache/servicecomb/router/distribute/AbstractRouterDistributor.java
index d3f8f7640..4de2e6a72 100644
--- 
a/governance/src/main/java/org/apache/servicecomb/router/distribute/AbstractRouterDistributor.java
+++ 
b/governance/src/main/java/org/apache/servicecomb/router/distribute/AbstractRouterDistributor.java
@@ -33,18 +33,16 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 
-public abstract class AbstractRouterDistributor<T, E> implements
-    RouterDistributor<T, E> {
+public abstract class AbstractRouterDistributor<INSTANCE> implements
+    RouterDistributor<INSTANCE> {
 
   private static final Logger LOGGER = 
LoggerFactory.getLogger(AbstractRouterDistributor.class);
 
-  private Function<T, E> getIns;
+  private Function<INSTANCE, String> getVersion;
 
-  private Function<E, String> getVersion;
+  private Function<INSTANCE, String> getServerName;
 
-  private Function<E, String> getServerName;
-
-  private Function<E, Map<String, String>> getProperties;
+  private Function<INSTANCE, Map<String, String>> getProperties;
 
   private RouterRuleCache routerRuleCache;
 
@@ -57,7 +55,7 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
   }
 
   @Override
-  public List<T> distribute(String targetServiceName, List<T> list, 
PolicyRuleItem invokeRule) {
+  public List<INSTANCE> distribute(String targetServiceName, List<INSTANCE> 
list, PolicyRuleItem invokeRule) {
     //init LatestVersion
     initLatestVersion(targetServiceName, list);
 
@@ -65,7 +63,7 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
         
routerRuleCache.getServiceInfoCacheMap().get(targetServiceName).getLatestVersionTag());
 
     // get tag list
-    Map<TagItem, List<T>> versionServerMap = 
getDistributList(targetServiceName, list, invokeRule);
+    Map<TagItem, List<INSTANCE>> versionServerMap = 
getDistributList(targetServiceName, list, invokeRule);
 
     if (CollectionUtils.isEmpty(versionServerMap)) {
       LOGGER.debug("route management can not match any rule and route the 
latest version");
@@ -80,11 +78,9 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
   }
 
   @Override
-  public void init(Function<T, E> getIns,
-      Function<E, String> getVersion,
-      Function<E, String> getServerName,
-      Function<E, Map<String, String>> getProperties) {
-    this.getIns = getIns;
+  public void init(Function<INSTANCE, String> getVersion,
+      Function<INSTANCE, String> getServerName,
+      Function<INSTANCE, Map<String, String>> getProperties) {
     this.getVersion = getVersion;
     this.getServerName = getServerName;
     this.getProperties = getProperties;
@@ -101,18 +97,17 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
    *
    * the method getProperties() contains other field that we don't need.
    */
-  private Map<TagItem, List<T>> getDistributList(String serviceName,
-      List<T> list,
+  private Map<TagItem, List<INSTANCE>> getDistributList(String serviceName,
+      List<INSTANCE> list,
       PolicyRuleItem invokeRule) {
     String latestV = 
routerRuleCache.getServiceInfoCacheMap().get(serviceName).getLatestVersionTag()
         .getVersion();
-    Map<TagItem, List<T>> versionServerMap = new HashMap<>();
-    for (T server : list) {
+    Map<TagItem, List<INSTANCE>> versionServerMap = new HashMap<>();
+    for (INSTANCE instance : list) {
       //get server
-      E ms = getIns.apply(server);
-      if (getServerName.apply(ms).equals(serviceName)) {
+      if (getServerName.apply(instance).equals(serviceName)) {
         //most matching
-        TagItem tagItem = new TagItem(getVersion.apply(ms), 
getProperties.apply(ms));
+        TagItem tagItem = new TagItem(getVersion.apply(instance), 
getProperties.apply(instance));
         TagItem targetTag = null;
         int maxMatch = 0;
         for (RouteItem entry : invokeRule.getRoute()) {
@@ -125,19 +120,19 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
             targetTag = entry.getTagitem();
           }
         }
-        if (invokeRule.isWeightLess() && getVersion.apply(ms).equals(latestV)) 
{
+        if (invokeRule.isWeightLess() && 
getVersion.apply(instance).equals(latestV)) {
           TagItem latestVTag = 
invokeRule.getRoute().get(invokeRule.getRoute().size() - 1)
               .getTagitem();
           if (!versionServerMap.containsKey(latestVTag)) {
             versionServerMap.put(latestVTag, new ArrayList<>());
           }
-          versionServerMap.get(latestVTag).add(server);
+          versionServerMap.get(latestVTag).add(instance);
         }
         if (targetTag != null) {
           if (!versionServerMap.containsKey(targetTag)) {
             versionServerMap.put(targetTag, new ArrayList<>());
           }
-          versionServerMap.get(targetTag).add(server);
+          versionServerMap.get(targetTag).add(instance);
         }
       }
     }
@@ -145,14 +140,13 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
   }
 
 
-  public void initLatestVersion(String serviceName, List<T> list) {
+  public void initLatestVersion(String serviceName, List<INSTANCE> list) {
     String latestVersion = null;
-    for (T server : list) {
-      E ms = getIns.apply(server);
-      if (getServerName.apply(ms).equals(serviceName)) {
+    for (INSTANCE instance : list) {
+      if (getServerName.apply(instance).equals(serviceName)) {
         if (latestVersion == null || VersionCompareUtil
-            .compareVersion(latestVersion, getVersion.apply(ms)) == -1) {
-          latestVersion = getVersion.apply(ms);
+            .compareVersion(latestVersion, getVersion.apply(instance)) == -1) {
+          latestVersion = getVersion.apply(instance);
         }
       }
     }
@@ -160,11 +154,11 @@ public abstract class AbstractRouterDistributor<T, E> 
implements
     
routerRuleCache.getServiceInfoCacheMap().get(serviceName).setLatestVersionTag(tagitem);
   }
 
-  public List<T> getLatestVersionList(List<T> list, String targetServiceName) {
+  public List<INSTANCE> getLatestVersionList(List<INSTANCE> list, String 
targetServiceName) {
     String latestV = 
routerRuleCache.getServiceInfoCacheMap().get(targetServiceName)
         .getLatestVersionTag().getVersion();
-    return list.stream().filter(server ->
-        getVersion.apply(getIns.apply(server)).equals(latestV)
+    return list.stream().filter(instance ->
+        getVersion.apply(instance).equals(latestV)
     ).collect(Collectors.toList());
   }
 }
diff --git 
a/governance/src/main/java/org/apache/servicecomb/router/distribute/RouterDistributor.java
 
b/governance/src/main/java/org/apache/servicecomb/router/distribute/RouterDistributor.java
index fe5cf37b1..fa9af8fd1 100644
--- 
a/governance/src/main/java/org/apache/servicecomb/router/distribute/RouterDistributor.java
+++ 
b/governance/src/main/java/org/apache/servicecomb/router/distribute/RouterDistributor.java
@@ -19,17 +19,18 @@ package org.apache.servicecomb.router.distribute;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
+
 import org.apache.servicecomb.router.model.PolicyRuleItem;
 
 /**
  * @Author GuoYl123
  * @Date 2019/10/17
  **/
-public interface RouterDistributor<T, E> {
+public interface RouterDistributor<INSTANCE> {
 
-  void init(Function<T, E> getIns, Function<E, String> getVersion,
-      Function<E, String> getServerName,
-      Function<E, Map<String, String>> getProperties);
+  void init(Function<INSTANCE, String> getVersion,
+      Function<INSTANCE, String> getServerName,
+      Function<INSTANCE, Map<String, String>> getProperties);
 
-  List<T> distribute(String targetServiceName, List<T> list, PolicyRuleItem 
invokeRule);
+  List<INSTANCE> distribute(String targetServiceName, List<INSTANCE> list, 
PolicyRuleItem invokeRule);
 }
diff --git 
a/governance/src/test/java/org/apache/servicecomb/router/ExampleDistributor.java
 
b/governance/src/test/java/org/apache/servicecomb/router/ExampleDistributor.java
index 7c6aa04f9..42fdfad03 100644
--- 
a/governance/src/test/java/org/apache/servicecomb/router/ExampleDistributor.java
+++ 
b/governance/src/test/java/org/apache/servicecomb/router/ExampleDistributor.java
@@ -21,8 +21,8 @@ import 
org.apache.servicecomb.router.distribute.AbstractRouterDistributor;
 import org.springframework.stereotype.Component;
 
 @Component
-public class ExampleDistributor extends AbstractRouterDistributor<ServiceIns, 
ServiceIns> {
+public class ExampleDistributor extends AbstractRouterDistributor<ServiceIns> {
   public ExampleDistributor() {
-    init(a -> a, ServiceIns::getVersion, ServiceIns::getServerName, 
ServiceIns::getTags);
+    init(ServiceIns::getVersion, ServiceIns::getServerName, 
ServiceIns::getTags);
   }
 }
diff --git 
a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfig2Test.java
 
b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfig2Test.java
index f3f36e453..c3901878b 100644
--- 
a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfig2Test.java
+++ 
b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfig2Test.java
@@ -70,7 +70,7 @@ public class RouterDistributorDynamicConfig2Test {
 
   private RouterFilter routerFilter;
 
-  private RouterDistributor<ServiceIns, ServiceIns> testDistributor;
+  private RouterDistributor<ServiceIns> testDistributor;
 
   @Autowired
   public void setEnvironment(Environment environment) {
@@ -83,7 +83,7 @@ public class RouterDistributorDynamicConfig2Test {
   }
 
   @Autowired
-  public void setTestDistributor(RouterDistributor<ServiceIns, ServiceIns> 
testDistributor) {
+  public void setTestDistributor(RouterDistributor<ServiceIns> 
testDistributor) {
     this.testDistributor = testDistributor;
   }
 
diff --git 
a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfigTest.java
 
b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfigTest.java
index f57ed6579..47228c7b8 100644
--- 
a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfigTest.java
+++ 
b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorDynamicConfigTest.java
@@ -88,7 +88,7 @@ public class RouterDistributorDynamicConfigTest {
 
   private RouterFilter routerFilter;
 
-  private RouterDistributor<ServiceIns, ServiceIns> testDistributor;
+  private RouterDistributor<ServiceIns> testDistributor;
 
   @Autowired
   public void setEnvironment(Environment environment) {
@@ -101,7 +101,7 @@ public class RouterDistributorDynamicConfigTest {
   }
 
   @Autowired
-  public void setTestDistributor(RouterDistributor<ServiceIns, ServiceIns> 
testDistributor) {
+  public void setTestDistributor(RouterDistributor<ServiceIns> 
testDistributor) {
     this.testDistributor = testDistributor;
   }
 
diff --git 
a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorFileConfigTest.java
 
b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorFileConfigTest.java
index 9e5be6937..19f0f47f3 100644
--- 
a/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorFileConfigTest.java
+++ 
b/governance/src/test/java/org/apache/servicecomb/router/RouterDistributorFileConfigTest.java
@@ -36,7 +36,7 @@ public class RouterDistributorFileConfigTest {
 
   private RouterFilter routerFilter;
 
-  private RouterDistributor<ServiceIns, ServiceIns> routerDistributor;
+  private RouterDistributor<ServiceIns> routerDistributor;
 
   @Autowired
   public void setRouterFilter(RouterFilter routerFilter) {
@@ -44,7 +44,7 @@ public class RouterDistributorFileConfigTest {
   }
 
   @Autowired
-  public void setRouterDistributor(RouterDistributor<ServiceIns, ServiceIns> 
routerDistributor) {
+  public void setRouterDistributor(RouterDistributor<ServiceIns> 
routerDistributor) {
     this.routerDistributor = routerDistributor;
   }
 
diff --git 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterAddHeaderFilter.java
similarity index 77%
rename from 
handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
rename to 
handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterAddHeaderFilter.java
index b40bf543d..9dcbdebff 100644
--- 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
+++ 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterAddHeaderFilter.java
@@ -21,12 +21,18 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import javax.annotation.Nonnull;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
 import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.core.filter.Filter;
+import org.apache.servicecomb.core.filter.FilterNode;
+import org.apache.servicecomb.core.filter.ProducerFilter;
 import org.apache.servicecomb.foundation.common.utils.JsonUtils;
 import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.swagger.invocation.InvocationType;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,47 +42,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.netflix.config.DynamicPropertyFactory;
 import com.netflix.config.DynamicStringProperty;
 
-public class RouterInvokeFilter implements HttpServerFilter {
+public class RouterAddHeaderFilter implements Filter {
 
-  private static final Logger LOGGER = 
LoggerFactory.getLogger(RouterInvokeFilter.class);
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(RouterAddHeaderFilter.class);
 
   private static final String SERVICECOMB_ROUTER_HEADER = 
"servicecomb.router.header";
 
   private static List<String> allHeader = new ArrayList<>();
 
-
-  @Override
-  public int getOrder() {
-    return -90;
-  }
-
-  @Override
-  public boolean enabled() {
-    return true;
-  }
-
-  @Override
-  public Response afterReceiveRequest(Invocation invocation,
-      HttpServletRequestEx httpServletRequestEx) {
-    if 
(!StringUtils.isEmpty(invocation.getContext(RouterServerListFilter.ROUTER_HEADER)))
 {
-      return null;
-    }
-
-    if (!isHaveHeadersRule()) {
-      return null;
-    }
-    if (loadHeaders()) {
-      Map<String, String> headerMap = getHeaderMap(httpServletRequestEx);
-      try {
-        invocation
-            .addContext(RouterServerListFilter.ROUTER_HEADER, 
JsonUtils.OBJ_MAPPER.writeValueAsString(headerMap));
-      } catch (JsonProcessingException e) {
-        LOGGER.error("canary context serialization failed");
-      }
-    }
-    return null;
-  }
-
   /**
    * read config and get Header
    */
@@ -129,4 +102,49 @@ public class RouterInvokeFilter implements 
HttpServerFilter {
     });
     return headerMap;
   }
+
+  @Override
+  public int getOrder(InvocationType invocationType, String microservice) {
+    return ProducerFilter.PRODUCER_SCHEDULE_FILTER_ORDER - 1970;
+  }
+
+  @Nonnull
+  @Override
+  public boolean isEnabledForInvocationType(InvocationType invocationType) {
+    // enable for both edge and producer
+    return true;
+  }
+
+  @Nonnull
+  @Override
+  public String getName() {
+    return "router-add-header";
+  }
+
+  @Override
+  public CompletableFuture<Response> onFilter(Invocation invocation, 
FilterNode nextNode) {
+    if (!invocation.isEdge() && !invocation.isProducer()) {
+      return nextNode.onFilter(invocation);
+    }
+
+    if 
(!StringUtils.isEmpty(invocation.getContext(RouterServerListFilter.ROUTER_HEADER)))
 {
+      return nextNode.onFilter(invocation);
+    }
+
+    if (!isHaveHeadersRule()) {
+      return nextNode.onFilter(invocation);
+    }
+
+    if (loadHeaders()) {
+      Map<String, String> headerMap = getHeaderMap(invocation.getRequestEx());
+      try {
+        invocation
+            .addContext(RouterServerListFilter.ROUTER_HEADER, 
JsonUtils.OBJ_MAPPER.writeValueAsString(headerMap));
+      } catch (JsonProcessingException e) {
+        LOGGER.error("canary context serialization failed");
+      }
+    }
+
+    return nextNode.onFilter(invocation);
+  }
 }
diff --git 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterServerListFilter.java
 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterServerListFilter.java
index 0e5ae7d09..b7a3cbc7a 100644
--- 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterServerListFilter.java
+++ 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterServerListFilter.java
@@ -26,7 +26,6 @@ import 
org.apache.servicecomb.foundation.common.utils.JsonUtils;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
 import org.apache.servicecomb.loadbalance.ServerListFilterExt;
 import org.apache.servicecomb.loadbalance.ServiceCombServer;
-import org.apache.servicecomb.registry.api.registry.Microservice;
 import org.apache.servicecomb.router.RouterFilter;
 import org.apache.servicecomb.router.distribute.RouterDistributor;
 import org.slf4j.Logger;
@@ -47,7 +46,7 @@ public class RouterServerListFilter implements 
ServerListFilterExt {
   public static final String ROUTER_HEADER = "X-RouterContext";
 
   @SuppressWarnings("unchecked")
-  private final RouterDistributor<ServiceCombServer, Microservice> 
routerDistributor = BeanUtils
+  private final RouterDistributor<ServiceCombServer> routerDistributor = 
BeanUtils
       .getBean(RouterDistributor.class);
 
   private final RouterFilter routerFilter = 
BeanUtils.getBean(RouterFilter.class);
diff --git 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterConfiguration.java
 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterConfiguration.java
index 9e8a5a3fa..7d66001c1 100644
--- 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterConfiguration.java
+++ 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterConfiguration.java
@@ -29,7 +29,12 @@ public class ServiceCombRouterConfiguration {
   public static final String ROUTER_ENABLED = ROUTER_PREFIX + ".enabled";
 
   @Bean
-  public ServiceCombCanaryDistributer serviceCombCanaryDistributer() {
-    return new ServiceCombCanaryDistributer();
+  public ServiceCombRouterDistributor serviceCombRouterDistributor() {
+    return new ServiceCombRouterDistributor();
+  }
+
+  @Bean
+  public RouterAddHeaderFilter routerAddHeaderFilter() {
+    return new RouterAddHeaderFilter();
   }
 }
diff --git 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombCanaryDistributer.java
 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterDistributor.java
similarity index 55%
rename from 
handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombCanaryDistributer.java
rename to 
handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterDistributor.java
index cde6807f4..dbef3df3d 100644
--- 
a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombCanaryDistributer.java
+++ 
b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/ServiceCombRouterDistributor.java
@@ -16,18 +16,27 @@
  */
 package org.apache.servicecomb.router.custom;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.servicecomb.loadbalance.ServiceCombServer;
-import org.apache.servicecomb.registry.api.registry.Microservice;
 import org.apache.servicecomb.router.distribute.AbstractRouterDistributor;
 
-public class ServiceCombCanaryDistributer extends
-    AbstractRouterDistributor<ServiceCombServer, Microservice> {
+public class ServiceCombRouterDistributor extends
+    AbstractRouterDistributor<ServiceCombServer> {
 
-  public ServiceCombCanaryDistributer() {
-    init(server -> MicroserviceCache.getInstance()
-            .getService(server.getInstance().getServiceId()),
-        Microservice::getVersion,
-        Microservice::getServiceName,
-        Microservice::getProperties);
+  public ServiceCombRouterDistributor() {
+    init(
+        instance -> MicroserviceCache.getInstance()
+            .getService(instance.getInstance().getServiceId()).getVersion(),
+        instance -> MicroserviceCache.getInstance()
+            
.getService(instance.getInstance().getServiceId()).getServiceName(),
+        instance -> {
+          Map<String, String> properties = new HashMap<>();
+          properties.putAll(MicroserviceCache.getInstance()
+              
.getService(instance.getInstance().getServiceId()).getProperties());
+          properties.putAll(instance.getInstance().getProperties());
+          return properties;
+        });
   }
 }
diff --git 
a/handlers/handler-router/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
 
b/handlers/handler-router/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
index 02a728b19..065e42fad 100644
--- 
a/handlers/handler-router/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
+++ 
b/handlers/handler-router/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.servicecomb.router.custom.RouterInvokeFilter
\ No newline at end of file
+org.apache.servicecomb.router.custom.RouterAddHeaderFilter
\ No newline at end of file
diff --git 
a/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml 
b/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml
index bd26a5acf..eef77f2e4 100644
--- 
a/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml
+++ 
b/huawei-cloud/dashboard/src/main/resources/META-INF/spring/services.bean.xml
@@ -20,7 +20,6 @@
 
     <bean id="monitorStarterListener" 
class="org.apache.servicecomb.huaweicloud.dashboard.monitor.MonitorBootListener"></bean>
     <bean id="dataFactory" 
class="org.apache.servicecomb.huaweicloud.dashboard.monitor.DataFactory"></bean>
-    <bean id="healthMonitorDataProvider" 
class="org.apache.servicecomb.huaweicloud.dashboard.monitor.HealthMonitorDataProvider"></bean>
     <bean id="metricsMonitorDataProvider" 
class="org.apache.servicecomb.huaweicloud.dashboard.monitor.MetricsMonitorDataProvider"></bean>
     <bean id="defaultMonitorDataPublisher" 
class="org.apache.servicecomb.huaweicloud.dashboard.monitor.DefaultMonitorDataPublisher"></bean>
 </beans>

Reply via email to