You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/06/27 08:20:49 UTC

[dubbo-website] branch asf-site updated: [Doc] Dubbo's Config Center model corresponding to different thirdparty products (#388)

This is an automated email from the ASF dual-hosted git repository.

liujun 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 43cd04a  [Doc] Dubbo's Config Center model corresponding to different thirdparty products (#388)
43cd04a is described below

commit 43cd04ae017a3d7b3bb49c9841d5835bbe9c2144
Author: ken.lj <ke...@gmail.com>
AuthorDate: Thu Jun 27 16:20:44 2019 +0800

    [Doc] Dubbo's Config Center model corresponding to different thirdparty products (#388)
---
 docs/zh-cn/dev/configcenter/design.md |  82 ++++++++++++++++++++++++++++++++++
 img/configcenter_nacos_model.jpg      | Bin 0 -> 78352 bytes
 img/configcenter_zk_model.jpg         | Bin 0 -> 189160 bytes
 img/configcenter_zk_properties.jpg    | Bin 0 -> 92946 bytes
 img/configcenter_zk_rule.jpg          | Bin 0 -> 131167 bytes
 img/configcenter_zk_singleitem.jpg    | Bin 0 -> 53837 bytes
 6 files changed, 82 insertions(+)

diff --git a/docs/zh-cn/dev/configcenter/design.md b/docs/zh-cn/dev/configcenter/design.md
new file mode 100644
index 0000000..ae521a8
--- /dev/null
+++ b/docs/zh-cn/dev/configcenter/design.md
@@ -0,0 +1,82 @@
+# Dubbo配置中心
+
+## 设计目的
+配置中心的核心功能是作为Key-Value存储,Dubbo框架告知配置中心其关心的key,配置中心返回该key对应的value值。
+
+按照应用场景划分,配置中心在Dubbo框架中主要承担以下职责:
+
+- 作为外部化配置中心,即存储dubbo.properties配置文件,此时,key值通常为文件名如dubbo.properties,value则为配置文件内容。
+- 存储单个配置项,如各种开关项、常量值等。
+- 存储服务治理规则,此时key通常按照"服务名+规则类型"的格式来组织,而value则为具体的治理规则。
+
+为了进一步实现对key-value的分组管理,Dubbo的配置中心还加入了namespace、group的概念,这些概念在很多专业的第三方配置中心中都有体现,通常情况下,namespace用来隔离不同的租户,group用来对统一租户的key集合做分组。
+
+当前,Dubbo配置中心实现了对Zookeeper、Nacos、Etcd、Consul、Apollo的对接,接下来我们具体看一下Dubbo抽象的配置中心是怎么映射到具体的第三方实现中的。
+
+## 实现原理
+
+### Zookeeper
+
+zookeeper提供了一个树状的存储模型,其实现原理如下:
+
+![image-20190127225608553](/img/configcenter_zk_model.jpg)
+
+namespace, group, key等分别对应不同层级的ZNode节点,而value则作为根ZNode节点的值存储。
+
+1. 外部化配置中心 dubbo.properties
+
+   ![image-20190127225608553](/img/configcenter_zk_properties.jpg)
+   
+   上图展示了两个不同作用域的dubbo.properties文件在zookeeper中的存储结构:
+   - 命名空间namespace都为:dubbo
+   - 分组group:全局级别为dubbo,所有应用共享;应用级别为应用名demo-provider,只对改应用生效
+   - key:dubbo.properties
+   
+2. 单个配置项
+
+   ![image-20190127225608553](/img/configcenter_zk_singleitem.jpg)
+   
+   设置优雅停机事件为15000:
+   - 命名空间namespace:dubbo
+   - 分组group:dubbo
+   - key:dubbo.service.shutdown.wait=15000
+     
+3. 服务治理规则
+
+    ![image-20190127225608553](/img/configcenter_zk_rule.jpg)
+    
+    上图展示了一条应用级别的条件路由规则:
+    
+    - 命名空间namespace:dubbo
+    - 分组group:dubbo
+    - key:governance-conditionrouter-consumer.condition-router,其中governance-conditionrouter-consumer为应用名,condition-router代表条件路由
+    
+    
+    > 注意:
+    >
+    > Dubbo同时支持应用、服务两种粒度的服务治理规则,对于这两种粒度,其key取值规则如下:
+    > * 应用粒度 {应用名 + 规则后缀}。如: `demo-application.configurators`、`demo-application.tag-router`等
+    > * 服务粒度 {服务接口名:[服务版本]:[服务分组] + 规则后缀},其中服务版本、服务分组是可选的,如果它们有配置则在key中体现,没被配置则用":"占位。如
+    > `org.apache.dubbo.demo.DemoService::.configurators`、`org.apache.dubbo.demo.DemoService:1.0.0:group1.configurators`
+
+### Etcd & Consul
+
+Etcd和Consul本质上也是一种类似zookeeper的树状存储结构,实现请参考zookeeper。
+
+### Nacos
+
+Nacos作为一个专业的第三方配置中心,拥有专门为配置中心设计的存储结构,包括内置的namespace、group、dataid等概念。并且这几个概念基本上与Dubbo框架抽象的配置中心是一一对应的。
+
+与Zookeeper实现的对应关系如下:
+
+![image-20190127225608553](/img/configcenter_nacos_model.jpg)
+
+参考上文关于zookeeper实现中描述的示例,这里的dataid可能为:
+* 外部化配置中心:dubbo.properties
+* 单个配置项:dubbo.service.shutdown.wait
+* 服务治理规则:org.apache.dubbo.demo.DemoService:1.0.0:group1.configurators
+
+### Apollo
+
+Apollo与Nacos类似,请参考动态配置中心使用文档中关于Apollo部分的描述。
+
diff --git a/img/configcenter_nacos_model.jpg b/img/configcenter_nacos_model.jpg
new file mode 100644
index 0000000..b6d1011
Binary files /dev/null and b/img/configcenter_nacos_model.jpg differ
diff --git a/img/configcenter_zk_model.jpg b/img/configcenter_zk_model.jpg
new file mode 100644
index 0000000..33a1b55
Binary files /dev/null and b/img/configcenter_zk_model.jpg differ
diff --git a/img/configcenter_zk_properties.jpg b/img/configcenter_zk_properties.jpg
new file mode 100644
index 0000000..0f95ca8
Binary files /dev/null and b/img/configcenter_zk_properties.jpg differ
diff --git a/img/configcenter_zk_rule.jpg b/img/configcenter_zk_rule.jpg
new file mode 100644
index 0000000..f39da96
Binary files /dev/null and b/img/configcenter_zk_rule.jpg differ
diff --git a/img/configcenter_zk_singleitem.jpg b/img/configcenter_zk_singleitem.jpg
new file mode 100644
index 0000000..641ffee
Binary files /dev/null and b/img/configcenter_zk_singleitem.jpg differ