You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2018/09/11 09:27:48 UTC

[incubator-dubbo] 02/03: Improve the route logic.

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

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit 612e3acd1fc1c2b26f7e72c5a0b91f03e4a2a898
Author: ken.lj <ke...@gmail.com>
AuthorDate: Tue Sep 11 17:26:53 2018 +0800

    Improve the route logic.
---
 .../java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java | 3 +++
 .../rpc/cluster/router/condition/config/ConfigConditionRouter.java | 2 +-
 .../java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java    | 7 +++----
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java
index 5ce835b..fbad2b4 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java
@@ -43,6 +43,9 @@ public class InvokerTreeCache<T> {
 
     public List<Invoker<T>> getInvokers(TreeNode<T> node, URL url, Invocation invocation) {
         // We have reached the leaf node.
+        if (node == null) {
+            return Collections.emptyList();
+        }
         if (node.isLeaf()) {
             return node.getInvokers();
         }
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/ConfigConditionRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/ConfigConditionRouter.java
index f6f1cc3..8605afe 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/ConfigConditionRouter.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/config/ConfigConditionRouter.java
@@ -42,7 +42,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * TODO only support one router rule =>, it will be inconvenient if we want to add more than one rules.
+ *
  */
 public class ConfigConditionRouter extends AbstractRouter implements ConfigurationListener {
     public static final String NAME = "CONFIG_CONDITION_OUTER";
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java
index 6ec6b31..c970974 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java
@@ -38,7 +38,6 @@ import org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule;
 import org.apache.dubbo.rpc.cluster.router.tag.model.TagRuleParser;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -225,7 +224,7 @@ public class TagRouter extends AbstractRouter implements Comparable<Router>, Con
         });
 
         // Now, FAILOVER key is required here.
-        map.putIfAbsent(TreeNode.FAILOVER_KEY, Collections.emptyList());
+//        map.putIfAbsent(TreeNode.FAILOVER_KEY, Collections.emptyList());
 
         return map;
     }
@@ -250,9 +249,9 @@ public class TagRouter extends AbstractRouter implements Comparable<Router>, Con
 
     @Override
     public String getKey() {
-        if (isRuntime()) {
+        /*if (isRuntime()) {
             return super.getKey();
-        }
+        }*/
         return Constants.TAG_KEY;
     }