[dubbo-website] branch master updated: Fix samples validation link error (#585)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new b734f82 Fix samples validation link error (#585) b734f82 is described below commit b734f827beedbec81e646995358343b42c17ea23 Author: 月泉 AuthorDate: Wed Jun 10 23:28:49 2020 +0800 Fix samples validation link error (#585) --- docs/en-us/user/demos/parameter-validation.md | 2 +- docs/zh-cn/user/demos/parameter-validation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en-us/user/demos/parameter-validation.md b/docs/en-us/user/demos/parameter-validation.md index f7053eb..91a2f93 100644 --- a/docs/en-us/user/demos/parameter-validation.md +++ b/docs/en-us/user/demos/parameter-validation.md @@ -179,5 +179,5 @@ public class ValidationConsumer { } ``` -[^1]: Support since `2.1.0` version. If you want to know how to use it, refer to [Sample code in dubbo project] (https://github.com/apache/dubbo-samples/tree/master/dubbo-samples-validation) +[^1]: Support since `2.1.0` version. If you want to know how to use it, refer to [Sample code in dubbo project] (https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-validation) [^2]: The validation method is extensible, refer to [Developer Extension](http://dubbo.apache.org/zh-cn/docs/dev/impls/validation.html) in the developer's manual. diff --git a/docs/zh-cn/user/demos/parameter-validation.md b/docs/zh-cn/user/demos/parameter-validation.md index b703dbd..dd90992 100644 --- a/docs/zh-cn/user/demos/parameter-validation.md +++ b/docs/zh-cn/user/demos/parameter-validation.md @@ -179,5 +179,5 @@ public class ValidationConsumer { } ``` -[^1]: 自 `2.1.0` 版本开始支持, 如何使用可以参考 [dubbo 项目中的示例代码](https://github.com/apache/dubbo-samples/tree/master/dubbo-samples-validation) +[^1]: 自 `2.1.0` 版本开始支持, 如何使用可以参考 [dubbo 项目中的示例代码](https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-validation) [^2]: 验证方式可扩展,扩展方式参见开发者手册中的[验证扩展](http://dubbo.apache.org/zh-cn/docs/dev/impls/validation.html)
[dubbo-website] branch master updated: fix the typo (#588)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 9376a91 fix the typo (#588) 9376a91 is described below commit 9376a9188af743e5f1bba8fb1a542079489cd567 Author: superleo-cn AuthorDate: Wed Jun 10 23:22:16 2020 +0800 fix the typo (#588) --- docs/en-us/user/references/protocol/redis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en-us/user/references/protocol/redis.md b/docs/en-us/user/references/protocol/redis.md index a4c692b..991a868 100644 --- a/docs/en-us/user/references/protocol/redis.md +++ b/docs/en-us/user/references/protocol/redis.md @@ -1,6 +1,6 @@ # redis:// -RPC protocol based on memcached implementation. +RPC protocol based on redis implementation. ## Register redis service address
[dubbo-website] branch master updated: fix spelling mistake (#590)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 0e8f47d fix spelling mistake (#590) 0e8f47d is described below commit 0e8f47df16460008b4458ee86515412d30a8035b Author: jiumozhi <498185...@qq.com> AuthorDate: Wed Jun 10 23:20:42 2020 +0800 fix spelling mistake (#590) --- docs/en-us/user/quick-start.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en-us/user/quick-start.md b/docs/en-us/user/quick-start.md index 48712b6..bbf0b14 100644 --- a/docs/en-us/user/quick-start.md +++ b/docs/en-us/user/quick-start.md @@ -89,7 +89,7 @@ provider.xml: ``` The demo uses multicast as the registry since it is simple and does not require to extra installation. -If you prefer a registiry like zookeeper, please check out examples [here](https://github.com/dubbo/dubbo-samples). +If you prefer a registry like zookeeper, please check out examples [here](https://github.com/dubbo/dubbo-samples). ### Configure the logging system @@ -249,4 +249,4 @@ You can find the complete example code in the Github repository. [^1]: The interface needs to be packaged separately, shared by the service provider and the consumer [^2]: Hidden realization of service consumer -[^3]: IoC injection can also be used \ No newline at end of file +[^3]: IoC injection can also be used
[dubbo-website] branch master updated: markdown error fix (#602)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 1461bfd markdown error fix (#602) 1461bfd is described below commit 1461bfd068b26d1895e3166722a7cfa19674155b Author: 离诌 AuthorDate: Wed Jun 10 22:47:04 2020 +0800 markdown error fix (#602) --- blog/en-us/dubbo-protocol.md | 2 +- blog/zh-cn/dubbo-protocol.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blog/en-us/dubbo-protocol.md b/blog/en-us/dubbo-protocol.md index 4946dc9..71fae9c 100644 --- a/blog/en-us/dubbo-protocol.md +++ b/blog/en-us/dubbo-protocol.md @@ -152,7 +152,7 @@ The Dubbo framework defines a proprietary RPC protocol in which the specific con - Exception: RESPONSE_WITH_EXCEPTION 0 - Return value: response bytes returned from the server -**Note: ** For the variable part, when uses json serialization in current version of Dubbo framework, an additional line break is added as a separator between each part of the content. Please add a new line break after each part of the variable part, such as: +**Note:** For the variable part, when uses json serialization in current version of Dubbo framework, an additional line break is added as a separator between each part of the content. Please add a new line break after each part of the variable part, such as: ``` Dubbo version bytes (line break) diff --git a/blog/zh-cn/dubbo-protocol.md b/blog/zh-cn/dubbo-protocol.md index 39f142e..6a2bab2 100644 --- a/blog/zh-cn/dubbo-protocol.md +++ b/blog/zh-cn/dubbo-protocol.md @@ -162,7 +162,7 @@ Dubbo 框架定义了私有的RPC协议,其中请求和响应协议的具体 - 异常:RESPONSE_WITH_EXCEPTION 0 - 返回值:从服务端返回的响应bytes -**注意:**对于(Variable Part)变长部分,当前版本的Dubbo 框架使用json序列化时,在每部分内容间额外增加了换行符作为分隔,请在Variable Part的每个part后额外增加换行符, 如: +**注意:** 对于(Variable Part)变长部分,当前版本的Dubbo 框架使用json序列化时,在每部分内容间额外增加了换行符作为分隔,请在Variable Part的每个part后额外增加换行符, 如: ``` Dubbo version bytes (换行符)
[dubbo-website] branch master updated: Fix word spelling (#563)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new e413ef9 Fix word spelling (#563) e413ef9 is described below commit e413ef992c8974d5302b0065a1958ff66eeecdba Author: withthewind AuthorDate: Sat Mar 7 16:19:14 2020 +0800 Fix word spelling (#563) --- docs/en-us/user/dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en-us/user/dependencies.md b/docs/en-us/user/dependencies.md index 2d9b494..437dce5 100644 --- a/docs/en-us/user/dependencies.md +++ b/docs/en-us/user/dependencies.md @@ -50,7 +50,7 @@ These dependencies needs to be added to project manually,when you need them. * slf4j: 1.7.25 * log4j: 1.2.16 -[^1]: In theory, Dubbo only depend on JDK, not depend on any 3rd party libs, you can finish logic by useing JDK. +[^1]: In theory, Dubbo only depend on JDK, not depend on any 3rd party libs, you can finish logic by using JDK. [^2]: Log output jar [^3]: Bytecode generation [^4]: Configuration parsing
[dubbo-website] branch master updated: Update graceful-shutdown.md (#566)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new f2181bb Update graceful-shutdown.md (#566) f2181bb is described below commit f2181bb96fe95d72e1a412dff0ac6bd908afdf23 Author: liber-xk <61538821+liber...@users.noreply.github.com> AuthorDate: Sat Mar 7 16:17:21 2020 +0800 Update graceful-shutdown.md (#566) --- docs/zh-cn/user/demos/graceful-shutdown.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh-cn/user/demos/graceful-shutdown.md b/docs/zh-cn/user/demos/graceful-shutdown.md index 8c6da4f..43dcd9b 100644 --- a/docs/zh-cn/user/demos/graceful-shutdown.md +++ b/docs/zh-cn/user/demos/graceful-shutdown.md @@ -23,8 +23,8 @@ Dubbo 是通过 JDK 的 ShutdownHook 来完成优雅停机的,所以如果用 dubbo.service.shutdown.wait=15000 ``` -如果 ShutdownHook 不能生效,可以自行调用,**使用tomcat等容器部署的場景,建议通过扩展ContextListener等自行调用以下代码实现优雅停机**: +如果 ShutdownHook 不能生效,可以自行调用,**使用tomcat等容器部署的场景,建议通过扩展ContextListener等自行调用以下代码实现优雅停机**: ```java DubboShutdownHook.destroyAll(); -``` \ No newline at end of file +```
[dubbo-website] branch master updated: fix: (zh-cn) group-merger.md dubbo-samples link failed (#556) (#557)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 743d168 fix: (zh-cn) group-merger.md dubbo-samples link failed (#556) (#557) 743d168 is described below commit 743d168ad3d7337344637e6cada55dd34ca2504a Author: Tao Rao AuthorDate: Sat Feb 8 23:22:56 2020 +0800 fix: (zh-cn) group-merger.md dubbo-samples link failed (#556) (#557) --- docs/zh-cn/user/demos/group-merger.md | 2 +- docs/zh-cn/user/demos/routing-rule.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh-cn/user/demos/group-merger.md b/docs/zh-cn/user/demos/group-merger.md index 93119da..24a61cc 100644 --- a/docs/zh-cn/user/demos/group-merger.md +++ b/docs/zh-cn/user/demos/group-merger.md @@ -2,7 +2,7 @@ 按组合并返回结果 [^1],比如菜单服务,接口一样,但有多种实现,用group区分,现在消费方需从每种group中调用一次返回结果,合并结果返回,这样就可以实现聚合菜单项。 -相关代码可以参考 [dubbo 项目中的示例](https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-merge) +相关代码可以参考 [dubbo 项目中的示例](https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-merge) ## 配置 diff --git a/docs/zh-cn/user/demos/routing-rule.md b/docs/zh-cn/user/demos/routing-rule.md index 8472ccf..57c1640 100644 --- a/docs/zh-cn/user/demos/routing-rule.md +++ b/docs/zh-cn/user/demos/routing-rule.md @@ -58,7 +58,7 @@ 各字段含义 - `scope`表示路由规则的作用粒度,scope的取值会决定key的取值。**必填**。 - - service 务粒度 + - service 服务粒度 - application 应用粒度 - `Key`明确规则体作用在哪个服务或应用。**必填**。 - scope=service时,key取值为[{group}:]{service}[:{version}]的组合
[dubbo-website] branch master updated: fix: (en-us) dubbo-101.md link failed (#555)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new a4c2803 fix: (en-us) dubbo-101.md link failed (#555) a4c2803 is described below commit a4c28039f8761c7bf3eff8aea0aaad67cf17465d Author: withthewind AuthorDate: Thu Jan 9 16:04:32 2020 +0800 fix: (en-us) dubbo-101.md link failed (#555) --- blog/en-us/dubbo-101.md | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blog/en-us/dubbo-101.md b/blog/en-us/dubbo-101.md index 2d477f0..41f42b7 100644 --- a/blog/en-us/dubbo-101.md +++ b/blog/en-us/dubbo-101.md @@ -191,18 +191,18 @@ public class Application { ### Run -The complete example can be found at https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-api. In the complete version, it is convenient to execute by maven in command line with the configuration of *exec-maven-plugin*. Of course, it can also be executed directly in IDE. However, there is one noteworthy thing that because of using assembled way to look up service, it needs to assign *-Djava.net.preferIPv4Stack=true* when running. +The complete example can be found at https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-api. In the complete version, it is convenient to execute by maven in command line with the configuration of *exec-maven-plugin*. Of course, it can also be executed directly in IDE. However, there is one noteworthy thing that because of using assembled way to look up service, it needs to assign *-Djava.net.preferIPv4Stack=true* when running. Build Example Synchronize the example codes and build by the following command lines: -1. Synchronize the example codes: git clone https://github.com/dubbo/dubbo-samples.git +1. Synchronize the example codes: git clone https://github.com/apache/dubbo-samples.git 2. Build:mvn clean package ```bash -$ git clone https://github.com/dubbo/dubbo-samples.git -$ cd dubbo-samples/dubbo-samples-api/ +$ git clone https://github.com/apache/dubbo-samples.git +$ cd dubbo-samples/java/dubbo-samples-api/ $ mvn clean package INFO] Scanning for projects... [INFO]
[dubbo-website] branch master updated: fix: (zh-cn) dubbo-101.md link failed (#554)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 15c5980 fix: (zh-cn) dubbo-101.md link failed (#554) 15c5980 is described below commit 15c5980839ad45ca774d07d103fa0e2e361c3631 Author: withthewind AuthorDate: Thu Jan 9 16:03:37 2020 +0800 fix: (zh-cn) dubbo-101.md link failed (#554) --- blog/zh-cn/dubbo-101.md | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blog/zh-cn/dubbo-101.md b/blog/zh-cn/dubbo-101.md index d25e833..c2ae952 100644 --- a/blog/zh-cn/dubbo-101.md +++ b/blog/zh-cn/dubbo-101.md @@ -185,18 +185,18 @@ public class Application { ### 运行 -完整的示例在 https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-api 上提供。在完整的示例中,由于配置了 *exec-maven-plugin*,可以很方便的在命令行下通过 maven 的方式执行。当然,您也可以在 IDE 里直接执行,但是需要注意的是,由于使用了组播的方式来发现服务,运行时需要指定 *-Djava.net.preferIPv4Stack=true*。 +完整的示例在 https://github.com/apache/dubbo-samples/tree/master/java/dubbo-samples-api 上提供。在完整的示例中,由于配置了 *exec-maven-plugin*,可以很方便的在命令行下通过 maven 的方式执行。当然,您也可以在 IDE 里直接执行,但是需要注意的是,由于使用了组播的方式来发现服务,运行时需要指定 *-Djava.net.preferIPv4Stack=true*。 构建示例 通过以下的命令来同步示例代码并完成构建: -1. 同步代码:git clone https://github.com/dubbo/dubbo-samples.git +1. 同步代码:git clone https://github.com/apache/dubbo-samples.git 2. 构建:mvn clean package ```bash -$ git clone https://github.com/dubbo/dubbo-samples.git -$ cd dubbo-samples/dubbo-samples-api/ +$ git clone https://github.com/apache/dubbo-samples.git +$ cd dubbo-samples/java/dubbo-samples-api/ $ mvn clean package INFO] Scanning for projects... [INFO]
[dubbo-website] branch master updated: Update SPI.md (#534)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 78109c2 Update SPI.md (#534) 78109c2 is described below commit 78109c240cc2b70a52ca77bc6717a56048bbd9ff Author: CenluChen <56420108+cenluc...@users.noreply.github.com> AuthorDate: Wed Dec 4 02:34:05 2019 +0800 Update SPI.md (#534) --- docs/zh-cn/dev/SPI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-cn/dev/SPI.md b/docs/zh-cn/dev/SPI.md index 4f3927b..8d3db93 100644 --- a/docs/zh-cn/dev/SPI.md +++ b/docs/zh-cn/dev/SPI.md @@ -124,7 +124,7 @@ public class RaceCarMaker implements CarMaker { ### 扩展点自适应 -`ExtensionLoader` 注入的依赖扩展点是一个 `Adaptive` 实例,直到扩展点方法执行时才决定调用是一个扩展点实现。 +`ExtensionLoader` 注入的依赖扩展点是一个 `Adaptive` 实例,直到扩展点方法执行时才决定调用是哪一个扩展点实现。 Dubbo 使用 URL 对象(包含了Key-Value)传递配置信息。
[dubbo-website] branch master updated: Fix dubbo-mesh-in-thinking.md spelling-mistakes (#524)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 2370658 Fix dubbo-mesh-in-thinking.md spelling-mistakes (#524) 2370658 is described below commit 23706589c7edda4851b6d2bc7aca62b42c317e8b Author: withthewind AuthorDate: Tue Nov 12 09:42:21 2019 +0800 Fix dubbo-mesh-in-thinking.md spelling-mistakes (#524) --- blog/zh-cn/dubbo-mesh-in-thinking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blog/zh-cn/dubbo-mesh-in-thinking.md b/blog/zh-cn/dubbo-mesh-in-thinking.md index c9d8d16..97dc63c 100644 --- a/blog/zh-cn/dubbo-mesh-in-thinking.md +++ b/blog/zh-cn/dubbo-mesh-in-thinking.md @@ -1,14 +1,14 @@ --- title: Dubbo在Service Mesh下的思考和方案 keywords: Dubbo, Service Mesh, Cloud Native -description: Dubbo是实现框架,融入servcemesh理念就是我们今天分享的。 +description: Dubbo是实现框架,融入service mesh理念就是我们今天分享的。 --- # Dubbo在Service Mesh下的思考和方案 ## 开头 -Service Mesh这个“热”词是2016年9月被“造”出来,而今年2018年更是被称为service Mesh的关键之年,各家大公司都希望能在这个思潮下领先一步。今天我也分享阿里中间件在这方面的观点,思考和实践。考虑到有些人没了解过Dubbo(集团内以HSF为主)和Servicemesh,先简单介绍下这两个词。Dubbo应该是国内最受欢迎的远程服务框架,在Github上有超过2w的star数,也是阿里分布式架构互联互通的核心所在。跟Dubbo一样,servicemesh也是面向服务互联互通这一问题域,是云原生技术栈的核心之一;大家可以简单理解service mesh就是云原生组织定义的微服务架构解决理念。Dubbo是实现框架,融入servcemesh理念就是我们今天分享的。 +Service Mesh这个“热”词是2016年9月被“造”出来,而今年2018年更是被称为service Mesh的关键之年,各家大公司都希望能在这个思潮下领先一步。今天我也分享阿里中间件在这方面的观点,思考和实践。考虑到有些人没了解过Dubbo(集团内以HSF为主)和Servicemesh,先简单介绍下这两个词。Dubbo应该是国内最受欢迎的远程服务框架,在Github上有超过2w的star数,也是阿里分布式架构互联互通的核心所在。跟Dubbo一样,servicemesh也是面向服务互联互通这一问题域,是云原生技术栈的核心之一;大家可以简单理解service mesh就是云原生组织定义的微服务架构解决理念。Dubbo是实现框架,融入service mesh理念就是我们今天分享的。 ## 现状和挑战
[dubbo-website] branch master updated: Translation of dubboAsync_client.md (#464)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 3078d28 Translation of dubboAsync_client.md (#464) 3078d28 is described below commit 3078d28eb0e1b6b8f2523cbd90a619062396670c Author: Kyle AuthorDate: Fri Sep 6 16:33:51 2019 +0800 Translation of dubboAsync_client.md (#464) --- blog/en-us/dubboAsync_client.md| 85 + blog/zh-cn/dubboAsync_client.md| 2 +- img/blog/dubboasyn_client/1_en.png | Bin 0 -> 17755 bytes site_config/blog.js| 7 +++ 4 files changed, 93 insertions(+), 1 deletion(-) diff --git a/blog/en-us/dubboAsync_client.md b/blog/en-us/dubboAsync_client.md new file mode 100644 index 000..d5993be --- /dev/null +++ b/blog/en-us/dubboAsync_client.md @@ -0,0 +1,85 @@ +--- +title: Implementation background and practice of Dubbo client asynchronous interface +keywords: Dubbo, Asynchronous, Reactive +description: Implementation background and practice of Dubbo client asynchronous interface +--- + +# Implementation background and practice of Dubbo client asynchronous interface + +## Preface + +![image | left](../../img/blog/dubboasyn_client/1_en.png "") + +Let's start with a brief introduction about the stages of a complete Dubbo invocation. +1. Biz~ represents business thread, that is, the thread where the business logic is located. Biz~ thread pool may be created and maintained by business itself, most of which may be managed by system framework itself (for example, a web system runs under Tomcat container, Biz~ thread is maintained by Tomcat); IO~ stands for network data processing thread, which is created and maintained by IO framework (such as Netty, Grizzly). Dubbo Remoting's default Netty implementation is NioEventloop [...] + +2. As we all know, the way of data communication between threads is shared variables. The data communication between Biz and IO is Queue. Specifically to Dubbo, Biz put a task in EventLoop's LinkedBlockingQueue in the client side implementation (i.e. the steps labeled in Figure 1 above), and the corresponding Thread in the EventLoop will keep iteration the Queue to keep on executing the information the task contains. Specific code can refer to SingleThreadEventExecutor (by the way, the d [...] + +3. As shown in the figure above, a standard RPC call passes through four message (event) transfers of 1,2,3,4, respectively are the client business thread sending requests to the client IO thread, the server business logic thread receiving the server IO thread requests, the server logic thread responding to the server IO thread after processing, and the client IO thread receiving the results feedback to the business logic thread. + +## Client Asynchronization + +### Background +In the Java language (other languages are not clear), a call of the local interface can be transparently converted into the call of remote RPC through the proxy mechanism. Most business parties prefer this programming method similar to the local interface to do remote service invocation. Therefore, although RPC is naturally asynchronous internally, users using Dubbo mostly use synchronization, while asynchrony becomes a minority use scenario. The advantage of synchronization is that the [...] + +Therefore, the motivation of client asynchronization is to save thread resource overhead at the cost of understanding how asynchronization is used. In the synchronous mode, the return type of API interface represents a certain business class, while in the asynchronous case, the response and the request are completely independent events, so it is most suitable for the return type of API interface to be CompletionStage mentioned above, which is the inevitable asynchronization supported by [...] + +The example blow is to illustrate it. + +### The sample + +Refer to the example code for event notification: [https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-notify](https://github.com/dubbo/dubbo-samples/tree/master/dubbo-samples-notify) + +Event notification allows the Consumer to trigger 'oninvoke', 'onreturn' and 'onthrow' events, which respectively represent before the call, after the call returns normally, or when an exception occurs. + +You can specify a method for notifying events when configuring the Consumer, such as: + +```xml + + + + + +``` + +The code for NotifyImpl is as follows: + +```java +public class NotifyImpl implements Notify{ + +public Map ret = new HashMap(); + +public void onreturn(String name, int id) { +ret.put(id, name); +System.out.println("onreturn: " + name); +} + +public void onthrow(Throwable ex, String name, int id) { +System.out.println("onthrow: " + name); +} +
[dubbo-website] branch master updated: translate dubbo-config-center.md (#467)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 54aa1ad translate dubbo-config-center.md (#467) 54aa1ad is described below commit 54aa1ad736ce575d5ae6cfe37f0b12fee43be1fc Author: Junjian Peng AuthorDate: Mon Sep 2 11:27:16 2019 +0800 translate dubbo-config-center.md (#467) --- docs/en-us/user/references/xml/dubbo-config-center.md | 19 +++ site_config/docs.js | 4 2 files changed, 23 insertions(+) diff --git a/docs/en-us/user/references/xml/dubbo-config-center.md b/docs/en-us/user/references/xml/dubbo-config-center.md new file mode 100644 index 000..d2598d5 --- /dev/null +++ b/docs/en-us/user/references/xml/dubbo-config-center.md @@ -0,0 +1,19 @@ +# dubbo:config-center + +Configuration center. Corresponding configuration class: `org.apache.dubbo.config.ConfigCenterConfig` + +| property | Corresponding URL parameter | type | required | default value | description | compatibility | +| | -- | --- | | | | -- | +| protocol | config.protocol| string | optional | zookeeper| Which configuration center to use: apollo, zookeeper, nacos, etc.take zookeeper for example1. If protocol is specified, address can be simplified to `127.0.0.1:2181`;2. If protocol is not specified, address is set to `zookeeper://127.0.0.1:2181` | 2.7.0+ | +| address | config.address | string | required | | Configuration center address.See protocol description for values | 2.7.0+ | +| highest-priority | config.highestPriority | boolean | optional | true | Configuration items from the configuration center have the highest priority, it means that the local configuration items will be overwritten. | 2.7.0+ | +| namespace| config.namespace | string | optional | dubbo| Using for multi-tenant isolation generally, the actual meaning varies depending on the configuration center. For example:zookeeper - Environment isolation, default `dubbo`;apollo - Distinguish between sets of configurations for different domains and use them by default `dubbo` and `application` | 2.7.0+ | +| cluster | config.cluster | string | optional | | The meaning varies according to the configuration center selected.For example, it's used to distinguish between different configuration clusters in apollo | 2.7.0+ | +| group| config.group | string | optional | dubbo| The meaning varies according to the configuration center selected.nacos - Isolate different configuration setszookeeper - Isolate different configuration sets | 2.7.0+ | +| check| config.check | boolean | optional | true | Whether to terminate application startup when the configuration hub connection fails. | 2.7.0+ | +| config-file | config.configFile | string | optional | dubbo.properties | The key mapped to the global level profilezookeeper - $DEFAULT_PATH/dubbo/config/dubbo/dubbo.propertiesapollo - The dubbo.properties key in dubbo namespace | 2.7.0+ | +| timeout | config.timeout | integer | | 3000ms | Gets the configured timeout | 2.7.0+ | +| username || string | | | the username if the configuration center requires validationApollo is not yet enabled | 2.7.0+ | +| password || string | | | password if configuration center needs to do checkApollo is not yet enabled | 2.7.0+ | +| parameters || Map | | | Extended parameters to support customized configuration parameters for different configuration centers | 2.7.0+ | +| include-spring-env || boolean | optional | false| With the Spring framework support, when the value is `true`, it will automatically reads the configuration from the Spring EnvironmentRead by defaultConfiguration with key `dubbo.properties`PropertySource with key `dubbo.properties` | 2.7.0+ | diff --git a/site_config/docs.js b/site_config/docs.js index a9b1482..27ef2f4 100644 --- a/site_config/docs.js +++ b/site_config/docs.js @@ -310,6 +310,10 @@ export default { title: 'dubbo:parameter
[dubbo] branch master updated: Simplify code with Lambda (#4834)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/master by this push: new 8be896e Simplify code with Lambda (#4834) 8be896e is described below commit 8be896e663812f9b981010295d47fa730af51428 Author: freekry AuthorDate: Fri Aug 16 10:54:56 2019 +0800 Simplify code with Lambda (#4834) Simplify code with Lambda --- .../java/org/apache/dubbo/config/spring/ConfigTest.java | 14 ++ .../annotation/AnnotationPropertyValuesAdapterTest.java | 16 +++- .../beans/factory/config/YamlPropertySourceFactory.java | 7 +-- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java index d44fb17..7b28d82 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java @@ -960,12 +960,7 @@ public class ConfigTest { sc.setApplication(ac); sc.setRegistry(rc); sc.setInterface(DemoService.class.getName()); -sc.setRef(new GenericService() { - -public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { -return null; -} -}); +sc.setRef((method, parameterTypes, args) -> null); ReferenceConfig ref = new ReferenceConfig(); ref.setApplication(ac); @@ -991,12 +986,7 @@ public class ConfigTest { service.setRegistry(new RegistryConfig("mock://localhost")); service.setInterface(DemoService.class.getName()); service.setGeneric(GENERIC_SERIALIZATION_BEAN); -service.setRef(new GenericService() { - -public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { -return null; -} -}); +service.setRef((method, parameterTypes, args) -> null); try { service.export(); Collection collection = MockRegistryFactory.getCachedRegistry(); diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java index 70f3a96..15ceecc 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java @@ -67,19 +67,9 @@ public class AnnotationPropertyValuesAdapterTest { DefaultConversionService conversionService = new DefaultConversionService(); -conversionService.addConverter(new Converter() { -@Override -public String convert(String[] source) { -return arrayToCommaDelimitedString(source); -} -}); - -conversionService.addConverter(new Converter>() { -@Override -public Map convert(String[] source) { -return CollectionUtils.toStringMap(source); -} -}); +conversionService.addConverter((Converter) source -> arrayToCommaDelimitedString(source)); + +conversionService.addConverter((Converter>) source -> CollectionUtils.toStringMap(source)); dataBinder.setConversionService(conversionService); diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/config/YamlPropertySourceFactory.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/config/YamlPropertySourceFactory.java index c9b44c9..060a0e4 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/config/YamlPropertySourceFactory.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/config/YamlPropertySourceFactory.java @@ -64,12 +64,7 @@ public class YamlPropertySourceFactory extends YamlProcessor implements Property public Map process() { final Map result = new LinkedHashMap(); -process(new MatchCallback() { -@Override -public void process(Properties properties, Map map) { -result.putAll(getFlattenedMap(map)); -} -}); +process((properties, map) -> result.putAll(getFlattenedMap(map))); return result; }
[dubbo] branch master updated: Make code of process callback of method cleaner in DubboBeanDefinitionParser (#4770)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/master by this push: new b0064d7 Make code of process callback of method cleaner in DubboBeanDefinitionParser (#4770) b0064d7 is described below commit b0064d78a3b929eb3b25e0de9055412cb61f48ce Author: Taosheng Wei AuthorDate: Sat Aug 10 20:28:03 2019 +0800 Make code of process callback of method cleaner in DubboBeanDefinitionParser (#4770) --- .../spring/schema/DubboBeanDefinitionParser.java | 26 -- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java index af42c9a..ee31d18 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java @@ -62,6 +62,10 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser { private static final Logger logger = LoggerFactory.getLogger(DubboBeanDefinitionParser.class); private static final Pattern GROUP_AND_VERION = Pattern.compile("^[\\-.0-9_a-zA-Z]+(\\:[\\-.0-9_a-zA-Z]+)?$"); +private static final String ONRETURN = "onreturn"; +private static final String ONTHROW = "onthrow"; +private static final String ONINVOKE = "oninvoke"; +private static final String METHOD = "Method"; private final Class beanClass; private final boolean required; @@ -190,24 +194,12 @@ public class DubboBeanDefinitionParser implements BeanDefinitionParser { value = null; } reference = value; -} else if ("onreturn".equals(property)) { +} else if(ONRETURN.equals(property) || ONTHROW.equals(property) || ONINVOKE.equals(property)) { int index = value.lastIndexOf("."); -String returnRef = value.substring(0, index); -String returnMethod = value.substring(index + 1); -reference = new RuntimeBeanReference(returnRef); - beanDefinition.getPropertyValues().addPropertyValue("onreturnMethod", returnMethod); -} else if ("onthrow".equals(property)) { -int index = value.lastIndexOf("."); -String throwRef = value.substring(0, index); -String throwMethod = value.substring(index + 1); -reference = new RuntimeBeanReference(throwRef); - beanDefinition.getPropertyValues().addPropertyValue("onthrowMethod", throwMethod); -} else if ("oninvoke".equals(property)) { -int index = value.lastIndexOf("."); -String invokeRef = value.substring(0, index); -String invokeRefMethod = value.substring(index + 1); -reference = new RuntimeBeanReference(invokeRef); - beanDefinition.getPropertyValues().addPropertyValue("oninvokeMethod", invokeRefMethod); +String ref = value.substring(0, index); +String method = value.substring(index + 1); +reference = new RuntimeBeanReference(ref); + beanDefinition.getPropertyValues().addPropertyValue(property + METHOD, method); } else { if ("ref".equals(property) && parserContext.getRegistry().containsBeanDefinition(value)) { BeanDefinition refBean = parserContext.getRegistry().getBeanDefinition(value);
[dubbo] branch master updated: Update DubboConfigBindingBeanPostProcessor.java (#4778)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git The following commit(s) were added to refs/heads/master by this push: new a1d0550 Update DubboConfigBindingBeanPostProcessor.java (#4778) a1d0550 is described below commit a1d05505086ee1a937a552f7831e1445dd26f9d7 Author: 54hechuan <43158596+54hech...@users.noreply.github.com> AuthorDate: Sat Aug 10 20:22:03 2019 +0800 Update DubboConfigBindingBeanPostProcessor.java (#4778) 修复 https://github.com/apache/dubbo/issues/4772 --- .../beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java index ad2218f..64327b7 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java @@ -87,7 +87,7 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { -if (beanName.equals(this.beanName) && bean instanceof AbstractConfig) { +if (this.beanName.equals(beanName) && bean instanceof AbstractConfig) { AbstractConfig dubboConfig = (AbstractConfig) bean; @@ -203,4 +203,4 @@ public class DubboConfigBindingBeanPostProcessor implements BeanPostProcessor, A return defaultDubboConfigBinder; } -} \ No newline at end of file +}
[dubbo-website] branch master updated: Fix typo (#429)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new cf9f34c Fix typo (#429) cf9f34c is described below commit cf9f34c23340c5396a2f0821a381ee586553d0d5 Author: 天璇 AuthorDate: Mon Jul 15 13:48:49 2019 +0800 Fix typo (#429) --- docs/zh-cn/user/demos/routing-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-cn/user/demos/routing-rule.md b/docs/zh-cn/user/demos/routing-rule.md index b3eb38e..8472ccf 100644 --- a/docs/zh-cn/user/demos/routing-rule.md +++ b/docs/zh-cn/user/demos/routing-rule.md @@ -239,7 +239,7 @@ RpcContext.getContext().setAttachment(Constants.REQUEST_TAG_KEY,"tag1"); 降级约定 -1. `request.tag=tag1` 时优先选择 标记了`tag=tag1` 的 provider。若集群中不存在与请求标记对应的服务,默认将降级请求 tag为空的provider;如果要该表这种默认行为,即找不到匹配tag1的provider返回异常,需设置`request.tag.force=true`。 +1. `request.tag=tag1` 时优先选择 标记了`tag=tag1` 的 provider。若集群中不存在与请求标记对应的服务,默认将降级请求 tag为空的provider;如果要改变这种默认行为,即找不到匹配tag1的provider返回异常,需设置`request.tag.force=true`。 2. `request.tag`未设置时,只会匹配tag为空的provider。即使集群中存在可用的服务,若 tag 不匹配也就无法调用,这与约定1不同,携带标签的请求可以降级访问到无标签的服务,但不携带标签/携带其他种类标签的请求永远无法访问到其他标签的服务。
[dubbo-website] branch master updated: Fix classpath didn't update#409 (#431)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 9c5ca0e Fix classpath didn't update#409 (#431) 9c5ca0e is described below commit 9c5ca0e72a1903a4a7df0c12becf6933af8ef911 Author: 天璇 AuthorDate: Mon Jul 15 13:46:39 2019 +0800 Fix classpath didn't update#409 (#431) correct the package name of Protocol --- docs/en-us/dev/impls/protocol.md | 12 ++-- docs/zh-cn/dev/impls/protocol.md | 12 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/en-us/dev/impls/protocol.md b/docs/en-us/dev/impls/protocol.md index 47ecd67..d3f96e6 100644 --- a/docs/en-us/dev/impls/protocol.md +++ b/docs/en-us/dev/impls/protocol.md @@ -65,11 +65,11 @@ public interface Protocol { ## Existing Protocol -* `org.apache.dubbo.rpc.injvm.InjvmProtocol` -* `org.apache.dubbo.rpc.dubbo.DubboProtocol` -* `org.apache.dubbo.rpc.rmi.RmiProtocol` -* `org.apache.dubbo.rpc.http.HttpProtocol` -* `org.apache.dubbo.rpc.http.hessian.HessianProtocol` +* `org.apache.dubbo.rpc.protocol.injvm.InjvmProtocol` +* `org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol` +* `org.apache.dubbo.rpc.protocol.rmi.RmiProtocol` +* `org.apache.dubbo.rpc.protocol.http.HttpProtocol` +* `org.apache.dubbo.rpc.protocol.http.hessian.HessianProtocol` ## Extension Guide @@ -147,4 +147,4 @@ META-INF/dubbo/org.apache.dubbo.rpc.Protocol: ```properties xxx=com.xxx.XxxProtocol -``` \ No newline at end of file +``` diff --git a/docs/zh-cn/dev/impls/protocol.md b/docs/zh-cn/dev/impls/protocol.md index b7c8ebd..0006b39 100644 --- a/docs/zh-cn/dev/impls/protocol.md +++ b/docs/zh-cn/dev/impls/protocol.md @@ -65,11 +65,11 @@ public interface Protocol { ## 已知扩展 -* `org.apache.dubbo.rpc.injvm.InjvmProtocol` -* `org.apache.dubbo.rpc.dubbo.DubboProtocol` -* `org.apache.dubbo.rpc.rmi.RmiProtocol` -* `org.apache.dubbo.rpc.http.HttpProtocol` -* `org.apache.dubbo.rpc.http.hessian.HessianProtocol` +* `org.apache.dubbo.rpc.protocol.injvm.InjvmProtocol` +* `org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol` +* `org.apache.dubbo.rpc.protocol.rmi.RmiProtocol` +* `org.apache.dubbo.rpc.protocol.http.HttpProtocol` +* `org.apache.dubbo.rpc.protocol.http.hessian.HessianProtocol` ## 扩展示例 @@ -148,4 +148,4 @@ META-INF/dubbo/org.apache.dubbo.rpc.Protocol: ```properties xxx=com.xxx.XxxProtocol -``` \ No newline at end of file +```
[dubbo-website] branch master updated: Separate the tables of maturity.md (#426)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new a6b4934 Separate the tables of maturity.md (#426) a6b4934 is described below commit a6b49348dbf803df1db0ce95caeff1a9d11dce1c Author: bigmeng AuthorDate: Mon Jul 8 09:17:04 2019 +0800 Separate the tables of maturity.md (#426) --- docs/en-us/user/maturity.md | 18 ++ docs/zh-cn/user/maturity.md | 21 - 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/en-us/user/maturity.md b/docs/en-us/user/maturity.md index 0d56dfe..0708723 100644 --- a/docs/en-us/user/maturity.md +++ b/docs/en-us/user/maturity.md @@ -36,40 +36,58 @@ | Redis registry | Stable | Support the client - based double - write clustering method with high performance | Please ensure server time synchronization, be used to check the expired dirty data of heartbeat | Can be used in the production environment | | | Multicast registry | Tested | Decentration, no registry needs to be installed | Depending on the network topology and routing, there is a risk across the server rooms | Can be used in a small range, in development/test environment | | | Simple registry| Tested | Dogfooding, the registry itself is also a standard RPC service | No cluster support, may occur single-point failure | On trial | | + | Feature| Maturity | Strength | Problem | Advise | User | +| -- | | | | | | | Simple monitor system | Stable | Support JFreeChart statistics report | No cluster support, may occur single-point failure, but the failure does not affect the RPC call | Can be used in the production environment | | + | Feature| Maturity | Strength | Problem | Advise | User | +| -- | | | | | | | Dubbo protocol | Stable | Use NIO to reuse a single long connection and use a thread pool to process requests concurrently, Reduce handshake and increase concurrency efficiency, good performance | A single connection will become a bottleneck in the transmission of large files | Can be used in the production environment | Alibaba | | Rmi protocol | Stable | Interoperable with native RMI, based on the TCP protocol | Occasionally the connection fails, and the stub needs to be rebuilt | Can be used in the production environment | Alibaba | | Hessian protocol | Stable | Interoperable with native Hessian, based on the HTTP protocol | Hessian.jar support is required, and the overhead of HTTP short connections is large | Can be used in the production environment | | + | Feature| Maturity | Strength | Problem | Advise | User | +| -- | | | | | | | Netty Transporter | Stable | The NIO framework of JBoss, has good performance | A request sends two events and needs to shield useless events | Can be used in the production environment | Alibaba | | Mina Transporter | Stable | Classic NIO framework,stable | The dispatch of the message queue is not timely, under great pressure, there will be FullGC | Can be used in the production environment | Alibaba | | Grizzly Transporter| Tested | The NIO framework of Sun, applied in the GlassFish container | The thread pool is not extensible, and Filter can't intercept the next filter | On trial | | + | Feature| Maturity | Strength | Problem | Advise | User | +| -- | | | | | | | Hessian Serialization | Stable | Good performance, multilingual support (recommended) | The compatibility
[dubbo-website] branch master updated: fix a typo and reformat the format (#425)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new c2f9412 fix a typo and reformat the format (#425) c2f9412 is described below commit c2f9412a02d8e5d7b8dfef5cd048e51a268ae057 Author: LHearen AuthorDate: Mon Jul 8 09:05:03 2019 +0800 fix a typo and reformat the format (#425) --- blog/en-us/dubbo-101.md | 4 ++-- docs/en-us/admin/install/consumer-demo.md | 18 +- docs/en-us/admin/install/provider-demo.md | 14 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/blog/en-us/dubbo-101.md b/blog/en-us/dubbo-101.md index 336a03b..a23cd6b 100644 --- a/blog/en-us/dubbo-101.md +++ b/blog/en-us/dubbo-101.md @@ -12,7 +12,7 @@ Java RMI (Remote Method Invocation) is a mechanism that allows users to access o ### Java RMI Work Flow -Here is how a typical RMI invocation usually works: +Here is how a typical RMI invocation usually works: 1. The server registers service from RMI and binds its address. 2. The client registers service from RMI and obtains target address. @@ -336,7 +336,7 @@ Run it directly in IDE and here are the results: ### Manage service by Telnet -If *qos* is actived during generation, the service can be watched and managed by *telnet* or *nc*. +If *qos* is activated during generation, the service can be watched and managed by *telnet* or *nc*. ```bash $ telnet localhost 2 diff --git a/docs/en-us/admin/install/consumer-demo.md b/docs/en-us/admin/install/consumer-demo.md index a9a53e6..73aec26 100644 --- a/docs/en-us/admin/install/consumer-demo.md +++ b/docs/en-us/admin/install/consumer-demo.md @@ -1,18 +1,18 @@ -# install demo consumer +# Install demo consumer -install: +Install: ```sh -git clone https://github.com/apache/dubbo.git -cd dubbo -Please start Provider first -add -Djava.net.preferIPv4Stack=true if your IDE is Intellij Idea +$ git clone https://github.com/apache/dubbo.git +$ cd dubbo +# please start Provider first +# add -Djava.net.preferIPv4Stack=true if your IDE is Intellij Idea ``` -configuration: +Configuration: ```sh -resource/META-INFO.spring/dubbo-demo-consumer.xml -change dubbo:registry to the real registry center address +# resource/META-INFO.spring/dubbo-demo-consumer.xml +# change dubbo:registry to the real registry center address ``` diff --git a/docs/en-us/admin/install/provider-demo.md b/docs/en-us/admin/install/provider-demo.md index 49f6ff2..557ca6a 100644 --- a/docs/en-us/admin/install/provider-demo.md +++ b/docs/en-us/admin/install/provider-demo.md @@ -1,17 +1,17 @@ -# install demo provider +# Install demo provider install: ```sh -git clone https://github.com/apache/dubbo.git -cd dubbo -run org.apache.dubbo.demo.provider.Provider under dubbo-demo-provider module -add -Djava.net.preferIPv4Stack=true if your IDE is Intellij Idea +$ git clone https://github.com/apache/dubbo.git +$ cd dubbo +# run org.apache.dubbo.demo.provider.Provider under dubbo-demo-provider module +# add -Djava.net.preferIPv4Stack=true if your IDE is Intellij Idea ``` configuration: ```sh -resource/META-INFO.spring/dubbo-demo-provider.xml -change dubbo:registry to a real registry server address, zookeeper is recommanded +# resource/META-INFO.spring/dubbo-demo-provider.xml +# change dubbo:registry to a real registry server address, zookeeper is recommended ```
[dubbo-website] branch master updated: Fix typos in maturity.md (#419)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 7927661 Fix typos in maturity.md (#419) 7927661 is described below commit 79276613a897e31742119baa660a66e5ac6ee1d9 Author: Kacper Fronc AuthorDate: Mon Jul 1 08:41:56 2019 +0800 Fix typos in maturity.md (#419) --- docs/en-us/user/maturity.md | 48 ++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/en-us/user/maturity.md b/docs/en-us/user/maturity.md index 97d79d9..0d56dfe 100644 --- a/docs/en-us/user/maturity.md +++ b/docs/en-us/user/maturity.md @@ -6,12 +6,12 @@ | -- | | | | | | | Concurrency control| Tested | concurrency control | | On trial | | | Connection control | Tested | connection number control| | On trial | | -| Connecting certain provider straightly | Tested | Provider service for point-to-point connecting straightly,for test | | Can be used in the test environment | Alibaba | -| Grouping polymerization| Tested | Return vlue of grouping polymerization, service for menu aggregation and other services | Used in special scenes | Can be used in the production environment | | -| Parameters validator | Tested | parameters validator,JSR303 validation framework integration | Have effect on Performance | On trial | LaiWang | -| Result cache | Tested | result cache,for accelerating requests | | On trial | | -| Generic reference | Stable | Generic reference,remote call without a business interface class,for test platforms, open api proxy service, and so on | | Can be used in the production environment | Alibaba | -| Generic service| Stable | Generic service,no interface class is required to implement any interface,for mock paltform | | Can be used in the production environment | Alibaba | +| Connecting certain provider straightly | Tested | Provider service for point-to-point connecting straightly, for test | | Can be used in the test environment | Alibaba | +| Grouping polymerization| Tested | Return value of grouping polymerization, service for menu aggregation and other services | Used in special scenes | Can be used in the production environment | | +| Parameters validator | Tested | parameters validator, JSR303 validation framework integration | Have effect on Performance | On trial | LaiWang | +| Result cache | Tested | result cache, for accelerating requests | | On trial | | +| Generic reference | Stable | Generic reference, remote call without a business interface class,for test platforms, open api proxy service, and so on | | Can be used in the production environment | Alibaba | +| Generic service| Stable | Generic service, no interface class is required to implement any interface, for mock platform | | Can be used in the production environment | Alibaba | | Echo test | Tested | echo test | | On trial | | | Attachment | Stable | Attachment | | Can be used in the production environment | | | Asynchronous call | Tested | Unavailable asynchronous call| | On trial | | @@ -19,25 +19,25 @@ | Callback parameter | Tested | Callback parameter | Used in special scenes | On trial
[dubbo-website] branch master updated: Fix typo in sidebar title for Serialization (#418)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 4895708 Fix typo in sidebar title for Serialization (#418) 4895708 is described below commit 4895708913f6684513c27cf92d5fa33d6201122f Author: Kacper Fronc AuthorDate: Mon Jul 1 08:38:48 2019 +0800 Fix typo in sidebar title for Serialization (#418) (Kyro -> Kryo) --- site_config/docs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site_config/docs.js b/site_config/docs.js index 30867e0..40c5709 100644 --- a/site_config/docs.js +++ b/site_config/docs.js @@ -238,7 +238,7 @@ export default { link: '/en-us/docs/user/demos/netty4.html' }, { -title: 'Serialization with FST and Kyro', +title: 'Serialization with FST and Kryo', link: '/en-us/docs/user/demos/serialization.html' } ],
[dubbo-website] branch master updated: fix Eco System some item url (#413)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/master by this push: new 0dc1740 fix Eco System some item url (#413) 0dc1740 is described below commit 0dc17406a73d1fb5a04caf49dd0f9ef762a9b026 Author: DLive AuthorDate: Fri Jun 21 08:04:21 2019 +0800 fix Eco System some item url (#413) --- site_config/community.jsx | 32 ++-- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/site_config/community.jsx b/site_config/community.jsx index 0c20f60..13f62af 100644 --- a/site_config/community.jsx +++ b/site_config/community.jsx @@ -131,19 +131,29 @@ export default { }, { text: 'Node.js', - link: 'https://github.com/dubbo/dubbo2.js', + link: 'https://github.com/apache/dubbo-js', bgColor: '#00D0D9', }, { text: 'Python', - link: 'https://github.com/dubbo/dubbo-client-py', + link: 'https://github.com/apache/dubbo-python', bgColor: '#00D0D9', }, { text: 'PHP', - link: 'https://github.com/dubbo/dubbo-php-framework', + link: 'https://github.com/apache/dubbo-php-framework', bgColor: '#00D0D9', }, +{ + text: 'Go', + link: 'https://github.com/apache/dubbo-go', + bgColor: '#00D0D9', +}, +{ + text: 'Erlang', + link: 'https://github.com/apache/dubbo-erlang', + bgColor: '#00D0D9', +} ], }, { @@ -558,19 +568,29 @@ export default { }, { text: 'Node.js', - link: 'https://github.com/dubbo/dubbo2.js', + link: 'https://github.com/apache/dubbo-js', bgColor: '#00D0D9', }, { text: 'Python', - link: 'https://github.com/dubbo/dubbo-client-py', + link: 'https://github.com/apache/dubbo-python', bgColor: '#00D0D9', }, { text: 'PHP', - link: 'https://github.com/dubbo/dubbo-php-framework', + link: 'https://github.com/apache/dubbo-php-framework', bgColor: '#00D0D9', }, +{ + text: 'Go', + link: 'https://github.com/apache/dubbo-go', + bgColor: '#00D0D9', +}, +{ + text: 'Erlang', + link: 'https://github.com/apache/dubbo-erlang', + bgColor: '#00D0D9', +} ], }, {
[dubbo] branch master updated (6f3a05c -> 041a6ad)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git. from 6f3a05c 1. 将URL中的默认值使用三目运算符表示。 (#4301) add 041a6ad [Dubbo-4323]fix use AtomicInteger instead of volatile to inc (#4324) No new revisions were added by this update. Summary of changes: .../java/org/apache/dubbo/cache/support/expiring/ExpiringMap.java| 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
[dubbo] branch master updated (3acf5b8 -> 6f3a05c)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/dubbo.git. from 3acf5b8 fix org.apache.dubbo.common.URL#toMap change password key, from USERNAME_KEY to PASSWORD_KEY (#4267) add 6f3a05c 1. 将URL中的默认值使用三目运算符表示。 (#4301) No new revisions were added by this update. Summary of changes: .../src/main/java/org/apache/dubbo/common/URL.java | 117 + 1 file changed, 25 insertions(+), 92 deletions(-)
[dubbo-website] branch asf-site updated: Update home.jsx (#394)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new 43731b8 Update home.jsx (#394) 43731b8 is described below commit 43731b85dec779467752558a360a0a1a6fbab259 Author: Jlcao AuthorDate: Wed Jun 12 11:56:36 2019 +0800 Update home.jsx (#394) --- site_config/home.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site_config/home.jsx b/site_config/home.jsx index 6c4d657..99e7019 100644 --- a/site_config/home.jsx +++ b/site_config/home.jsx @@ -83,7 +83,7 @@ export default { '/img/users_icbc.png', '/img/users_handu.png', '/img/users_rograndec.png', - '/img/user_chuangjinzhitou.png' + '/img/user_chuangjinzhitou.png' // '/img/users_other1.png', // '/img/users_other2.png' ], @@ -171,6 +171,7 @@ export default { '/img/users_icbc.png', '/img/users_handu.png', '/img/users_rograndec.png', + '/img/user_chuangjinzhitou.png' // '/img/users_other1.png', // '/img/users_other2.png' ],
[incubator-dubbo] branch master updated: Unit test of JValidator; Clean code of JValidator (#3723)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new c1be6c6 Unit test of JValidator; Clean code of JValidator (#3723) c1be6c6 is described below commit c1be6c61605c76c7656bde921b2a3505ebd8db1e Author: Taosheng Wei AuthorDate: Mon Mar 25 10:44:39 2019 +0800 Unit test of JValidator; Clean code of JValidator (#3723) --- .../validation/support/jvalidation/JValidator.java | 12 +- .../support/jvalidation/JValidatorTest.java| 27 ++ .../jvalidation/mock/JValidatorTestTarget.java | 8 +++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java b/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java index 9feccb2..735b37d 100644 --- a/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java +++ b/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/support/jvalidation/JValidator.java @@ -94,7 +94,7 @@ public class JValidator implements Validator { factory = Validation.buildDefaultValidatorFactory(); } this.validator = factory.getValidator(); -this.methodClassMap = new ConcurrentHashMap(); +this.methodClassMap = new ConcurrentHashMap<>(); } private static boolean isPrimitives(Class cls) { @@ -117,7 +117,7 @@ public class JValidator implements Validator { String parameterClassName = generateMethodParameterClassName(clazz, method); Class parameterClass; try { -parameterClass = (Class) Class.forName(parameterClassName, true, clazz.getClassLoader()); +parameterClass = Class.forName(parameterClassName, true, clazz.getClassLoader()); } catch (ClassNotFoundException e) { ClassPool pool = ClassGenerator.getClassPool(clazz.getClassLoader()); CtClass ctClass = pool.makeClass(parameterClassName); @@ -243,14 +243,14 @@ public class JValidator implements Validator { @Override public void validate(String methodName, Class[] parameterTypes, Object[] arguments) throws Exception { -List> groups = new ArrayList>(); +List> groups = new ArrayList<>(); Class methodClass = methodClass(methodName); if (methodClass != null) { groups.add(methodClass); } -Set> violations = new HashSet>(); +Set> violations = new HashSet<>(); Method method = clazz.getMethod(methodName, parameterTypes); -Class[] methodClasses = null; +Class[] methodClasses; if (method.isAnnotationPresent(MethodValidated.class)){ methodClasses = method.getAnnotation(MethodValidated.class).value(); groups.addAll(Arrays.asList(methodClasses)); @@ -260,7 +260,7 @@ public class JValidator implements Validator { groups.add(1, clazz); // convert list to array -Class[] classgroups = groups.toArray(new Class[0]); +Class[] classgroups = groups.toArray(new Class[groups.size()]); Object parameterBean = getMethodParameterBean(clazz, method, arguments); if (parameterBean != null) { diff --git a/dubbo-filter/dubbo-filter-validation/src/test/java/org/apache/dubbo/validation/support/jvalidation/JValidatorTest.java b/dubbo-filter/dubbo-filter-validation/src/test/java/org/apache/dubbo/validation/support/jvalidation/JValidatorTest.java index a45ea96..94768d2 100644 --- a/dubbo-filter/dubbo-filter-validation/src/test/java/org/apache/dubbo/validation/support/jvalidation/JValidatorTest.java +++ b/dubbo-filter/dubbo-filter-validation/src/test/java/org/apache/dubbo/validation/support/jvalidation/JValidatorTest.java @@ -23,6 +23,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import javax.validation.ConstraintViolationException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class JValidatorTest { @Test @@ -56,4 +60,27 @@ public class JValidatorTest { JValidator jValidator = new JValidator(url); jValidator.validate("someMethod2", new Class[]{ValidationParameter.class}, new Object[]{new ValidationParameter("NotBeNull")}); } + +@Test +public void testItWithArrayArg() throws Exception { +URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget"); +JValidator jValidator = new JValidator(url); +jValidator.validate(&q
[incubator-dubbo-website] branch asf-site updated: method spelling error (#339)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new 569d29d method spelling error (#339) 569d29d is described below commit 569d29dac67a96393bfe220f5e77b12cfd53f407 Author: huazhongming AuthorDate: Mon Mar 25 10:39:07 2019 +0800 method spelling error (#339) --- docs/zh-cn/user/references/xml/dubbo-method.md | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/zh-cn/user/references/xml/dubbo-method.md b/docs/zh-cn/user/references/xml/dubbo-method.md index 487e08d..4f29d02 100644 --- a/docs/zh-cn/user/references/xml/dubbo-method.md +++ b/docs/zh-cn/user/references/xml/dubbo-method.md @@ -49,13 +49,13 @@ table tr:hover { | 属性 | 对应URL参数 | 类型 | 是否必填 | 缺省值 | 作用 | 描述 | 兼容性 | | --- | --- | | --- | --- | --- | --- | --- | | name | | string | 必填 | | 标识 | 方法名 | 1.0.8以上版本 | -| timeout | metodName.timeout | int | 可选 | 缺省为的timeout | 性能调优 | 方法调用超时时间(毫秒) | 1.0.8以上版本 | -| retries | metodName.retries | int | 可选 | 缺省为dubbo:reference的retries | 性能调优 | 远程服务调用重试次数,不包括第一次调用,不需要重试请设为0 | 2.0.0以上版本 | -| loadbalance | metodName.loadbalance | string | 可选 | 缺省为的loadbalance | 性能调优 | 负载均衡策略,可选值:random,roundrobin,leastactive,分别表示:随机,轮询,最少活跃调用 | 2.0.0以上版本 | -| async | metodName.async | boolean | 可选 | 缺省为dubbo:reference的async | 性能调优 | 是否异步执行,不可靠异步,只是忽略返回值,不阻塞执行线程 | 1.0.9以上版本 | +| timeout | methodName.timeout | int | 可选 | 缺省为的timeout | 性能调优 | 方法调用超时时间(毫秒) | 1.0.8以上版本 | +| retries | methodName.retries | int | 可选 | 缺省为dubbo:reference的retries | 性能调优 | 远程服务调用重试次数,不包括第一次调用,不需要重试请设为0 | 2.0.0以上版本 | +| loadbalance | methodName.loadbalance | string | 可选 | 缺省为的loadbalance | 性能调优 | 负载均衡策略,可选值:random,roundrobin,leastactive,分别表示:随机,轮询,最少活跃调用 | 2.0.0以上版本 | +| async | methodName.async | boolean | 可选 | 缺省为dubbo:reference的async | 性能调优 | 是否异步执行,不可靠异步,只是忽略返回值,不阻塞执行线程 | 1.0.9以上版本 | | sent | methodName.sent | boolean | 可选 | true | 性能调优 | 异步调用时,标记sent=true时,表示网络已发出数据 | 2.0.6以上版本 | -| actives | metodName.actives | int | 可选 | 0 | 性能调优 | 每服务消费者最大并发调用限制 | 2.0.5以上版本 | -| executes | metodName.executes | int | 可选 | 0 | 性能调优 | 每服务每方法最大使用线程数限制 ,此属性只在dubbo:method作为dubbo:service子标签时有效 | 2.0.5以上版本 | +| actives | methodName.actives | int | 可选 | 0 | 性能调优 | 每服务消费者最大并发调用限制 | 2.0.5以上版本 | +| executes | methodName.executes | int | 可选 | 0 | 性能调优 | 每服务每方法最大使用线程数限制 ,此属性只在dubbo:method作为dubbo:service子标签时有效 | 2.0.5以上版本 | | deprecated | methodName.deprecated | boolean | 可选 | false | 服务治理 | 服务方法是否过时,此属性只在dubbo:method作为dubbo:service子标签时有效 | 2.0.5以上版本 | | sticky | methodName.sticky | boolean | 可选 | false | 服务治理 | 设置true 该接口上的所有方法使用同一个provider.如果需要更复杂的规则,请使用用路由 | 2.0.6以上版本 | | return | methodName.return | boolean | 可选 | true | 性能调优 | 方法调用是否需要返回值,async设置为true时才生效,如果设置为true,则返回future,或回调onreturn等方法,如果设置为false,则请求发送成功后直接返回Null | 2.0.6以上版本 |
[incubator-dubbo-website] branch asf-site updated: 1. new a blog to introduce dubbo2.7 new features 2. fomart blog.js 3. change my chinese name to english nick name (#337)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new b15f236 1. new a blog to introduce dubbo2.7 new features 2. fomart blog.js 3. change my chinese name to english nick name (#337) b15f236 is described below commit b15f236627b8290e3fd1953ba30c3d1faa22b1a7 Author: xujingfeng <250577...@qq.com> AuthorDate: Fri Mar 22 14:09:42 2019 +0800 1. new a blog to introduce dubbo2.7 new features 2. fomart blog.js 3. change my chinese name to english nick name (#337) --- blog/zh-cn/dubbo-27-features.md | 230 + site_config/blog.js | 1037 --- 2 files changed, 752 insertions(+), 515 deletions(-) diff --git a/blog/zh-cn/dubbo-27-features.md b/blog/zh-cn/dubbo-27-features.md new file mode 100644 index 000..22c4c5a --- /dev/null +++ b/blog/zh-cn/dubbo-27-features.md @@ -0,0 +1,230 @@ +--- +title: Dubbo2.7 三大新特性详解 +keywords: Dubbo2.7 +description: 异步化改造,三大中心改造,服务治理增强 +--- + +# + +## 1 背景介绍 + +自 2017 年 7 月阿里重启 Dubbo 开源,到目前为止 github star 数,contributor 数都有了非常大的提升。2018 年 2 月 9 日阿里决定将 Dubbo 项目贡献给 Apache,经过一周的投票,顺利成为了 Apache 的孵化项目,也就是大家现在看到的 **Incubator Dubbo**。预计在 2019 年 4 月,Dubbo 可以达成毕业,成为 Apache 的顶级项目。 + +## 2 分支介绍 + +![分支](http://kirito.iocoder.cn/image-20190321153455566.png) + +Dubbo 目前有如图所示的 5 个分支,其中 2.7.1-release 只是一个临时分支,忽略不计,对其他 4 个分支进行介绍。 + +- 2.5.x 近期已经通过投票,Dubbo 社区即将停止对其的维护。 +- 2.6.x 为长期支持的版本,也是 Dubbo 贡献给 Apache 之前的版本,其包名前缀为:com.alibaba,JDK 版本对应 1.6。 +- 3.x-dev 是前瞻性的版本,对 Dubbo 进行一些高级特性的补充,如支持 rx 特性。 +- master 为长期支持的版本,版本号为 2.7.x,也是 Dubbo 贡献给 Apache 的开发版本,其包名前缀为:org.apache,JDK 版本对应 1.8。 + +> 如果想要研究 Dubbo 的源码,建议直接浏览 master 分支。 + +## 3 Dubbo 2.7 新特性 + +Dubbo 2.7.x 作为 Apache 的孵化版本,除了代码优化之外,还新增了许多重磅的新特性,本文将会介绍其中最典型的三个新特性: + +- 异步化改造 +- 三大中心改造 +- 服务治理增强 + +## 4 异步化改造 + +### 4.1 几种调用方式 + +![调用方式](http://kirito.iocoder.cn/image-20190321160844133.png) + +在远程方法调用中,大致可以分为这 4 种调用方式。oneway 指的是客户端发送消息后,不需要接受响应。对于那些不关心服务端响应的请求,比较适合使用 oneway 通信。 + +> 注意,void hello() 方法在远程方法调用中,不属于 oneway 调用,虽然 void 方法表达了不关心返回值的语义,但在 RPC 层面,仍然需要做通信层的响应。 + +sync 是最常用的通信方式,也是默认的通信方法。 + +future 和 callback 都属于异步调用的范畴,他们的区别是:在接收响应时,future.get() 会导致线程的阻塞;callback 通常会设置一个回调线程,当接收到响应时,自动执行,不会对当前线程造成阻塞。 + +### 4.2 Dubbo 2.6 异步化 + +异步化的优势在于客户端不需要启动多线程即可完成并行调用多个远程服务,相对多线程开销较小。介绍 2.7 中的异步化改造之前,先回顾一下如何在 2.6 中使用 Dubbo 异步化的能力。 + +1. 将同步接口声明成 `async=true` +```xml + +``` +```java +public interface AsyncService { +String sayHello(String name); +} +``` +2. 通过上下文类获取 future +```java +AsyncService.sayHello("Han Meimei"); +Future fooFuture = RpcContext.getContext().getFuture(); +fooFuture.get(); +``` + +可以看出,这样的使用方式,不太符合异步编程的习惯,竟然需要从一个上下文类中获取到 Future。如果同时进行多个异步调用,使用不当很容易造成上下文污染。而且,Future 并不支持 callback 的调用方式。这些弊端在 Dubbo 2.7 中得到了改进。 + +### 4.3 Dubbo 2.7 异步化 + +1. 无需配置中特殊声明,显式声明异步接口即可 +```java +public interface AsyncService { +String sayHello(String name); +default CompletableFuture sayHiAsync(String name) { +return CompletableFuture.completedFuture(sayHello(name)); +} +} +``` +2. 使用 callback 方式处理返回值 +```java +CompletableFuture future = asyncService.sayHiAsync("Han MeiMei"); +future.whenComplete((retValue, exception) -> { +if (exception == null) { +System.out.println(retValue); +} else { +exception.printStackTrace(); +} +}); +``` + +Dubbo 2.7 中使用了 JDK1.8 提供的 `CompletableFuture` 原生接口对自身的异步化做了改进。`CompletableFuture` 可以支持 future 和 callback 两种调用方式,用户可以根据自己的喜好和场景选择使用,非常灵活。 + +### 4.4 异步化设计 FAQ + +Q:如果 RPC 接口只定义了同步接口,有办法使用异步调用吗? + +A:2.6 中的异步调用唯一的优势在于,不需要在接口层面做改造,又可以进行异步调用,这种方式仍然在 2.7 中保留;使用 Dubbo 官方提供的 compiler hacker,编译期自动重写同步方法,请[在此](https://github.com/dubbo/dubbo-async-processor#compiler-hacker-processer)讨论和跟进具体进展。 + +--- + +Q:关于异步接口的设计问题,为何不提供编译插件,根据原接口,自动编译出一个 XxxAsync 接口? + +A:Dubbo 2.7 采用过这种设计,但接口的膨胀会导致服务类的增量发布,而且接口名的变化会影响服务治理的一些相关逻辑,改为方法添加 Async 后缀相对影响范围较小。 + +--- + +Q:Dubbo 分为了客户端异步和服务端异步,刚刚你介绍的是客户端异步,为什么不提服务端异步呢? + +A:Dubbo 2.7 新增了服务端异步的支持,但实际上,Dubbo 的业务线程池模型,本身就可以理解为异步调用,个人认为服务端异步的特性较为鸡肋。 + +## 5 三大中心改造 + +三大中心指的:注册中心,元数据中心,配置中心。 + +在 2.7 之前的版本,Dubbo 只配备了注册中心,主流使用的注册中心为 zookeeper。新增加了元数据中心和配置中心,自然是为了解决对应的痛点,下面我们来详细阐释三大中心改造的原因。 + +### 5.1 元数据改造 + +元数据是什么?元数据定义为描述数据的数据,在服务治理中,例如服务接口名,重试次数,版本号等等都可以理解为元数据。在 2.7 之前,元数据一股脑丢在了注册中心之中,这造成了一系列的问题: + +**推送量大 -> 存储数据量大 -> 网络传输量大 -> 延迟严重** + +生产者端注册 30+ 参数,有接近一半是不需要作为注册中心进行传递;消费者端注册 25+ 参数,只有个别需要传递给注册中心。有了以上的理论分析,Dubbo 2.7 进行了大刀阔斧的改动,只将真正属于服务治理的数据发布到注册中心之中,大大降低了注册中心的负荷。 + +同时,将全量的元数据发布到另外的组件中:元数据中心。元数据中心目前支持 redis(推荐),zookeeper。这也为 Dubbo 2.7 全新的 Dubbo Admin 做了准备,关于新版的 Dubbo Admin,我将会后续准备一篇独立的文章进行介绍。 + +示例:使用 zookeeper 作为元数据中心 + +```xml + +``` + +### 5.2 Dubbo 2.6 元数据 + +```shell +dubbo://30.5.120.185:20880/
[incubator-dubbo-website] branch asf-site updated: fix link error (#335)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new 5246503 fix link error (#335) 5246503 is described below commit 5246503b7e7a84813a5ae0a58978780ebc40842a Author: xujingfeng <250577...@qq.com> AuthorDate: Wed Mar 20 20:10:35 2019 +0800 fix link error (#335) --- site_config/blog.js | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/site_config/blog.js b/site_config/blog.js index e853fe8..af3caca 100644 --- a/site_config/blog.js +++ b/site_config/blog.js @@ -182,7 +182,7 @@ export default { author: '@JeffLv', dateStr: 'Feb 20th, 2019', desc: 'Dubbo客户端异步接口的实现背景和实践', -link: '/zh-cn/blog/dubboAync_client.html', +link: '/zh-cn/blog/dubboAsync_client.html', }, { title: 'Dubbo服务端异步接口的实现背景和实践', @@ -283,13 +283,6 @@ export default { link: '/zh-cn/blog/dubbo-copywriting-style.html', }, { -title: 'Dubbo 中的 URL 统一模型', -author:'@徐靖峰', -dateStr: 'Dec 27th, 2018', -desc: 'URL 是 Dubbo 种一个重要的领域模型,了解它可以更加轻松的理解 Dubbo 的设计理念。', -link: '/zh-cn/blog/introduction-to-dubbo-url.html', -}, -{ title: '当Dubbo遇上Arthas:排查问题的实践', author:'@hengyunabc', dateStr: 'Dec 14th, 2018',
[incubator-dubbo] branch master updated: fix-3678 (#3681)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new da69a9c fix-3678 (#3681) da69a9c is described below commit da69a9c8db15b6047cb80ed3d2251215784dcb0e Author: kexianjun AuthorDate: Wed Mar 20 20:04:16 2019 +0800 fix-3678 (#3681) --- .../org/apache/dubbo/remoting/exchange/support/DefaultFuture.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java index 059fdaa..290d668 100644 --- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java +++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java @@ -329,9 +329,7 @@ public class DefaultFuture implements ResponseFuture { lock.lock(); try { response = res; -if (done != null) { -done.signal(); -} +done.signalAll(); } finally { lock.unlock(); }
[incubator-dubbo-website] branch asf-site updated: Remove redundant symbols
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new f201607 Remove redundant symbols f201607 is described below commit f2016079f1df9ad276a5ff12904f5e2170192178 Author: lixiaojiee AuthorDate: Mon Mar 18 00:16:27 2019 +0800 Remove redundant symbols --- blog/zh-cn/dubbo-new-async.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/zh-cn/dubbo-new-async.md b/blog/zh-cn/dubbo-new-async.md index 6d9eff2..6735c58 100644 --- a/blog/zh-cn/dubbo-new-async.md +++ b/blog/zh-cn/dubbo-new-async.md @@ -475,7 +475,7 @@ CompletableFuture类型的接口既可以用作同步调用,也可以实现Con ``` public static void main(String[] args) throws Exception { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/async-``consumer.xml"}); + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/async-consumer.xml"}); context.start(); AsyncService asyncService = (AsyncService) context.getBean("asyncService");
[incubator-dubbo] branch master updated: Dubbo-3473 Fix Not Properly Closed Resources (#3474)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 2e660df Dubbo-3473 Fix Not Properly Closed Resources (#3474) 2e660df is described below commit 2e660dfef7282b43bc58113df39e61b7a79bdf0e Author: Furkan KAMACI AuthorDate: Thu Mar 7 13:08:55 2019 +0300 Dubbo-3473 Fix Not Properly Closed Resources (#3474) --- .../src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java | 3 +-- .../org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java index 7995468..ae7b92c 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java @@ -76,8 +76,7 @@ public class GenericFilter implements Filter { } else if (ProtocolUtils.isJavaGenericSerialization(generic)) { for (int i = 0; i < args.length; i++) { if (byte[].class == args[i].getClass()) { -try { -UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i]); +try(UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) { args[i] = ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA) .deserialize(null, is).readObject(); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java index 5ab3c27..b62198d 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java @@ -55,8 +55,7 @@ public class LogTelnetHandler implements TelnetHandler { int showLogLength = Integer.parseInt(str[0]); if (file != null && file.exists()) { -try { -FileInputStream fis = new FileInputStream(file); +try(FileInputStream fis = new FileInputStream(file)) { FileChannel filechannel = fis.getChannel(); size = filechannel.size(); ByteBuffer bb;
[incubator-dubbo] branch master updated: replace magic string "dubbo" with constants (#3602)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 6a70284 replace magic string "dubbo" with constants (#3602) 6a70284 is described below commit 6a7028446bcd76ec75c742ab283c7dc5675144e7 Author: kezhenxu94 AuthorDate: Wed Mar 6 18:59:35 2019 +0800 replace magic string "dubbo" with constants (#3602) --- .../java/org/apache/dubbo/common/Constants.java| 6 ++ .../src/main/java/org/apache/dubbo/common/URL.java | 24 +++--- .../org/apache/dubbo/common/utils/UrlUtils.java| 24 +++--- .../dubbo/config/AbstractInterfaceConfig.java | 6 +++--- .../dubbo/monitor/dubbo/DubboMonitorFactory.java | 3 ++- 5 files changed, 35 insertions(+), 28 deletions(-) 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 dd7d22e..aa6ae05 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 @@ -753,6 +753,12 @@ public class Constants { public static final String HOST_KEY = "host"; +public static final String PORT_KEY = "port"; + +public static final String USERNAME_KEY = "username"; + +public static final String PASSWORD_KEY = "password"; + public static final String ADDRESS_KEY = "address"; public static final String RETRY_TIMES_KEY = "retry.times"; diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java index 7809140..9167a03 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java @@ -1122,22 +1122,22 @@ class URL implements Serializable { } public String getRawParameter(String key) { -if ("protocol".equals(key)) { +if (Constants.PROTOCOL_KEY.equals(key)) { return protocol; } -if ("username".equals(key)) { +if (Constants.USERNAME_KEY.equals(key)) { return username; } -if ("password".equals(key)) { +if (Constants.PASSWORD_KEY.equals(key)) { return password; } -if ("host".equals(key)) { +if (Constants.HOST_KEY.equals(key)) { return host; } -if ("port".equals(key)) { +if (Constants.PORT_KEY.equals(key)) { return String.valueOf(port); } -if ("path".equals(key)) { +if (Constants.PATH_KEY.equals(key)) { return path; } return getParameter(key); @@ -1146,22 +1146,22 @@ class URL implements Serializable { public Map toMap() { Map map = new HashMap(parameters); if (protocol != null) { -map.put("protocol", protocol); +map.put(Constants.PROTOCOL_KEY, protocol); } if (username != null) { -map.put("username", username); +map.put(Constants.USERNAME_KEY, username); } if (password != null) { -map.put("password", password); +map.put(Constants.USERNAME_KEY, password); } if (host != null) { -map.put("host", host); +map.put(Constants.HOST_KEY, host); } if (port > 0) { -map.put("port", String.valueOf(port)); +map.put(Constants.PORT_KEY, String.valueOf(port)); } if (path != null) { -map.put("path", path); +map.put(Constants.PATH_KEY, path); } return map; } diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java index 23b5033..f7ca5c0 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java @@ -63,22 +63,22 @@ public class UrlUtils { url += URL_PARAM_STARTING_SYMBOL + Constants.BACKUP_KEY + "=" + backup.toString(); } } -String defaultProtocol = defaults == null ? null : defaults.get("protocol"); +String defaultProtocol = defaults == null ? null : defaults.get(Constants.PROTOCOL_KEY); if (defaultProtocol == null || defaultProtocol.length() == 0) { -defaultProtocol = "dubbo"; +defaultProtocol = Constants.DUBBO_PROTOCOL; } -String
[incubator-dubbo] branch master updated: fix issue #195: @Reference check=false不生效 (#3530)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 05a98f3 fix issue #195: @Reference check=false不生效 (#3530) 05a98f3 is described below commit 05a98f3214d35ba13978bc88988d5a83864b8cd7 Author: Ian Luo AuthorDate: Sun Feb 24 14:23:37 2019 +0800 fix issue #195: @Reference check=false不生效 (#3530) --- .../java/com/alibaba/dubbo/config/annotation/Reference.java| 2 +- .../java/org/apache/dubbo/config/AbstractReferenceConfig.java | 10 +- .../java/org/apache/dubbo/config/AbstractServiceConfig.java| 8 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dubbo-compatible/src/main/java/com/alibaba/dubbo/config/annotation/Reference.java b/dubbo-compatible/src/main/java/com/alibaba/dubbo/config/annotation/Reference.java index 4c1ca97..c8f25b3 100644 --- a/dubbo-compatible/src/main/java/com/alibaba/dubbo/config/annotation/Reference.java +++ b/dubbo-compatible/src/main/java/com/alibaba/dubbo/config/annotation/Reference.java @@ -43,7 +43,7 @@ public @interface Reference { boolean generic() default false; -boolean injvm() default false; +boolean injvm() default true; boolean check() default true; diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java index 325b1f1..b4a732e 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java @@ -36,12 +36,12 @@ public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig { /** * Check if service provider exists, if not exists, it will be fast fail */ -protected Boolean check; +protected Boolean check = true; /** * Whether to eagle-init */ -protected Boolean init; +protected Boolean init = false; /** * Whether to use generic interface @@ -51,16 +51,16 @@ public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig { /** * Whether to find reference's instance from the current JVM */ -protected Boolean injvm; +protected Boolean injvm = false; /** * Lazy create connection */ -protected Boolean lazy; +protected Boolean lazy = false; protected String reconnect; -protected Boolean sticky; +protected Boolean sticky = false; /** * Whether to support event in stub. diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java index 4fffd75..ac27644 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java @@ -47,7 +47,7 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig { /** * whether the service is deprecated */ -protected Boolean deprecated; +protected Boolean deprecated = false; /** * The time delay register service (milliseconds) @@ -57,7 +57,7 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig { /** * Whether to export the service */ -protected Boolean export; +protected Boolean export = true; /** * The service weight @@ -74,7 +74,7 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig { * after the service registered,and it needs to be enabled manually; if you want to disable the service, you also need * manual processing */ -protected Boolean dynamic; +protected Boolean dynamic = false; /** * Whether to use token @@ -99,7 +99,7 @@ public abstract class AbstractServiceConfig extends AbstractInterfaceConfig { /** * Whether to register */ -private Boolean register; +private Boolean register = true; /** * Warm up period
[incubator-dubbo] branch master updated: fix issue #3533 (#3548)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new e89b3f2 fix issue #3533 (#3548) e89b3f2 is described below commit e89b3f2728248242e38e70627d761be776ef03ec Author: THY AuthorDate: Sun Feb 24 14:20:57 2019 +0800 fix issue #3533 (#3548) --- .../apache/dubbo/configcenter/support/zookeeper/CacheListener.java | 5 + 1 file changed, 5 insertions(+) diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java index a1e1f08..1851a22 100644 --- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java +++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java @@ -38,6 +38,8 @@ import java.util.concurrent.CountDownLatch; * */ public class CacheListener implements TreeCacheListener { +private static final byte[] EMPTY_BYTES = new byte[0]; + private Map> keyListeners = new ConcurrentHashMap<>(); private CountDownLatch initializedLatch; private String rootPath; @@ -83,6 +85,9 @@ public class CacheListener implements TreeCacheListener { return; } +if (value == null) { +value = EMPTY_BYTES; +} ConfigChangeEvent configChangeEvent = new ConfigChangeEvent(key, new String(value, StandardCharsets.UTF_8), changeType); Set listeners = keyListeners.get(key); if (CollectionUtils.isNotEmpty(listeners)) {
[incubator-dubbo-website] branch asf-site updated: Add an article of gracefully shutdown (#303)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new d99abc1 Add an article of gracefully shutdown (#303) d99abc1 is described below commit d99abc168177d4a01051ba7d544b85913936de1f Author: GuoHao AuthorDate: Sun Feb 24 13:55:21 2019 +0800 Add an article of gracefully shutdown (#303) --- blog/zh-cn/dubbo-gracefully-shutdown.md | 114 site_config/blog.js | 7 ++ 2 files changed, 121 insertions(+) diff --git a/blog/zh-cn/dubbo-gracefully-shutdown.md b/blog/zh-cn/dubbo-gracefully-shutdown.md new file mode 100644 index 000..1858931 --- /dev/null +++ b/blog/zh-cn/dubbo-gracefully-shutdown.md @@ -0,0 +1,114 @@ +--- +title: Dubbo 优雅停机 +keywords: Dubbo, Gracefully Shutdown, Safely Shutdown +description: 介绍Dubbo优雅停机的原理和使用方式 +--- + +# Dubbo 优雅停机 + +## 背景 + +对于任何一个线上应用,如何在服务更新部署过程中保证客户端无感知是开发者必须要解决的问题,即从应用停止到重启恢复服务这个阶段不能影响正常的业务请求。理想条件下,在没有请求的时候再进行更新是最安全可靠的,然而互联网应用必须要保证可用性,因此在技术层面上优化应用更新流程来保证服务在更新时无损是必要的。 + +传统的解决方式是通过将应用更新流程划分为手工摘流量、停应用、更新重启三个步骤,由人工操作实现客户端无对更新感知。这种方式简单而有效,但是限制较多:不仅需要使用借助网关的支持来摘流量,还需要在停应用前人工判断来保证在途请求已经处理完毕。这种需要人工介入的方式运维复杂度较高,只能适用规模较小的应用,无法在大规模系统上使用。 + +因此,如果在容器/框架级别提供某种自动化机制,来自动进行摘流量并确保处理完以到达的请求,不仅能保证业务不受更新影响,还可以极大地提升更新应用时的运维效率。 + +这个机制也就是优雅停机,目前Tomcat/Undertow/Dubbo等容器/框架都有提供相关实现。下面给出正式一些的定义:优雅停机是指在停止应用时,执行的一系列保证应用正常关闭的操作。这些操作往往包括等待已有请求执行完成、关闭线程、关闭连接和释放资源等,优雅停机可以避免非正常关闭程序可能造成数据异常或丢失,应用异常等问题。优雅停机本质上是JVM即将关闭前执行的一些额外的处理代码。 + +## 适用场景 + +- JVM主动关闭(`System.exit(int)`; +- JVM由于资源问题退出(`OOM`); +- 应用程序接受到`SIGTERM`或`SIGINT`信号。 + +## 配置方式 +### 服务的优雅停机 +在Dubbo中,优雅停机是默认开启的,停机等待时间为1毫秒。可以通过配置`dubbo.service.shutdown.wait`来修改等待时间。 + +例如将等待时间设置为20秒可通过增加以下配置实现: + +```shell +dubbo.service.shutdown.wait=2 +``` + +### 容器的优雅停机 +当使用`org.apache.dubbo.container.Main`这种容器方式来使用 Dubbo 时,也可以通过配置`dubbo.shutdown.hook`为`true`来开启优雅停机。 + +### 通过QOS优雅上下线 + +基于`ShutdownHook`方式的优雅停机无法确保所有关闭流程一定执行完,所以 Dubbo 推出了多段关闭的方式来保证服务完全无损。 + +多段关闭即将停止应用分为多个步骤,通过运维自动化脚本或手工操作的方式来保证脚本每一阶段都能执行完毕。 + +在关闭应用前,首先通过 QOS 的`offline`指令下线所有服务,然后等待一定时间确保已经到达请求全部处理完毕,由于服务已经在注册中心下线,当前应用不会有新的请求。这时再执行真正的关闭(`SIGTERM` 或` SIGINT`)流程,就能保证服务无损。 + +QOS可通过 telnet 或 HTTP 方式使用,具体方式请见[Dubbo-QOS命令使用说明](http://dubbo.apache.org/zh-cn/docs/user/references/qos.html)。 + +## 流程 + +Provider在接收到停机指令后 + +- 从注册中心上注销所有服务; +- 从配置中心取消监听动态配置; +- 向所有连接的客户端发送只读事件,停止接收新请求; +- 等待一段时间以处理已到达的请求,然后关闭请求处理线程池; +- 断开所有客户端连接。 + +Consumer在接收到停机指令后 + +- 拒绝新到请求,直接返回调用异常; +- 等待当前已发送请求执行完毕,如果响应超时则强制关闭连接。 + +当使用容器方式运行 Dubbo 时,在容器准备退出前,可进行一系列的资源释放和清理工。 + +例如使用 SpringContainer时,Dubbo 的ShutdownHook线程会执行`ApplicationContext`的`stop`和`close`方法,保证 Bean的生命周期完整。 + +## 实现原理 + +1. 在加载类`org.apache.dubbo.config.AbstractConfig`时,通过`org.apache.dubbo.config.DubboShutdownHook`向JVM注册 ShutdownHook。 + + ```java + /** +* Register the ShutdownHook +*/ + public void register() { + if (!registered.get() && registered.compareAndSet(false, true)) { + Runtime.getRuntime().addShutdownHook(getDubboShutdownHook()); + } + } + ``` + +2. 每个ShutdownHook都是一个单独的线程,由JVM在退出时触发执行`org.apache.dubbo.config.DubboShutdownHook`。 + + ```java + /** +* Destroy all the resources, including registries and protocols. +*/ + public void doDestroy() { + if (!destroyed.compareAndSet(false, true)) { + return; + } + // destroy all the registries + AbstractRegistryFactory.destroyAll(); + // destroy all the protocols + destroyProtocols(); + } + ``` + +3. 首先关闭所有注册中心,这一步包括: + - 从注册中心注销所有已经发布的服务; + - 取消订阅当前应用所有依赖的服务; + - 断开与注册中心的连接。 +4. 执行所有`Protocol`的`destroy()`,主要包括: + - 销毁所有`Invoker`和`Exporter`; + - 关闭Server,向所有已连接Client发送当前Server只读事件; + - 关闭独享/共享Client,断开连接,取消超时和重试任务; + - 释放所有相关资源。 +5. 执行完毕,关闭JVM。 + +## 注意事项 + +- 使用`SIGKILL`关闭应用不会执行优雅停机; +- 优雅停机不保证会等待所有已发送/到达请求结束; +- 配置的优雅停机等待时间`timeout`不是所有步骤等待时间的总和,而是每一个`destroy`执行的最大时间。例如配置等待时间为5秒,则关闭Server、关闭Client等步骤会分别等待5秒。 diff --git a/site_config/blog.js b/site_config/blog.js index ab52335..0d8ac30 100644 --- a/site_config/blog.js +++ b/site_config/blog.js @@ -163,6 +163,13 @@ export default { barText: '博客', postsTitle: '所有文章', list: [ +{ +title: 'Dubbo优雅停机介绍', +author: '@guohao', +dateStr: 'Feb 22th, 2019', +desc: 'Dubbo优雅停机的实现背景和实践', +link: '/zh-cn/blog/dubbo-gracefully-shutdown.html', +}, { title: 'Dubbo客户端异步接口的实现背景和实践', author: '@JeffLv',
[incubator-dubbo] branch master updated: [Enhancement]: refactor categorizing with Collectors.groupingBy (#3490)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 717c15e [Enhancement]: refactor categorizing with Collectors.groupingBy (#3490) 717c15e is described below commit 717c15e6581dc818552ef9bdf4cb6961d9b234da Author: kezhenxu94 AuthorDate: Wed Feb 20 00:04:00 2019 +0800 [Enhancement]: refactor categorizing with Collectors.groupingBy (#3490) --- .../registry/integration/RegistryDirectory.java| 47 +- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java index 449bb28..f843871 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java @@ -52,6 +52,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -64,7 +65,6 @@ import static org.apache.dubbo.common.Constants.DYNAMIC_CONFIGURATORS_CATEGORY; import static org.apache.dubbo.common.Constants.PROVIDERS_CATEGORY; import static org.apache.dubbo.common.Constants.ROUTERS_CATEGORY; import static org.apache.dubbo.common.Constants.ROUTE_PROTOCOL; -import static org.apache.dubbo.common.utils.UrlUtils.classifyUrls; /** @@ -124,7 +124,7 @@ public class RegistryDirectory extends AbstractDirectory implements Notify this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY)); this.overrideDirectoryUrl = this.directoryUrl = turnRegistryUrlToConsumerUrl(url); String group = directoryUrl.getParameter(Constants.GROUP_KEY, ""); -this.multiGroup = group != null && ("*".equals(group) || group.contains(",")); +this.multiGroup = group != null && (Constants.ANY_VALUE.equals(group) || group.contains(",")); } private URL turnRegistryUrlToConsumerUrl(URL url) { @@ -189,21 +189,30 @@ public class RegistryDirectory extends AbstractDirectory implements Notify @Override public synchronized void notify(List urls) { -List categoryUrls = urls.stream() +Map> categoryUrls = urls.stream() +.filter(Objects::nonNull) .filter(this::isValidCategory) .filter(this::isNotCompatibleFor26x) -.collect(Collectors.toList()); +.collect(Collectors.groupingBy(url -> { +if (UrlUtils.isConfigurator(url)) { +return CONFIGURATORS_CATEGORY; +} else if (UrlUtils.isRoute(url)) { +return ROUTERS_CATEGORY; +} else if (UrlUtils.isProvider(url)) { +return PROVIDERS_CATEGORY; +} +return ""; +})); -/** - * TODO Try to refactor the processing of these three type of urls using Collectors.groupBy()? - */ -this.configurators = Configurator.toConfigurators(classifyUrls(categoryUrls, UrlUtils::isConfigurator)) -.orElse(configurators); +List configuratorURLs = categoryUrls.getOrDefault(CONFIGURATORS_CATEGORY, Collections.emptyList()); +this.configurators = Configurator.toConfigurators(configuratorURLs).orElse(this.configurators); -toRouters(classifyUrls(categoryUrls, UrlUtils::isRoute)).ifPresent(this::addRouters); +List routerURLs = categoryUrls.getOrDefault(ROUTERS_CATEGORY, Collections.emptyList()); +toRouters(routerURLs).ifPresent(this::addRouters); // providers -refreshOverrideAndInvoker(classifyUrls(categoryUrls, UrlUtils::isProvider)); +List providerURLs = categoryUrls.getOrDefault(PROVIDERS_CATEGORY, Collections.emptyList()); +refreshOverrideAndInvoker(providerURLs); } private void refreshOverrideAndInvoker(List urls) { @@ -283,7 +292,7 @@ public class RegistryDirectory extends AbstractDirectory implements Notify private List> toMergeInvokerList(List> invokers) { List> mergedInvokers = new ArrayList<>(); -Map>> groupMap = new HashMap>>(); +Map>> groupMap = new HashMap<>(); for (Invoker invoker : invokers) { String group = invoker.getUrl().getParameter(Constants.GROUP_KEY, "");
[incubator-dubbo] branch master updated: fix issue#1293: A question for ReferenceConfigCache. (#3505)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 7c236ca fix issue#1293: A question for ReferenceConfigCache. (#3505) 7c236ca is described below commit 7c236ca8f74e6797dac4d432a37294ee8a4529d5 Author: Ian Luo AuthorDate: Tue Feb 19 23:09:54 2019 +0800 fix issue#1293: A question for ReferenceConfigCache. (#3505) --- .../dubbo/config/utils/ReferenceConfigCache.java | 55 +- .../config/utils/ReferenceConfigCacheTest.java | 8 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java index 5ca9698..09f12da 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java @@ -39,28 +39,25 @@ public class ReferenceConfigCache { * * key example: group1/org.apache.dubbo.foo.FooService:1.0.0. */ -public static final KeyGenerator DEFAULT_KEY_GENERATOR = new KeyGenerator() { -@Override -public String generateKey(ReferenceConfig referenceConfig) { -String iName = referenceConfig.getInterface(); -if (StringUtils.isBlank(iName)) { -Class clazz = referenceConfig.getInterfaceClass(); -iName = clazz.getName(); -} -if (StringUtils.isBlank(iName)) { -throw new IllegalArgumentException("No interface info in ReferenceConfig" + referenceConfig); -} - -StringBuilder ret = new StringBuilder(); -if (!StringUtils.isBlank(referenceConfig.getGroup())) { -ret.append(referenceConfig.getGroup()).append("/"); -} -ret.append(iName); -if (!StringUtils.isBlank(referenceConfig.getVersion())) { -ret.append(":").append(referenceConfig.getVersion()); -} -return ret.toString(); +public static final KeyGenerator DEFAULT_KEY_GENERATOR = referenceConfig -> { +String iName = referenceConfig.getInterface(); +if (StringUtils.isBlank(iName)) { +Class clazz = referenceConfig.getInterfaceClass(); +iName = clazz.getName(); } +if (StringUtils.isBlank(iName)) { +throw new IllegalArgumentException("No interface info in ReferenceConfig" + referenceConfig); +} + +StringBuilder ret = new StringBuilder(); +if (!StringUtils.isBlank(referenceConfig.getGroup())) { +ret.append(referenceConfig.getGroup()).append("/"); +} +ret.append(iName); +if (!StringUtils.isBlank(referenceConfig.getVersion())) { +ret.append(":").append(referenceConfig.getVersion()); +} +return ret.toString(); }; static final ConcurrentMap cacheHolder = new ConcurrentHashMap(); private final String name; @@ -115,6 +112,22 @@ public class ReferenceConfigCache { return (T) config.get(); } +/** + * Fetch cache with the specified key. The key is decided by KeyGenerator passed-in. If the default KeyGenerator is + * used, then the key is in the format of group/interfaceClass:version + * + * @param key cache key + * @param type object class + * @param object type + * @return object from the cached ReferenceConfig + * @see KeyGenerator#generateKey(ReferenceConfig) + */ +@SuppressWarnings("unchecked") +public T get(String key, Class type) { +ReferenceConfig config = cache.get(key); +return (config != null) ? (T) config.get() : null; +} + void destroyKey(String key) { ReferenceConfig config = cache.remove(key); if (config == null) { diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ReferenceConfigCacheTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ReferenceConfigCacheTest.java index af5659e..2af6da7 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ReferenceConfigCacheTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/ReferenceConfigCacheTest.java @@ -59,6 +59,14 @@ public class ReferenceConfigCacheTest { } @Test +public void testGetCacheWithKey() throws Exception { +ReferenceConfigCache cache = ReferenceConfigCache.getCache(); +MockReferenceConfig config = buildMockReferenceConfig(&q
[incubator-dubbo-website] branch asf-site updated: Fix and improve [first-dubbo-filter.md] (#288)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new 3a22a50 Fix and improve [first-dubbo-filter.md] (#288) 3a22a50 is described below commit 3a22a509094c0d4c34adc344de2208b5ec8e32c2 Author: web AuthorDate: Sun Feb 17 14:04:28 2019 +0800 Fix and improve [first-dubbo-filter.md] (#288) --- blog/zh-cn/first-dubbo-filter.md | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/blog/zh-cn/first-dubbo-filter.md b/blog/zh-cn/first-dubbo-filter.md index b0fd455..9f0830f 100644 --- a/blog/zh-cn/first-dubbo-filter.md +++ b/blog/zh-cn/first-dubbo-filter.md @@ -152,7 +152,7 @@ src XxxFilter.java: -``` +```java public class XxxFilter implements Filter { public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { // before filter ... @@ -167,4 +167,29 @@ META-INF/dubbo/com.alibaba.dubbo.rpc.Filter: ``` xxx=com.xxx.XxxFilter ``` + +在 xml 中配置: + +```xml + + + + + + + + +``` + +或者使用注解: + +```java +@Activate(group = "consumer") +public class XxxFilter implements Filter { +// ... +} +``` + +使用 xml 的配置方式会更加灵活,粒度更细。 + 在before和after中,可以实现自己的业务逻辑来赋予改filter一定的功能。编写和配置完成后,该filter就会被Dubbo框架激活并且在调用链中执行。
[incubator-dubbo] branch master updated: [Enhancement]: RestProtocol (#3480)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 813fed5 [Enhancement]: RestProtocol (#3480) 813fed5 is described below commit 813fed53e8da58beb48bae9ed602f133abb3f747 Author: kezhenxu94 AuthorDate: Sun Feb 17 13:51:12 2019 +0800 [Enhancement]: RestProtocol (#3480) --- .../dubbo/rpc/protocol/rest/RestProtocol.java | 50 +- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java index 4290ef2..26d0aa0 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java @@ -28,16 +28,13 @@ import org.apache.dubbo.rpc.protocol.AbstractProxyProtocol; import org.apache.http.HeaderElement; import org.apache.http.HeaderElementIterator; -import org.apache.http.HttpResponse; import org.apache.http.client.config.RequestConfig; import org.apache.http.config.SocketConfig; -import org.apache.http.conn.ConnectionKeepAliveStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.message.BasicHeaderElementIterator; import org.apache.http.protocol.HTTP; -import org.apache.http.protocol.HttpContext; import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; @@ -65,7 +62,7 @@ public class RestProtocol extends AbstractProxyProtocol { private static final int HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS = 1000; private static final int HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S = 30; -private final Map servers = new ConcurrentHashMap(); +private final Map servers = new ConcurrentHashMap<>(); private final RestServerFactory serverFactory = new RestServerFactory(); @@ -91,12 +88,11 @@ public class RestProtocol extends AbstractProxyProtocol { protected Runnable doExport(T impl, Class type, URL url) throws RpcException { String addr = getAddr(url); Class implClass = ApplicationModel.getProviderModel(url.getServiceKey()).getServiceInstance().getClass(); -RestServer server = servers.get(addr); -if (server == null) { -server = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, DEFAULT_SERVER)); -server.start(url); -servers.put(addr, server); -} +RestServer server = servers.computeIfAbsent(addr, restServer -> { +RestServer s = serverFactory.createServer(url.getParameter(Constants.SERVER_KEY, DEFAULT_SERVER)); +s.start(url); +return s; +}); String contextPath = getContextPath(url); if ("servlet".equalsIgnoreCase(url.getParameter(Constants.SERVER_KEY, DEFAULT_SERVER))) { @@ -124,13 +120,10 @@ public class RestProtocol extends AbstractProxyProtocol { server.deploy(resourceDef, impl, contextPath); final RestServer s = server; -return new Runnable() { -@Override -public void run() { -// TODO due to dubbo's current architecture, -// it will be called from registry protocol in the shutdown process and won't appear in logs -s.undeploy(resourceDef); -} +return () -> { +// TODO due to dubbo's current architecture, +// it will be called from registry protocol in the shutdown process and won't appear in logs +s.undeploy(resourceDef); }; } @@ -159,20 +152,17 @@ public class RestProtocol extends AbstractProxyProtocol { .build(); CloseableHttpClient httpClient = HttpClientBuilder.create() -.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() { -@Override -public long getKeepAliveDuration(HttpResponse response, HttpContext context) { -HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE)); -while (it.hasNext()) { -HeaderElement he = it.nextElement(); -String param = he.getName(); -String value = he.getValue(); -if (value != null && param.equalsIgnoreCase(Constants.TIMEOUT_KEY)) { -
[incubator-dubbo] branch master updated: fix typo (#3491)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 2b12c16 fix typo (#3491) 2b12c16 is described below commit 2b12c1661469a693a4df7b617d85a1e9e4d3e84e Author: kezhenxu94 AuthorDate: Sun Feb 17 13:32:15 2019 +0800 fix typo (#3491) --- dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java | 2 +- .../java/org/apache/dubbo/config/AbstractInterfaceConfig.java | 4 ++-- .../src/main/java/org/apache/dubbo/config/ProtocolConfig.java | 8 3 files changed, 7 insertions(+), 7 deletions(-) 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 1180731..dd7d22e 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 @@ -247,7 +247,7 @@ public class Constants { public static final String PROTOCOL_KEY = "protocol"; -public static final String DOBBO_PROTOCOL = DUBBO; +public static final String DUBBO_PROTOCOL = DUBBO; public static final String ZOOKEEPER_PROTOCOL = "zookeeper"; diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java index 4899d5a..78624d3 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java @@ -350,12 +350,12 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig { if (getExtensionLoader(MonitorFactory.class).hasExtension("logstat")) { map.put(Constants.PROTOCOL_KEY, "logstat"); } else { -map.put(Constants.PROTOCOL_KEY, Constants.DOBBO_PROTOCOL); +map.put(Constants.PROTOCOL_KEY, Constants.DUBBO_PROTOCOL); } } return UrlUtils.parseURL(address, map); } else if (Constants.REGISTRY_PROTOCOL.equals(monitor.getProtocol()) && registryURL != null) { - return registryURL.setProtocol(Constants.DOBBO_PROTOCOL).addParameter(Constants.PROTOCOL_KEY, Constants.REGISTRY_PROTOCOL).addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map)); + return registryURL.setProtocol(Constants.DUBBO_PROTOCOL).addParameter(Constants.PROTOCOL_KEY, Constants.REGISTRY_PROTOCOL).addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map)); } return null; } diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java index 5f60b4f..008f7bf 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java @@ -317,7 +317,7 @@ public class ProtocolConfig extends AbstractConfig { } public void setCodec(String codec) { -if (Constants.DOBBO_PROTOCOL.equals(name)) { +if (Constants.DUBBO_PROTOCOL.equals(name)) { checkMultiExtension(Codec.class, Constants.CODEC_KEY, codec); } this.codec = codec; @@ -328,7 +328,7 @@ public class ProtocolConfig extends AbstractConfig { } public void setSerialization(String serialization) { -if (Constants.DOBBO_PROTOCOL.equals(name)) { +if (Constants.DUBBO_PROTOCOL.equals(name)) { checkMultiExtension(Serialization.class, Constants.SERIALIZATION_KEY, serialization); } this.serialization = serialization; @@ -371,7 +371,7 @@ public class ProtocolConfig extends AbstractConfig { } public void setServer(String server) { -if (Constants.DOBBO_PROTOCOL.equals(name)) { +if (Constants.DUBBO_PROTOCOL.equals(name)) { checkMultiExtension(Transporter.class, Constants.SERVER_KEY, server); } this.server = server; @@ -382,7 +382,7 @@ public class ProtocolConfig extends AbstractConfig { } public void setClient(String client) { -if (Constants.DOBBO_PROTOCOL.equals(name)) { +if (Constants.DUBBO_PROTOCOL.equals(name)) { checkMultiExtension(Transporter.class, Constants.CLIENT_KEY, client); } this.client = client;
[incubator-dubbo] branch master updated: Branch refactor version (#3471)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new d33784d Branch refactor version (#3471) d33784d is described below commit d33784d3c887aefd647e24a9e46f58be8ad4f02a Author: wanghb AuthorDate: Fri Feb 15 17:12:49 2019 +0800 Branch refactor version (#3471) --- .../main/java/org/apache/dubbo/common/Version.java | 148 - 1 file changed, 83 insertions(+), 65 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java b/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java index 099b2bb..6872e24 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java @@ -21,6 +21,7 @@ import org.apache.dubbo.common.logger.LoggerFactory; import org.apache.dubbo.common.utils.ClassHelper; import org.apache.dubbo.common.utils.StringUtils; +import java.io.IOException; import java.net.URL; import java.security.CodeSource; import java.util.Enumeration; @@ -28,12 +29,16 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Version */ public final class Version { private static final Logger logger = LoggerFactory.getLogger(Version.class); + +private static final Pattern PREFIX_DIGITS_PATTERN = Pattern.compile("^([0-9]*).*"); // Dubbo RPC protocol version, for compatibility, it must not be between 2.0.10 ~ 2.6.2 public static final String DEFAULT_DUBBO_PROTOCOL_VERSION = "2.0.2"; @@ -120,73 +125,47 @@ public final class Version { String[] vArr = version.split("\\."); int len = vArr.length; for (int i = 0; i < len; i++) { -v += Integer.parseInt(getDigital(vArr[i])) * Math.pow(10, (len - i - 1) * 2); +v += Integer.parseInt(getPrefixDigits(vArr[i])) * Math.pow(10, (len - i - 1) * 2); } return v; } -private static String getDigital(String v) { -int index = 0; -for (int i = 0; i < v.length(); i++) { -char c = v.charAt(i); -if (Character.isDigit(c)) { -if (i == v.length() - 1) { -index = i + 1; -} else { -index = i; -} -} else { -index = i; -break; -} -} -return v.substring(0, index); -} - -private static boolean hasResource(String path) { -try { -return Version.class.getClassLoader().getResource(path) != null; -} catch (Throwable t) { -return false; +/** + * get prefix digits from given version string + */ +private static String getPrefixDigits(String v) { +Matcher matcher = PREFIX_DIGITS_PATTERN.matcher(v); +if (matcher.find()) { +return matcher.group(1); } +return ""; } public static String getVersion(Class cls, String defaultVersion) { try { // find version info from MANIFEST.MF first String version = cls.getPackage().getImplementationVersion(); -if (StringUtils.isEmpty(version)) { -version = cls.getPackage().getSpecificationVersion(); +if (!StringUtils.isEmpty(version)) { +return version; } -if (StringUtils.isEmpty(version)) { -// guess version fro jar file name if nothing's found from MANIFEST.MF -CodeSource codeSource = cls.getProtectionDomain().getCodeSource(); -if (codeSource == null) { -logger.info("No codeSource for class " + cls.getName() + " when getVersion, use default version " + defaultVersion); -} else { -String file = codeSource.getLocation().getFile(); -if (file != null && file.length() > 0 && file.endsWith(".jar")) { -file = file.substring(0, file.length() - 4); -int i = file.lastIndexOf('/'); -if (i >= 0) { -file = file.substring(i + 1); -} -i = file.indexOf("-"); -if (i >= 0) { -file = file.substring(i + 1); -} -while (file.length() > 0 && !Character.isDigit(file.charAt(0))) { -i = file.indexOf("-"); -if (i >= 0) { -
[incubator-dubbo] branch master updated: Class comment error (#3481)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new bd6e5f1 Class comment error (#3481) bd6e5f1 is described below commit bd6e5f101ba5ddaa6bd4f153d694bf7dcf0c19d0 Author: Jia He <491311...@qq.com> AuthorDate: Fri Feb 15 11:29:56 2019 +0800 Class comment error (#3481) --- .../src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java | 2 +- .../src/main/java/org/apache/dubbo/config/ConsumerConfig.java | 2 +- .../src/main/java/org/apache/dubbo/config/MetadataReportConfig.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java index 58c6138..45677bf 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java @@ -27,7 +27,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; /** - * + * ConfigCenterConfig */ public class ConfigCenterConfig extends AbstractConfig { private AtomicBoolean inited = new AtomicBoolean(false); diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConsumerConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConsumerConfig.java index 3a556e7..afbd4c4 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConsumerConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConsumerConfig.java @@ -19,7 +19,7 @@ package org.apache.dubbo.config; import org.apache.dubbo.common.utils.StringUtils; /** - * The service consumer default confuguration + * The service consumer default configuration * * @export */ diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java index a4ace7a..e7add0a 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/MetadataReportConfig.java @@ -25,7 +25,7 @@ import java.util.Map; import static org.apache.dubbo.common.Constants.PROPERTIES_CHAR_SEPERATOR; /** - * RegistryConfig + * MetadataReportConfig * * @export */
[incubator-dubbo] branch master updated: extract method to cache default extension name (#3456)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new cad253a extract method to cache default extension name (#3456) cad253a is described below commit cad253a0d745204c617df007cd8239305a53173f Author: wanghb AuthorDate: Wed Feb 13 10:48:19 2019 +0800 extract method to cache default extension name (#3456) --- .../dubbo/common/extension/ExtensionLoader.java| 25 ++ 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java index 36c7707..e47e19d 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java @@ -624,6 +624,22 @@ public class ExtensionLoader { // synchronized in getExtensionClasses private Map> loadExtensionClasses() { +cacheDefaultExtensionName(); + +Map> extensionClasses = new HashMap<>(); +loadDirectory(extensionClasses, DUBBO_INTERNAL_DIRECTORY, type.getName()); +loadDirectory(extensionClasses, DUBBO_INTERNAL_DIRECTORY, type.getName().replace("org.apache", "com.alibaba")); +loadDirectory(extensionClasses, DUBBO_DIRECTORY, type.getName()); +loadDirectory(extensionClasses, DUBBO_DIRECTORY, type.getName().replace("org.apache", "com.alibaba")); +loadDirectory(extensionClasses, SERVICES_DIRECTORY, type.getName()); +loadDirectory(extensionClasses, SERVICES_DIRECTORY, type.getName().replace("org.apache", "com.alibaba")); +return extensionClasses; +} + +/** + * extract and cache default extension name if exists + */ +private void cacheDefaultExtensionName() { final SPI defaultAnnotation = type.getAnnotation(SPI.class); if (defaultAnnotation != null) { String value = defaultAnnotation.value(); @@ -638,15 +654,6 @@ public class ExtensionLoader { } } } - -Map> extensionClasses = new HashMap>(); -loadDirectory(extensionClasses, DUBBO_INTERNAL_DIRECTORY, type.getName()); -loadDirectory(extensionClasses, DUBBO_INTERNAL_DIRECTORY, type.getName().replace("org.apache", "com.alibaba")); -loadDirectory(extensionClasses, DUBBO_DIRECTORY, type.getName()); -loadDirectory(extensionClasses, DUBBO_DIRECTORY, type.getName().replace("org.apache", "com.alibaba")); -loadDirectory(extensionClasses, SERVICES_DIRECTORY, type.getName()); -loadDirectory(extensionClasses, SERVICES_DIRECTORY, type.getName().replace("org.apache", "com.alibaba")); -return extensionClasses; } private void loadDirectory(Map> extensionClasses, String dir, String type) {
[incubator-dubbo] branch master updated: [Dubbo-3237]fix connectionMonitor in RestProtocol seems not work #3237 (#3455)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 10912c8 [Dubbo-3237]fix connectionMonitor in RestProtocol seems not work #3237 (#3455) 10912c8 is described below commit 10912c811598285c62f7c0f28530732dd1115e5b Author: huazhongming AuthorDate: Wed Feb 13 01:01:11 2019 +0800 [Dubbo-3237]fix connectionMonitor in RestProtocol seems not work #3237 (#3455) --- .../org/apache/dubbo/rpc/protocol/rest/RestProtocol.java| 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java index 7f8bc79..4290ef2 100644 --- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java +++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java @@ -61,7 +61,7 @@ public class RestProtocol extends AbstractProxyProtocol { private static final int HTTPCLIENTCONNECTIONMANAGER_MAXPERROUTE = 20; private static final int HTTPCLIENTCONNECTIONMANAGER_MAXTOTAL = 20; -private static final int HTTPCLIENT_KEEPALIVEDURATION = 30*1000; +private static final int HTTPCLIENT_KEEPALIVEDURATION = 30 * 1000; private static final int HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS = 1000; private static final int HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S = 30; @@ -70,7 +70,7 @@ public class RestProtocol extends AbstractProxyProtocol { private final RestServerFactory serverFactory = new RestServerFactory(); // TODO in the future maybe we can just use a single rest client and connection manager -private final List clients = Collections.synchronizedList(new LinkedList()); +private final List clients = Collections.synchronizedList(new LinkedList<>()); private volatile ConnectionMonitor connectionMonitor; @@ -136,9 +136,6 @@ public class RestProtocol extends AbstractProxyProtocol { @Override protected T doRefer(Class serviceType, URL url) throws RpcException { -if (connectionMonitor == null) { -connectionMonitor = new ConnectionMonitor(); -} // TODO more configs to add PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); @@ -146,6 +143,10 @@ public class RestProtocol extends AbstractProxyProtocol { connectionManager.setMaxTotal(url.getParameter(Constants.CONNECTIONS_KEY, HTTPCLIENTCONNECTIONMANAGER_MAXTOTAL)); connectionManager.setDefaultMaxPerRoute(url.getParameter(Constants.CONNECTIONS_KEY, HTTPCLIENTCONNECTIONMANAGER_MAXPERROUTE)); +if (connectionMonitor == null) { +connectionMonitor = new ConnectionMonitor(); +connectionMonitor.start(); +} connectionMonitor.addConnectionManager(connectionManager); RequestConfig requestConfig = RequestConfig.custom() .setConnectTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT)) @@ -239,7 +240,7 @@ public class RestProtocol extends AbstractProxyProtocol { protected String getContextPath(URL url) { String contextPath = url.getPath(); -return contextPath.endsWith("/") ? contextPath.substring(0,contextPath.length()-1) : contextPath; +return contextPath.endsWith("/") ? contextPath.substring(0, contextPath.length() - 1) : contextPath; } protected class ConnectionMonitor extends Thread {
[incubator-dubbo-website] branch asf-site updated: Wrong text (#284)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new 58d3baf Wrong text (#284) 58d3baf is described below commit 58d3baff8124be538f295adcb4fe493ac21e1fb8 Author: huazhongming AuthorDate: Tue Feb 12 17:38:51 2019 +0800 Wrong text (#284) --- docs/zh-cn/source_code_guide/loadbalance.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh-cn/source_code_guide/loadbalance.md b/docs/zh-cn/source_code_guide/loadbalance.md index ca7a4b5..d86f9bf 100644 --- a/docs/zh-cn/source_code_guide/loadbalance.md +++ b/docs/zh-cn/source_code_guide/loadbalance.md @@ -262,7 +262,7 @@ int offsetWeight = random.nextInt(totalWeight) + 1; ### 2.3 ConsistentHashLoadBalance -一致性 hash 算法由麻省理工学院的 Karger 及其合作者于1997年提供出的,算法提出之初是用于大规模缓存系统的负载均衡。它的工作过程是这样的,首先根据 ip 或其他的信息为缓存节点生成一个 hash,并将这个 hash 投射到 [0, 232 - 1] 的圆环上。当有查询或写入请求时,则为缓存项的 key 生成一个 hash 值。然后查找第一个大于或等于该 hash 值的缓存节点,并到这个节点中查询或写入缓存项。如果当前节点挂了,则在下一次查询或写入缓存时,为缓存项查找另一个大于其 hash 值的缓存节点即可。大致效果如下图所示,每个缓存节点在圆环上占据一个位置。如果缓存项的 key 的 hash 值小于缓存节点 hash 值,则到该缓存节点中存储或读取缓存项。比如下面绿色点对应的缓存项将会被存储到 cache-2 节点中。由于 cache-3 挂了,原本应该存到该节点中的缓� �想最终会存储到 cache-4 节点中。 +一致性 hash 算法由麻省理工学院的 Karger 及其合作者于1997年提出的,算法提出之初是用于大规模缓存系统的负载均衡。它的工作过程是这样的,首先根据 ip 或者其他的信息为缓存节点生成一个 hash,并将这个 hash 投射到 [0, 232 - 1] 的圆环上。当有查询或写入请求时,则为缓存项的 key 生成一个 hash 值。然后查找第一个大于或等于该 hash 值的缓存节点,并到这个节点中查询或写入缓存项。如果当前节点挂了,则在下一次查询或写入缓存时,为缓存项查找另一个大于其 hash 值的缓存节点即可。大致效果如下图所示,每个缓存节点在圆环上占据一个位置。如果缓存项的 key 的 hash 值小于缓存节点 hash 值,则到该缓存节点中存储或读取缓存项。比如下面绿色点对应的缓存项将会被存储到 cache-2 节点中。由于 cache-3 挂了,原本应该存到该节点中的缓� �项最终会存储到 cache-4 节点中。 ![](./sources/images/consistent-hash.jpg) @@ -375,7 +375,7 @@ private Invoker selectForKey(long hash) { // 到 TreeMap 中查找第一个节点值大于或等于当前 hash 的 Invoker Map.Entry> entry = virtualInvokers.tailMap(hash, true).firstEntry(); // 如果 hash 大于 Invoker 在圆环上最大的位置,此时 entry = null, -// 需要将 TreeMap 的头结点赋值给 entry +// 需要将 TreeMap 的头节点赋值给 entry if (entry == null) { entry = virtualInvokers.firstEntry(); }
[incubator-dubbo] branch master updated: Add delay export test case (#3447)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new fa2316e Add delay export test case (#3447) fa2316e is described below commit fa2316eb29843439ae9097df2bd4f865ac88d538 Author: LiZhen AuthorDate: Tue Feb 12 16:16:16 2019 +0800 Add delay export test case (#3447) --- .../org/apache/dubbo/config/ServiceConfigTest.java | 23 -- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java index 1030bf3..dc3d253 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java @@ -31,7 +31,6 @@ import org.apache.dubbo.rpc.Exporter; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Protocol; import org.apache.dubbo.rpc.service.GenericService; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -40,6 +39,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Collections; +import java.util.concurrent.TimeUnit; import static org.apache.dubbo.common.Constants.GENERIC_SERIALIZATION_BEAN; import static org.apache.dubbo.common.Constants.GENERIC_SERIALIZATION_DEFAULT; @@ -52,6 +52,7 @@ import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.withSettings; public class ServiceConfigTest { @@ -60,7 +61,7 @@ public class ServiceConfigTest { private Exporter exporter = Mockito.mock(Exporter.class); private ServiceConfig service = new ServiceConfig(); private ServiceConfig service2 = new ServiceConfig(); - +private ServiceConfig delayService = new ServiceConfig(); @BeforeEach public void setUp() throws Exception { @@ -104,6 +105,14 @@ public class ServiceConfigTest { service2.setMethods(Collections.singletonList(method)); service2.setProxy("testproxyfactory"); +delayService.setProvider(provider); +delayService.setApplication(app); +delayService.setRegistry(registry); +delayService.setInterface(DemoService.class); +delayService.setRef(new DemoServiceImpl()); +delayService.setMethods(Collections.singletonList(method)); +delayService.setDelay(100); + ConfigManager.getInstance().clear(); } @@ -143,6 +152,16 @@ public class ServiceConfigTest { assertEquals(2, TestProxyFactory.count); // local injvm and registry protocol, so expected is 2 } + +@Test +public void testDelayExport() throws Exception { +delayService.export(); +assertTrue(delayService.getExportedUrls().isEmpty()); +//add 300ms to ensure that the delayService has been exported +TimeUnit.MILLISECONDS.sleep(delayService.getDelay() + 300); +assertThat(delayService.getExportedUrls(), hasSize(1)); +} + @Test @Disabled("cannot pass in travis") public void testUnexport() throws Exception {
[incubator-dubbo.wiki] branch master updated: change the copyright year
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.wiki.git The following commit(s) were added to refs/heads/master by this push: new c6add92 change the copyright year c6add92 is described below commit c6add927165b7475d1d4eea002cebd90595678ff Author: XiaoJie Li AuthorDate: Tue Feb 12 01:39:00 2019 +0800 change the copyright year --- _Footer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_Footer.md b/_Footer.md index 07e103c..09922f4 100644 --- a/_Footer.md +++ b/_Footer.md @@ -1 +1 @@ -Copyright © 2018 The Apache Software Foundation. \ No newline at end of file +Copyright © 2019 The Apache Software Foundation. \ No newline at end of file
[incubator-dubbo-website] branch asf-site updated: fix (#280)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git The following commit(s) were added to refs/heads/asf-site by this push: new ab4d916 fix (#280) ab4d916 is described below commit ab4d916c3a626f27bff045c1af628bc0f166a11a Author: yuemingming <32236524+yuemingm...@users.noreply.github.com> AuthorDate: Mon Feb 4 00:12:22 2019 +0800 fix (#280) --- docs/zh-cn/source_code_guide/export-service.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-cn/source_code_guide/export-service.md b/docs/zh-cn/source_code_guide/export-service.md index 9a8ecb5..9e13315 100644 --- a/docs/zh-cn/source_code_guide/export-service.md +++ b/docs/zh-cn/source_code_guide/export-service.md @@ -394,7 +394,7 @@ private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List r 上面的代码首先是将一些信息,比如版本、时间戳、方法名以及各种配置对象的字段信息放入到 map 中,map 中的内容将作为 URL 的查询字符串。构建好 map 后,紧接着是获取上下文路径、主机名以及端口号等信息。最后将 map 和主机名等数据传给 URL 构造方法创建 URL 对象。需要注意的是,这里出现的 URL 并非 java.net.URL,而是 com.alibaba.dubbo.common.URL。 -上面省略了一段代码,这里简单分析一下。这段代码用于检测 \ 标签中的配置信息,并将相关配置添加到 map 中。代码如下: +上面省略了一段代码,这里简单分析一下。这段代码用于检测 \ 标签中的配置信息,并将相关配置添加到 map 中。代码如下: ```java private void doExportUrlsFor1Protocol(ProtocolConfig protocolConfig, List registryURLs) {
[incubator-dubbo] branch master updated: remove useless catch exception (#3421)
This is an automated email from the ASF dual-hosted git repository. lixiaojie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 1a88b32 remove useless catch exception (#3421) 1a88b32 is described below commit 1a88b32800a3a6310e44b5f11f2409e37c9878ae Author: mjaow AuthorDate: Sun Feb 3 20:08:20 2019 +0800 remove useless catch exception (#3421) --- .../dubbo/remoting/transport/netty4/NettyCodecAdapter.java | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyCodecAdapter.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyCodecAdapter.java index 24d5d00..5f3b784 100644 --- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyCodecAdapter.java +++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyCodecAdapter.java @@ -83,19 +83,11 @@ final class NettyCodecAdapter { NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler); -Object msg; - -int saveReaderIndex; - try { // decode object. do { -saveReaderIndex = message.readerIndex(); -try { -msg = codec.decode(channel, message); -} catch (IOException e) { -throw e; -} +int saveReaderIndex = message.readerIndex(); +Object msg = codec.decode(channel, message); if (msg == Codec2.DecodeResult.NEED_MORE_INPUT) { message.readerIndex(saveReaderIndex); break;