Skip to content

Commit

Permalink
follow the name of tagKey of 2.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
xujingfeng committed Dec 29, 2018
1 parent 376c0ca commit eccb7b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
Expand Up @@ -64,7 +64,7 @@ public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, URL url, Invocation
List<Invoker<T>> 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
Expand Down
Expand Up @@ -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<Invoker<String>> invokers = new ArrayList<>();
Invoker<String> 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<String> 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<String> 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<String> defaultInvoker = new MockInvoker<>(URL.valueOf(
"dubbo://10.20.3.4:20880/com.foo.BarService"));

Expand All @@ -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<Invoker<String>> invokers = new ArrayList<>();
Invoker<String> 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<String> 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<String> 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<String> defaultInvoker = new MockInvoker<>(URL.valueOf(
"dubbo://10.20.3.4:20880/com.foo.BarService"));

Expand All @@ -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<Invoker<String>> invokers = new ArrayList<>();
Invoker<String> 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<String> 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<String> 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<String> defaultInvoker = new MockInvoker<>(URL.valueOf(
"dubbo://10.20.3.4:20880/com.foo.BarService"));

Expand All @@ -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<Invoker<String>> invokers = new ArrayList<>();
Invoker<String> 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<String> 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<String> 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);
Expand Down
Expand Up @@ -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(){ }
Expand Down

0 comments on commit eccb7b4

Please sign in to comment.