Skip to content

Commit

Permalink
Merge 467ef72 into 7048473
Browse files Browse the repository at this point in the history
  • Loading branch information
kimmking committed Mar 25, 2020
2 parents 7048473 + 467ef72 commit 9421f14
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 99 deletions.
2 changes: 1 addition & 1 deletion docs/document/content/features/orchestration/_index.cn.md
Expand Up @@ -7,4 +7,4 @@ chapter = true

## 导览

提供注册中心、配置动态化、数据库熔断禁用、调用链路等治理能力。
编排治理模块提供配置中心/注册中心(以及规划中的元数据中心)、配置动态化、数据库熔断禁用、调用链路等治理能力。
2 changes: 1 addition & 1 deletion docs/document/content/features/orchestration/_index.en.md
Expand Up @@ -7,4 +7,4 @@ chapter = true

## Navigation

Provide orchestration of registry center, dynamic configuration, database & application disabling, and APM.
Provide orchestration of config/registry center(and metadata center in plan), dynamic configuration, database & application disabling, and APM.
@@ -1,13 +1,15 @@
+++
pre = "<b>3.3.2. </b>"
toc = true
title = "编排治理"
title = "注册中心"
weight = 2
+++

## 实现动机

通过注册中心,提供熔断数据库访问程序对数据库的访问和禁用从库的访问的能力。治理仍然有大量未完成的功能。
- 相对于配置中心管理配置数据,注册中心存放运行时的动态/临时状态数据,比如可用的proxy的实例,需要禁用或熔断的datasource实例。

- 通过注册中心,可以提供熔断数据库访问程序对数据库的访问和禁用从库的访问的编排治理能力。治理仍然有大量未完成的功能(比如流控等)。

## 注册中心数据结构

Expand Down
@@ -1,13 +1,15 @@
+++
pre = "<b>3.3.2. </b>"
toc = true
title = "Orchestration"
title = "Registry Center"
weight = 2
+++

## Motivation

Registry center can disable the access to slave database and the access of application. Orchestration still has many functions to be developed.
- As config center manage configuration data, registry center hold all ephemeral status data dynamically generated in runtime(such as available proxy instances, disabled datasource instances etc).

- Registry center can disable the access to slave database and the access of application. Orchestration still has many functions(such as flow control) to be developed.

## Data Structure in Registry Center

Expand Down Expand Up @@ -66,4 +68,3 @@ Zookeeper command is as follow:
```
[zk: localhost:2181(CONNECTED) 0] set /your_zk_namespace/your_app_name/state/datasources/your_slave_datasource_name DISABLED
```

@@ -0,0 +1,38 @@
+++
pre = "<b>3.3.3. </b>"
toc = true
title = "支持的配置中心/注册中心"
weight = 3
+++

## SPI

[Service Provider Interface (SPI)](https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html)是一种为了被第三方实现或扩展的API。它可以用于实现框架扩展或组件替换。

ShardingSphere在数据库治理模块使用SPI方式载入数据到配置中心/注册中心,进行实例熔断和数据库禁用。
目前,ShardingSphere内部支持Zookeeper和etcd这种常用的配置中心/注册中心。
此外,您可以使用其他第三方配置中心/注册中心,并通过SPI的方式注入到ShardingSphere,从而使用该配置中心/注册中心,实现数据库治理功能。

## Zookeeper

ShardingSphere官方使用[Apache Curator](http://curator.apache.org/)作为Zookeeper的实现方案(支持配置中心和注册中心)。
请使用Zookeeper 3.4.6及其以上版本,详情请参见[官方网站](https://zookeeper.apache.org/)

## Etcd

ShardingSphere官方使用[io.etcd/jetcd](https://github.com/etcd-io/jetcd)作为Etcd的实现方案(支持配置中心和注册中心)。
请使用Etcd v3以上版本,详情请参见[官方网站](https://etcd.io/)

## Apollo

ShardingSphere官方使用[Apollo Client](https://github.com/ctripcorp/apollo)作为Apollo的实现方案(支持配置中心)。
请使用Apollo Client 1.5.0及其以上版本,详情请参见[官方网站](https://github.com/ctripcorp/apollo)

## Nacos

ShardingSphere官方使用[Nacos Client](https://nacos.io/zh-cn/docs/sdk.html)作为Nacos的实现方案(支持配置中心)。
请使用Nacos Client 1.0.0及其以上版本,详情请参见[官方网站](https://nacos.io/zh-cn/docs/sdk.html)

## 其他

使用SPI方式自行实现相关逻辑编码。
@@ -0,0 +1,33 @@
+++
pre = "<b>3.3.3. </b>"
toc = true
title = "Available Config Center/Registry Center"
weight = 3
+++

## SPI

[Service Provider Interface (SPI)](https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html) is a kind of API that aims to be implemented or extended by the third party.
It can be used to realize framework extension or component replacement.

ShardingSphere uses SPI to load data to the config center/registry center and disable instances and databases. Currently, ShardingSphere supports frequently used registry centers, Zookeeper and Etcd. In addition, by injecting them to ShardingSphere with SPI, users can use other third-party config/registry centers to enable databases orchestration.

## Zookeeper

ShardingSphere adopts [Apache Curator](http://curator.apache.org/) to enable Zookeeper(support config center&registry center). Please use Zookeeper 3.4.6 and above, see the [official website](https://zookeeper.apache.org/) for details.

## Etcd

ShardingSphere adopts [io.etcd/jetcd](https://github.com/etcd-io/jetcd) to enable Etcd(support config center&registry center). Please use Etcd v3 and above, see the [official website](https://etcd.io/) for details.

## Apollo

ShardingSphere adopts [Apollo Client](https://github.com/ctripcorp/apollo) to enable Apollo(support config center). Please use Apollo Client 1.5.0 and above, see the [official website](https://github.com/ctripcorp/apollo) for details.

## Nacos

ShardingSphere adopts [Nacos Client](https://nacos.io/en-us/docs/sdk.html) to enable Nacos(support config center). Please use Nacos Client 1.0.0 and above, see the [official website](https://nacos.io/en-us/docs/sdk.html) for details.

## Others

Use SPI to realize relevant logic coding.

This file was deleted.

This file was deleted.

Expand Up @@ -190,14 +190,22 @@ weight = 1
// OrchestrationShardingDataSourceFactory 可替换成 OrchestrationMasterSlaveDataSourceFactory 或 OrchestrationEncryptDataSourceFactory
return OrchestrationShardingDataSourceFactory.createDataSource(
createDataSourceMap(), createShardingRuleConfig(), new HashMap<String, Object>(), new Properties(),
new OrchestrationConfiguration("orchestration-sharding-data-source", getRegistryCenterConfiguration(), false));
new OrchestrationConfiguration(createCenterConfigurationMap()));
}

private RegistryCenterConfiguration getRegistryCenterConfiguration() {
RegistryCenterConfiguration regConfig = new RegistryCenterConfiguration("zookeeper");//注册中心的类型可以是Zookeeper,Etcd等
regConfig.setServerLists("localhost:2181");
regConfig.setNamespace("sharding-sphere-orchestration");
return regConfig;
private Map<String, CenterConfiguration> createCenterConfigurationMap() {
Map<String, CenterConfiguration> instanceConfigurationMap = new HashMap<String, CenterConfiguration>();
CenterConfiguration config = createCenterConfiguration();
instanceConfigurationMap.put("orchestration-sharding-data-source", config);
return instanceConfigurationMap;
}
private CenterConfiguration createCenterConfiguration() {
Properties properties = new Properties();
properties.setProperty("overwrite", overwrite);
CenterConfiguration result = new CenterConfiguration("zookeeper", properties);
result.setServerLists("localhost:2181");
result.setNamespace("sharding-sphere-orchestration");
result.setOrchestrationType("registry_center,config_center");
return result;
}
```

Expand Down Expand Up @@ -343,6 +351,7 @@ ShardingStrategyConfiguration的实现类,用于配置不分片的策略。
| max.connections.size.per.query (?)| int | 每个物理数据库为每次查询分配的最大连接数量。默认值: 1 |
| check.table.metadata.enabled (?) | boolean | 是否在启动时检查分表元数据一致性,默认值: false |
| query.with.cipher.column (?) | boolean | 当存在明文列时,是否使用密文列查询,默认值: true |
| allow.range.query.with.inline.sharding (?) | boolean | 当使用inline分表策略时,是否允许范围查询,默认值: false |

### 读写分离

Expand Down Expand Up @@ -445,20 +454,58 @@ ShardingStrategyConfiguration的实现类,用于配置不分片的策略。

| *名称* | *数据类型* | *说明* |
| --------------- | --------------------------- | ---------------------------------------------------------- |
| name | String | 治理实例名称 |
| overwrite | boolean | 本地配置是否覆盖注册中心配置,如果可覆盖,每次启动都以本地配置为准 |
| regCenterConfig | RegistryCenterConfiguration | 注册中心配置 |
| instanceConfigurationMap | Map\<String, CenterConfiguration\> | 配置中心和注册中心的配置map,key为名称,value为配置或注册中心 |

#### RegistryCenterConfiguration
#### CenterConfiguration

用于配置注册中心
用于配置配置中心或注册中心

| *名称* | *数据类型* | *说明* |
| --------------------------------- | ---------- | ----------------------------------------------------------------------------------- |
| serverLists | String | 连接注册中心服务器的列表,包括IP地址和端口号,多个地址用逗号分隔。如: host1:2181,host2:2181 |
| namespace (?) | String | 注册中心的命名空间 |
| type | String | 配置中心或注册中心的实例类型,例如zookeeper或etcd、apollo、nacos |
| properties | String | 配置本实例需要的其他参数,例如zookeeper的连接参数等,具体参考properties配置 |
| orchestrationType | String | 配置中心或注册中心的类型,例如config-center或registry-center,如果都是,可以"setOrchestrationType("registry_center,config_center");" |
| serverLists | String | 连接配置中心或注册中心服务器的列表,包括IP地址和端口号,多个地址用逗号分隔。如: host1:2181,host2:2181 |
| namespace (?) | String | 配置中心或注册中心的命名空间 |

其中properties的通用配置如下:

| *名称* | *数据类型* | *说明* |
| --------------- | --------------------------- | ---------------------------------------------------------- |
| overwrite | boolean | 本地配置是否覆盖注册中心配置,如果可覆盖,每次启动都以本地配置为准 |

如果采用了zookeeper作为配置中心或(和)注册中心,那么properties还可以配置:

| *名称* | *数据类型* | *说明* |
| --------------- | --------------------------- | ---------------------------------------------------------- |
| digest (?) | String | 连接注册中心的权限令牌。缺省为不需要权限验证 |
| operationTimeoutMilliseconds (?) | int | 操作超时的毫秒数,默认500毫秒 |
| maxRetries (?) | int | 连接失败后的最大重试次数,默认3次 |
| retryIntervalMilliseconds (?) | int | 重试间隔毫秒数,默认500毫秒 |
| timeToLiveSeconds (?) | int | 临时节点存活秒数,默认60秒 |

如果采用了etcd作为配置中心或(和)注册中心,那么properties还可以配置:

| *名称* | *数据类型* | *说明* |
| --------------- | --------------------------- | ---------------------------------------------------------- |
| timeToLiveSeconds (?) | long | TTL时间,单位为秒,默认30秒 |

如果采用了apollo作为配置中心,那么properties还可以配置:

| *名称* | *数据类型* | *说明* |
| --------------- | --------------------------- | ---------------------------------------------------------- |
| appId (?) | String | apollo appId,默认值为"APOLLO_SHARDINGSPHERE" |
| env (?) | String | apollo env,默认值为"DEV" |
| clusterName (?) | String | apollo clusterName,默认值为"default" |
| administrator (?) | String | apollo administrator,默认值为"" |
| token (?) | String | apollo token,默认值为"" |
| portalUrl (?) | String | apollo portalUrl,默认值为"" |
| connectTimeout (?) | int | apollo connectTimeout,默认值为1000毫秒 |
| readTimeout (?) | int | apollo readTimeout,默认值为5000毫秒 |

如果采用了nacos作为配置中心,那么properties还可以配置:

| *名称* | *数据类型* | *说明* |
| --------------- | --------------------------- | ---------------------------------------------------------- |
| group (?) | String | nacos group配置,默认值为"SHARDING_SPHERE_DEFAULT_GROUP" |
| timeout (?) | long | nacos 获取数据超时时间,单位为毫秒,默认值为3000毫秒 |

0 comments on commit 9421f14

Please sign in to comment.