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 44fb07fa4f16322fbed14013c4c9f358f95b2e28 Author: ken.lj <[email protected]> AuthorDate: Wed Oct 17 14:07:22 2018 +0800 Demo and ut changes --- .../cluster/router/ConfigConditionRouterTest.java | 7 ++-- .../dubbo/rpc/cluster/router/TagRouterTest.java | 26 +++++++-------- .../org/apache/dubbo/demo/consumer/Consumer.java | 4 +-- .../dubbo/demo/consumer/DemoServiceMock.java | 39 ++++++++++++++++++++++ .../META-INF/spring/dubbo-demo-consumer.xml | 2 ++ .../META-INF/spring/dubbo-demo-provider.xml | 6 ++-- 6 files changed, 64 insertions(+), 20 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 416fac5..b545f8e 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 @@ -88,15 +88,16 @@ public class ConfigConditionRouterTest { "scope: service\n" + "force: true\n" + "runtime: true\n" + - "enabled: false\n" + + "enabled: true\n" + "priority: 1\n" + - "key: org.apache.dubbo.demo.DemoService\n" + + "key: org.apache.dubbo.demo.DemoService:1.0.2\n" + "conditions:\n" + " - method!=sayHello =>\n" + " - method=routeMethod1 => address=30.5.120.37:20880\n" + "..."; +// String serviceStr = ""; try { - String servicePath = "/dubbo/config/org.apache.dubbo.demo.DemoService/routers"; + String servicePath = "/dubbo/config/org.apache.dubbo.demo.DemoService:1.0.2/routers"; if (client.checkExists().forPath(servicePath) == null) { client.create().creatingParentsIfNeeded().forPath(servicePath); } 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 26367c2..2f5d4a8 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,19 +37,19 @@ public class TagRouterTest { @Test public void normalTagRuleTest() { -// 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 = ""; + String serviceStr = "---\n" + + "force: false\n" + + "runtime: true\n" + + "enabled: false\n" + + "priority: 1\n" + + "key: demo-provider\n" + + "tags:\n" + + " - name: tag1\n" + + " addresses: [\"30.5.120.37:20881\"]\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 62ff67a..80d3eff 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,10 +34,10 @@ public class Consumer { while (true) { try { Thread.sleep(1000); - RpcContext.getContext().setAttachment("tag", "tag3"); +// RpcContext.getContext().setAttachment("tag", "tag3"); String hello = demoService.sayHello("world"); // call remote method System.out.println(hello); // get result - RpcContext.getContext().setAttachment("tag", "tag1"); +// RpcContext.getContext().setAttachment("tag", "tag1"); // RpcContext.getContext().setAttachment("force.tag", "true"); String routeMethod1 = demoService.routeMethod1(); // call remote method System.out.println(routeMethod1); // get result diff --git a/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/DemoServiceMock.java b/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/DemoServiceMock.java new file mode 100644 index 0000000..3e405a3 --- /dev/null +++ b/dubbo-demo/dubbo-demo-consumer/src/main/java/org/apache/dubbo/demo/consumer/DemoServiceMock.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.demo.consumer; + +import org.apache.dubbo.demo.DemoService; + +/** + * + */ +public class DemoServiceMock implements DemoService { + @Override + public String sayHello(String name) { + return "mock value"; + } + + @Override + public String routeMethod1() { + return null; + } + + @Override + public String routeMethod2() { + return null; + } +} diff --git a/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml b/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml index 86472c5..f80ceb0 100644 --- a/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml +++ b/dubbo-demo/dubbo-demo-consumer/src/main/resources/META-INF/spring/dubbo-demo-consumer.xml @@ -26,9 +26,11 @@ <dubbo:application name="demo-consumer"> <dubbo:parameter key="config.type" value="zookeeper"/> <dubbo:parameter key="config.address" value="127.0.0.1:2181"/> + <dubbo:parameter key="config.check" value="true"/> </dubbo:application> <!-- use multicast registry center to discover service --> + <dubbo:registry address="zookeeper://127.0.0.1:2181" default="true"/> <dubbo:registry address="zookeeper://127.0.0.1:2181"/> <dubbo:servicestore address="zookeeper://127.0.0.1:2181"/> 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 7604b32..66982ae 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 @@ -26,9 +26,11 @@ <!--<dubbo:provider tag="tag3"/>--> <!-- use multicast registry center to export service --> - <dubbo:registry address="zookeeper://127.0.0.1:2181" simple="true" /> + <dubbo:registry address="zookeeper://127.0.0.1:2181" simple="false"> + <dubbo:parameter key="config.check" value="false"/> + </dubbo:registry> - <dubbo:servicestore address="redis://127.0.0.1:6379"/> + <dubbo:servicestore address="zookeeper://127.0.0.1:2181"/> <!-- use dubbo protocol to export service on port 20880 --> <dubbo:protocol name="dubbo" port="-1"/>
