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 714951a5ed16c5bdd242646e50680a0007c4ca3b Author: ken.lj <ken.lj...@gmail.com> AuthorDate: Tue Sep 11 17:27:27 2018 +0800 Change for demo and test logic --- .../cluster/router/ConfigConditionRouterTest.java | 15 ++++++------- .../dubbo/rpc/cluster/router/TagRouterTest.java | 25 +++++++++++----------- .../org/apache/dubbo/demo/consumer/Consumer.java | 7 +++--- .../META-INF/spring/dubbo-demo-provider.xml | 2 +- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/ConfigConditionRouterTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/ConfigConditionRouterTest.java index 70576d2..416fac5 100644 --- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/ConfigConditionRouterTest.java +++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/ConfigConditionRouterTest.java @@ -40,13 +40,12 @@ public class ConfigConditionRouterTest { String serviceStr = "---\n" + "scope: application\n" + "force: true\n" + - "runtime: false\n" + + "runtime: true\n" + "enabled: true\n" + "priority: 2\n" + "key: demo-consumer\n" + "conditions:\n" + - " - method=sayHello => host=30.5.120.21\n" + - " - method=routeMethod1 => host=30.5.120.21\n" + + " - method=notExitMethod => \n" + "..."; try { String servicePath = "/dubbo/config/demo-consumer/routers"; @@ -69,8 +68,8 @@ public class ConfigConditionRouterTest { "priority: 2\n" + "key: demo-consumer\n" + "conditions:\n" + - " - interface=org.apache.dubbo.demo.DemoService&method=sayHello => host=30.5.120.21\n" + - " - method=routeMethod1 => host=30.5.120.21\n" + + " - interface=org.apache.dubbo.demo.DemoService&method=sayHello => host=30.5.120.37\n" + + " - method=routeMethod1 => host=30.5.120.37\n" + "..."; try { String servicePath = "/dubbo/config/demo-consumer/routers"; @@ -88,13 +87,13 @@ public class ConfigConditionRouterTest { String serviceStr = "---\n" + "scope: service\n" + "force: true\n" + - "runtime: false\n" + - "enabled: true\n" + + "runtime: true\n" + + "enabled: false\n" + "priority: 1\n" + "key: org.apache.dubbo.demo.DemoService\n" + "conditions:\n" + " - method!=sayHello =>\n" + - " - method=routeMethod1 => address=30.5.120.21:20880\n" + + " - method=routeMethod1 => address=30.5.120.37:20880\n" + "..."; try { String servicePath = "/dubbo/config/org.apache.dubbo.demo.DemoService/routers"; diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/TagRouterTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/TagRouterTest.java index 34c9821..26367c2 100644 --- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/TagRouterTest.java +++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/router/TagRouterTest.java @@ -37,18 +37,19 @@ public class TagRouterTest { @Test public void normalTagRuleTest() { - String serviceStr = "---\n" + - "force: true\n" + - "runtime: true\n" + - "enabled: true\n" + - "priority: 1\n" + - "key: demo-provider\n" + - "tags:\n" + - " - name: tag1\n" + - " addresses: [\"30.5.120.21:20880\"]\n" + - " - name: tag2\n" + - " addresses: [\"30.5.120.21:20881\"]\n" + - "..."; +// String serviceStr = "---\n" + +// "force: false\n" + +// "runtime: true\n" + +// "enabled: true\n" + +// "priority: 1\n" + +// "key: demo-provider\n" + +// "tags:\n" + +// " - name: tag1\n" + +// " addresses: [\"30.5.120.37:20880\"]\n" + +// " - name: tag2\n" + +// " addresses: [\"30.5.120.37:20880\"]\n" + +// "..."; + String serviceStr = ""; try { String servicePath = "/dubbo/config/demo-provider/tagrouters"; if (client.checkExists().forPath(servicePath) == null) { diff --git a/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Consumer.java b/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Consumer.java index 58466b1..62ff67a 100644 --- a/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Consumer.java +++ b/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Consumer.java @@ -34,14 +34,15 @@ public class Consumer { while (true) { try { Thread.sleep(1000); - RpcContext.getContext().setAttachment("tag", "tag1"); + RpcContext.getContext().setAttachment("tag", "tag3"); String hello = demoService.sayHello("world"); // call remote method System.out.println(hello); // get result - RpcContext.getContext().setAttachment("tag", "tag3"); - RpcContext.getContext().setAttachment("force.tag", "true"); + RpcContext.getContext().setAttachment("tag", "tag1"); +// RpcContext.getContext().setAttachment("force.tag", "true"); String routeMethod1 = demoService.routeMethod1(); // call remote method System.out.println(routeMethod1); // get result } catch (Throwable throwable) { + RpcContext.getContext().clearAttachments(); throwable.printStackTrace(); } } diff --git a/dubbo-demo/dubbo-demo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml b/dubbo-demo/dubbo-demo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml index 30275e4..96ebae1 100644 --- a/dubbo-demo/dubbo-demo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml +++ b/dubbo-demo/dubbo-demo-provider/src/main/resources/META-INF/spring/dubbo-demo-provider.xml @@ -23,7 +23,7 @@ <!-- provider's application name, used for tracing dependency relationship --> <dubbo:application name="demo-provider"/> - <dubbo:provider tag="tag3"/> + <!--<dubbo:provider tag="tag3"/>--> <!-- use multicast registry center to export service --> <dubbo:registry address="zookeeper://127.0.0.1:2181"/>