You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "chickenlj (GitHub)" <gi...@apache.org> on 2018/12/07 09:38:15 UTC

[GitHub] [incubator-dubbo] chickenlj opened issue #2915: [2.7.0-development docs] Dynamic Configuration.

## 覆盖规则什么

此功能目的是运行期修改RPC相关参数,如timeout、loadbalance、threadpool等,Dubbo支持动态下发[配置规则](http://dubbo.apache.org/zh-cn/docs/user/demos/config-rule.html)

## 存在的问题

- 以override协议的UR形式下发;override://10.20.153.10/com.foo.BarService?category=configurators&dynamic=false&disbaled=true
- 以服务为粒度,无法满足全局变更某个应用的配置的需求
- 允许配置多条规则,导致具体哪条生效无法跟踪
- 之前版本的配置格式设计存在问题,是bug重灾区,甚至连要怎么配置我们框架开发者也搞不明白
- 提到多次的,和注册中心绑定在一起

## 解决方法

![override uml](https://user-images.githubusercontent.com/18097545/49639755-bff59e80-fa46-11e8-8b7a-1a9ce1c62d5c.jpg)


这里画出了覆盖规则实现的完整类图,只有`ConfigurationListener`及红色的继承关系是2.7.0版本中新增的,它是动态配置的回调接口。所以,RegistryProtocol、RegistryDirectory实现了双向读取和监听:

- 注册中心的配置变更,即override://配置,兼容2.6及以前版本
- 配置中心的配置变更,即新增YAML格式配置



以下新增的YAML配置格式:

```yaml
---
apiVersion: v2.7
scope: application/service
key: governance-appoverride-provider/group+service+version
enabled: true
configs:
- addresses: ["0.0.0.0"] # must not contain port when works on consumer side
  providerAddresses: ["1.1.1.1:20880", "2.2.2.2:20881"] # must contain port
  side: consumer
  applications/services: []
  parameters:
    timeout: 1000
    cluster: failfase
    loadbalance: random
- addresses: ["0.0.0.0:20880"] # must contain port when works on provider side, specify multiple addresses if you want to apply to multiple ports.
  side: provider
  applications/services: []
  parameters:
    threadpool: fixed
    threads: 200
    iothreads: 4
    dispatcher: all
    queues: 0
    weight: 200
...
```

配置被接收到是如何生效的那?其实还是走的2.6之前的老的URL覆盖流程,这点从类图中也可以看出来,我们的配置还是经由OverrideConfigurator覆盖URL实现。所以,2.7.0中新增了一个从YAML -> URL的解析转换流程。

### 工作流程或时序图

为了更详细的了解工作流程,请看以下两个时序图

Provider端,export与reexport

![override provider](https://user-images.githubusercontent.com/18097545/49639764-c71cac80-fa46-11e8-9b92-b65810e1e21a.jpg)

Consumer端
![override consumer](https://user-images.githubusercontent.com/18097545/49639780-d00d7e00-fa46-11e8-946b-c90a778ab429.jpg)

### 不同粒度的规则
![overridegranularity](https://user-images.githubusercontent.com/18097545/49639791-d6035f00-fa46-11e8-85b5-a10f57a58d06.jpg)


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2915 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] chickenlj closed issue #2915: [2.7.0-development docs] Dynamic Configuration.

Posted by "chickenlj (GitHub)" <gi...@apache.org>.
[ issue closed by chickenlj ]

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2915 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org