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 38fd6166effc..a5092bfa2570 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 @@ -64,7 +64,7 @@ public List> route(List> invokers, URL url, Invocation List> result = new ArrayList<>(); try { // Dynamic param - String tag = RpcContext.getContext().getAttachment(Constants.REQUEST_TAG_KEY); + String tag = RpcContext.getContext().getAttachment(Constants.TAG_KEY); // Tag request if (!StringUtils.isEmpty(tag)) { // Select tag invokers first diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouterTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouterTest.java index 839af44efe9f..5b7bd4a3334f 100644 --- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouterTest.java +++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouterTest.java @@ -54,15 +54,15 @@ public void setUp() throws Exception { @Test public void testRoute_matchTag() { - RpcContext.getContext().setAttachment(Constants.REQUEST_TAG_KEY, "red"); + RpcContext.getContext().setAttachment(Constants.TAG_KEY, "red"); List> invokers = new ArrayList<>(); Invoker redInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.1:20880/com.foo.BarService?tag=red")); + "dubbo://10.20.3.1:20880/com.foo.BarService?dubbo.tag=red")); Invoker yellowInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.2:20880/com.foo.BarService?tag=yellow")); + "dubbo://10.20.3.2:20880/com.foo.BarService?dubbo.tag=yellow")); Invoker blueInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.3:20880/com.foo.BarService?tag=blue")); + "dubbo://10.20.3.3:20880/com.foo.BarService?dubbo.tag=blue")); Invoker defaultInvoker = new MockInvoker<>(URL.valueOf( "dubbo://10.20.3.4:20880/com.foo.BarService")); @@ -82,15 +82,15 @@ public void testRoute_matchTag() { @Test public void testRoute_matchDefault() { - RpcContext.getContext().setAttachment(Constants.REQUEST_TAG_KEY, ""); + RpcContext.getContext().setAttachment(Constants.TAG_KEY, ""); List> invokers = new ArrayList<>(); Invoker redInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.1:20880/com.foo.BarService?tag=red")); + "dubbo://10.20.3.1:20880/com.foo.BarService?dubbo.tag=red")); Invoker yellowInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.2:20880/com.foo.BarService?tag=yellow")); + "dubbo://10.20.3.2:20880/com.foo.BarService?dubbo.tag=yellow")); Invoker blueInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.3:20880/com.foo.BarService?tag=blue")); + "dubbo://10.20.3.3:20880/com.foo.BarService?dubbo.tag=blue")); Invoker defaultInvoker = new MockInvoker<>(URL.valueOf( "dubbo://10.20.3.4:20880/com.foo.BarService")); @@ -110,15 +110,15 @@ public void testRoute_matchDefault() { @Test public void testRoute_requestWithTag_shouldDowngrade() { - RpcContext.getContext().setAttachment(Constants.REQUEST_TAG_KEY, "black"); + RpcContext.getContext().setAttachment(Constants.TAG_KEY, "black"); List> invokers = new ArrayList<>(); Invoker redInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.1:20880/com.foo.BarService?tag=red")); + "dubbo://10.20.3.1:20880/com.foo.BarService?dubbo.tag=red")); Invoker yellowInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.2:20880/com.foo.BarService?tag=yellow")); + "dubbo://10.20.3.2:20880/com.foo.BarService?dubbo.tag=yellow")); Invoker blueInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.3:20880/com.foo.BarService?tag=blue")); + "dubbo://10.20.3.3:20880/com.foo.BarService?dubbo.tag=blue")); Invoker defaultInvoker = new MockInvoker<>(URL.valueOf( "dubbo://10.20.3.4:20880/com.foo.BarService")); @@ -138,15 +138,15 @@ public void testRoute_requestWithTag_shouldDowngrade() { @Test public void testRoute_requestWithoutTag_shouldNotDowngrade() { - RpcContext.getContext().setAttachment(Constants.REQUEST_TAG_KEY, ""); + RpcContext.getContext().setAttachment(Constants.TAG_KEY, ""); List> invokers = new ArrayList<>(); Invoker redInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.1:20880/com.foo.BarService?tag=red")); + "dubbo://10.20.3.1:20880/com.foo.BarService?dubbo.tag=red")); Invoker yellowInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.2:20880/com.foo.BarService?tag=yellow")); + "dubbo://10.20.3.2:20880/com.foo.BarService?dubbo.tag=yellow")); Invoker blueInvoker = new MockInvoker<>(URL.valueOf( - "dubbo://10.20.3.3:20880/com.foo.BarService?tag=blue")); + "dubbo://10.20.3.3:20880/com.foo.BarService?dubbo.tag=blue")); invokers.add(redInvoker); invokers.add(yellowInvoker); diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java index 950693069078..77333e8a7783 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java @@ -641,9 +641,7 @@ public class Constants { public static final String MULTICAST = "multicast"; - public static final String TAG_KEY = "tag"; - - public static final String REQUEST_TAG_KEY = "request.tag"; + public static final String TAG_KEY = "dubbo.tag"; /* * private Constants(){ }