Update user-manual/configuration/java-api (#5895)
* update index of configuration
* update index of configuration
* update java config
* update java config
* update java config
* update java config
* update sharding root java config
* update table java config
* update Inline Sharding Algorithm java config
* update Modulo Sharding Algorithm java config
* update Sharding Algorithm java config
* update Sharding Algorithm java config
* update master-slave Algorithm java config
* update encrypt Algorithm java config
* update index
* update replica
* update shadow
* update governance
* remove config-java
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.cn.md
index 493d837..32246e5 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.cn.md
@@ -5,10 +5,9 @@
chapter = true
+++
-## 概述
+配置是 ShardingSphere-JDBC 中唯一与应用开发者交互的模块,通过它可以快速清晰的理解 ShardingSphere-JDBC 所提供的功能。
-配置是整个ShardingSphere-JDBC的核心,是ShardingSphere-JDBC中唯一与应用开发者打交道的模块。配置模块也是ShardingSphere-JDBC的门户,通过它可以快速清晰的理解ShardingSphere-JDBC所提供的功能。
+本章节是 ShardingSphere-JDBC 的配置参考手册,需要时可当做字典查阅。
-本部分是ShardingSphere-JDBC的配置参考手册,需要时可当做字典查阅。
-
-ShardingSphere-JDBC提供了4种配置方式,用于不同的使用场景。通过配置,应用开发者可以灵活的使用分库分表、读写分离以及分库分表 + 读写分离共用。
+ShardingSphere-JDBC 提供了 4 种配置方式,用于不同的使用场景。
+通过配置,应用开发者可以灵活的使用数据分片、读写分离、多副本、数据加密、影子库等功能,并且能够叠加使用。
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.en.md
index c92a181..42a45f4 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/_index.en.md
@@ -1,16 +1,14 @@
+++
pre = "<b>4.1.2. </b>"
-title = "Configuration manual"
+title = "Configuration Manual"
weight = 2
chapter = true
-
+++
-## Introduction
+Configuration is the only module in ShardingSphere-JDBC that interacts with application developers,
+through which developers can quickly and clearly understand the functions provided by ShardingSphere-JDBC.
-As the core of ShardingSphere-JDBC, configuration is the only module in ShardingSphere-JDBC that has something to do with application developers. Configuration module is also the portal of ShardingSphere-JDBC, through which users can fast and clearly understand the functions provided by ShardingSphere-JDBC.
+This chapter is a configuration manual for ShardingSphere-JDBC, which can also be referred to as a dictionary if necessary.
-This part is a configuration manual for ShardingSphere-JDBC, which can also be referred to as a dictionary if necessary.
-
-ShardingSphere-JDBC has provided 4 kinds of configuration methods for different situations. By configuration, application developers can flexibly use sharding databases with sharding tables, read-write split or the combination of both.
-
+ShardingSphere-JDBC has provided 4 kinds of configuration methods for different situations.
+By configuration, application developers can flexibly use data sharding, read-write splitting, multi replica, data encryption, shadow database or the combination of them.
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-java.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-java.cn.md
deleted file mode 100644
index ae3cb59..0000000
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-java.cn.md
+++ /dev/null
@@ -1,508 +0,0 @@
-+++
-title = "Java 配置"
-weight = 1
-+++
-
-## 配置示例
-
-### 数据分片
-
-```java
- DataSource getShardingDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
- shardingRuleConfig.getBroadcastTables().add("t_config");
- shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("user_id", "ds${user_id % 2}"));
- shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new ModuloShardingTableAlgorithm()));
- return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig, new Properties());
- }
-
- private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
- KeyGeneratorConfiguration result = new KeyGeneratorConfiguration("SNOWFLAKE", "order_id");
- return result;
- }
-
- TableRuleConfiguration getOrderTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order", "ds${0..1}.t_order${0..1}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
- return result;
- }
-
- TableRuleConfiguration getOrderItemTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "ds${0..1}.t_order_item${0..1}");
- return result;
- }
-
- Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds0", DataSourceUtil.createDataSource("ds0"));
- result.put("ds1", DataSourceUtil.createDataSource("ds1"));
- return result;
- }
-```
-
-### 读写分离
-
-```java
- DataSource getMasterSlaveDataSource() throws SQLException {
- MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration("ds_master_slave", "ds_master", Arrays.asList("ds_slave0", "ds_slave1"));
- return MasterSlaveDataSourceFactory.createDataSource(createDataSourceMap(), masterSlaveRuleConfig, new Properties());
- }
-
- Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds_master", DataSourceUtil.createDataSource("ds_master"));
- result.put("ds_slave0", DataSourceUtil.createDataSource("ds_slave0"));
- result.put("ds_slave1", DataSourceUtil.createDataSource("ds_slave1"));
- return result;
- }
-```
-
-### 数据加密
-
-```java
- DataSource getEncryptDataSource() throws SQLException {
- return EncryptDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), getEncryptRuleConfiguration(), new Properties());
- }
-
- private static EncryptRuleConfiguration getEncryptRuleConfiguration() {
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456");
- EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("AES", props);
- EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration("plain_pwd", "cipher_pwd", "", "aes");
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration(Collections.singletonMap("pwd", columnConfig));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration();
- encryptRuleConfig.getEncryptors().put("aes", encryptorConfig);
- encryptRuleConfig.getTables().put("t_encrypt", tableConfig);
- return encryptRuleConfig;
- }
-```
-
-### 数据分片 + 读写分离
-
-```java
- DataSource getDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
- shardingRuleConfig.getBroadcastTables().add("t_config");
- shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new StandardShardingStrategyConfiguration("user_id", new PreciseModuloShardingDatabaseAlgorithm()));
- shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new PreciseModuloShardingTableAlgorithm()));
- shardingRuleConfig.setMasterSlaveRuleConfigs(getMasterSlaveRuleConfigurations());
- return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig, new Properties());
- }
-
- private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
- KeyGeneratorConfiguration result = new KeyGeneratorConfiguration("SNOWFLAKE", "order_id");
- return result;
- }
-
- TableRuleConfiguration getOrderTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order", "ds_${0..1}.t_order_${[0, 1]}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
- return result;
- }
-
- TableRuleConfiguration getOrderItemTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "ds_${0..1}.t_order_item_${[0, 1]}");
- return result;
- }
-
- List<MasterSlaveRuleConfiguration> getMasterSlaveRuleConfigurations() {
- MasterSlaveRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveRuleConfiguration("ds_0", "demo_ds_master_0", Arrays.asList("demo_ds_master_0_slave_0", "demo_ds_master_0_slave_1"));
- MasterSlaveRuleConfiguration masterSlaveRuleConfig2 = new MasterSlaveRuleConfiguration("ds_1", "demo_ds_master_1", Arrays.asList("demo_ds_master_1_slave_0", "demo_ds_master_1_slave_1"));
- return Lists.newArrayList(masterSlaveRuleConfig1, masterSlaveRuleConfig2);
- }
-
- Map<String, DataSource> createDataSourceMap() {
- final Map<String, DataSource> result = new HashMap<>();
- result.put("demo_ds_master_0", DataSourceUtil.createDataSource("demo_ds_master_0"));
- result.put("demo_ds_master_0_slave_0", DataSourceUtil.createDataSource("demo_ds_master_0_slave_0"));
- result.put("demo_ds_master_0_slave_1", DataSourceUtil.createDataSource("demo_ds_master_0_slave_1"));
- result.put("demo_ds_master_1", DataSourceUtil.createDataSource("demo_ds_master_1"));
- result.put("demo_ds_master_1_slave_0", DataSourceUtil.createDataSource("demo_ds_master_1_slave_0"));
- result.put("demo_ds_master_1_slave_1", DataSourceUtil.createDataSource("demo_ds_master_1_slave_1"));
- return result;
- }
-```
-
-### 数据分片 + 数据加密
-
-```java
- public DataSource getDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderEncryptTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
- shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("user_id", "demo_ds_${user_id % 2}"));
- shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new PreciseModuloShardingTableAlgorithm()));
- shardingRuleConfig.setEncryptRuleConfig(getEncryptRuleConfiguration());
- return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig, new Properties());
- }
-
- private static TableRuleConfiguration getOrderTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order", "demo_ds_${0..1}.t_order_${[0, 1]}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
- return result;
- }
-
- private static TableRuleConfiguration getOrderItemTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "demo_ds_${0..1}.t_order_item_${[0, 1]}");
- result.setEncryptorConfig(new EncryptorConfiguration("MD5", "status", new Properties()));
- return result;
- }
-
- private static EncryptRuleConfiguration getEncryptRuleConfiguration() {
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456");
- EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("AES", props);
- EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration("plain_order", "cipher_order", "", "aes");
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration(Collections.singletonMap("order_id", columnConfig));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration();
- encryptRuleConfig.getEncryptors().put("aes", encryptorConfig);
- encryptRuleConfig.getTables().put("t_order", tableConfig);
- return encryptRuleConfig;
- }
-
- private static Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("demo_ds_0", DataSourceUtil.createDataSource("demo_ds_0"));
- result.put("demo_ds_1", DataSourceUtil.createDataSource("demo_ds_1"));
- return result;
- }
-
- private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
- return new KeyGeneratorConfiguration("SNOWFLAKE", "order_id", new Properties());
- }
-```
-
-### 治理
-
-```java
- DataSource getDataSource() throws SQLException {
- // OrchestrationShardingDataSourceFactory 可替换成 OrchestrationMasterSlaveDataSourceFactory 或 OrchestrationEncryptDataSourceFactory
- return OrchestrationShardingDataSourceFactory.createDataSource(
- createDataSourceMap(), createShardingRuleConfig(), new HashMap<String, Object>(), new Properties(),
- new OrchestrationConfiguration(createCenterConfigurationMap()));
- }
- private Map<String, CenterConfiguration> createCenterConfigurationMap() {
- Map<String, CenterConfiguration> instanceConfigurationMap = new HashMap<String, CenterConfiguration>();
- CenterConfiguration config = createCenterConfiguration();
- instanceConfigurationMap.put("orchestration-shardingsphere-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("shardingsphere-orchestration");
- result.setOrchestrationType("registry_center,config_center,metadata_center");
- return result;
- }
-```
-
-## 配置项说明
-
-### 数据分片
-
-#### ShardingDataSourceFactory
-
-数据分片的数据源创建工厂。
-
-| *名称* | *数据类型* | *说明* |
-| ------------------ | ------------------------ | -------------- |
-| dataSourceMap | Map\<String, DataSource\> | 数据源配置 |
-| shardingRuleConfig | ShardingRuleConfiguration | 数据分片配置规则 |
-| props (?) | Properties | 属性配置 |
-
-#### ShardingRuleConfiguration
-
-分片规则配置对象。
-
-| *名称* | *数据类型* | *说明*
-| ----------------------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------- |
-| tableRuleConfigs | Collection\<TableRuleConfiguration\> | 分片规则列表 |
-| bindingTableGroups (?) | Collection\<String\> | 绑定表规则列表 |
-| broadcastTables (?) | Collection\<String\> | 广播表规则列表 |
-| defaultDataSourceName (?) | String | 未配置分片规则的表将通过默认数据源定位 |
-| defaultDatabaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | 默认分库策略 |
-| defaultTableShardingStrategyConfig (?) | ShardingStrategyConfiguration | 默认分表策略 |
-| defaultKeyGeneratorConfig (?) | KeyGeneratorConfiguration | 默认自增列值生成器配置,缺省将使用org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator |
-| masterSlaveRuleConfigs (?) | Collection\<MasterSlaveRuleConfiguration\> | 读写分离规则,缺省表示不使用读写分离 |
-
-#### TableRuleConfiguration
-
-表分片规则配置对象。
-
-| *名称* | *数据类型* | *说明* |
-| ---------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| logicTable | String | 逻辑表名称 |
-| actualDataNodes (?) | String | 由数据源名 + 表名组成,以小数点分隔。多个表以逗号分隔,支持inline表达式。缺省表示使用已知数据源与逻辑表名称生成数据节点,用于广播表(即每个库中都需要一个同样的表用于关联查询,多为字典表)或只分库不分表且所有库的表结构完全一致的情况 |
-| databaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | 分库策略,缺省表示使用默认分库策略 |
-| tableShardingStrategyConfig (?) | ShardingStrategyConfiguration | 分表策略,缺省表示使用默认分表策略 |
-| keyGeneratorConfig (?) | KeyGeneratorConfiguration | 自增列值生成器配置,缺省表示使用默认自增主键生成器 |
-| encryptorConfiguration (?) | EncryptorConfiguration | 加解密生成器配置 |
-
-#### StandardShardingStrategyConfiguration
-
-ShardingStrategyConfiguration的实现类,用于单分片键的标准分片场景。
-
-| *名称* | *数据类型* | *说明* |
-| -------------------------- | ------------------------ | ----------------------- |
-| shardingColumn | String | 分片列名称 |
-| preciseShardingAlgorithm | PreciseShardingAlgorithm | 精确分片算法,用于=和IN |
-| rangeShardingAlgorithm (?) | RangeShardingAlgorithm | 范围分片算法,用于BETWEEN |
-
-#### ComplexShardingStrategyConfiguration
-
-ShardingStrategyConfiguration的实现类,用于多分片键的复合分片场景。
-
-| *名称* | *数据类型* | *说明* |
-| ----------------- | ---------------------------- | ------------------------ |
-| shardingColumns | String | 分片列名称,多个列以逗号分隔 |
-| shardingAlgorithm | ComplexKeysShardingAlgorithm | 复合分片算法 |
-
-#### InlineShardingStrategyConfiguration
-
-ShardingStrategyConfiguration的实现类,用于配置行表达式分片策略。
-
-| *名称* | *数据类型* | *说明* |
-| ------------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
-| shardingColumn | String | 分片列名称 |
-| algorithmExpression | String | 分片算法行表达式,需符合groovy语法,详情请参考[行表达式](/cn/features/sharding/other-features/inline-expression) |
-
-#### HintShardingStrategyConfiguration
-
-ShardingStrategyConfiguration的实现类,用于配置Hint方式分片策略。
-
-| *名称* | *数据类型* | *说明* |
-| ----------------- | --------------------- | ----------- |
-| shardingAlgorithm | HintShardingAlgorithm | Hint分片算法 |
-
-#### NoneShardingStrategyConfiguration
-
-ShardingStrategyConfiguration的实现类,用于配置不分片的策略。
-
-#### KeyGeneratorConfiguration
-
-| *名称* | *数据类型* | *说明* |
-| ----------------- | ---------------------------- | ------------------------------------------------------------------------------ |
-| column | String | 自增列名称 |
-| type | String | 自增列值生成器类型,可自定义或选择内置类型:SNOWFLAKE/UUID |
-| props | Properties | 自增列值生成器的相关属性配置 |
-
-#### Properties
-
-属性配置项,可以为以下自增列值生成器的属性。
-
-##### SNOWFLAKE
-
-| *名称* | *数据类型* | *说明* |
-| --------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------- |
-| worker.id (?) | long | 工作机器唯一id,默认为0 |
-| max.tolerate.time.difference.milliseconds (?) | long | 最大容忍时钟回退时间,单位:毫秒。默认为10毫秒 |
-| max.vibration.offset (?) | int | 最大抖动上限值,范围[0, 4096),默认为1。注:若使用此算法生成值作分片值,建议配置此属性。此算法在不同毫秒内所生成的key取模2^n (2^n一般为分库或分表数) 之后结果总为0或1。为防止上述分片问题,建议将此属性值配置为(2^n)-1 |
-
-#### EncryptRuleConfiguration
-
-| *名称* |*数据类型* | *说明* |
-| ------------------- | ------------------------------------------- | ------------------------------------------------------------------------------ |
-| encryptors | Map<String, EncryptorRuleConfiguration> | 加解密器配置列表,可自定义或选择内置类型:MD5/AES |
-| tables | Map<String, EncryptTableRuleConfiguration> | 加密表配置列表 |
-
-#### EncryptorRuleConfiguration
-
-| *名称* |*数据类型* | *说明* |
-| ------------------- | ---------------------------- | ------------------------------------------------------------------------------ |
-| type | String | 加解密器类型,可自定义或选择内置类型:MD5/AES |
-| properties | Properties | 属性配置, 注意:使用AES加密器,需要配置AES加密器的KEY属性:aes.key.value |
-
-#### EncryptTableRuleConfiguration
-
-| *名称* |*数据类型* | *说明* |
-| ------------------- | -------------------------------------------- | --------------------------------- |
-| tables | Map<String, EncryptColumnRuleConfiguration> | 加密列配置列表 |
-
-#### EncryptColumnRuleConfiguration
-
-| *名称* |*数据类型* | *说明* |
-| ------------------- | ---------------------------- | ------------------------------------------------------------------------------ |
-| plainColumn | String | 存储明文的字段 |
-| cipherColumn | String | 存储密文的字段 |
-| assistedQueryColumn| String | 辅助查询字段,针对ShardingQueryAssistedEncryptor类型的加解密器进行辅助查询 |
-| encryptor | String | 加解密器名字 |
-
-#### Properties
-
-属性配置项,可以为以下属性。
-
-| *名称* | *数据类型* | *说明* |
-| ----------------------------------| --------- | -------------------------------------------------|
-| sql.show (?) | boolean | 是否开启SQL显示,默认值: false |
-| executor.size (?) | int | 工作线程数量,默认值: CPU核数 |
-| 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 |
-
-### 读写分离
-
-#### MasterSlaveDataSourceFactory
-
-读写分离的数据源创建工厂。
-
-| *名称* | *数据类型* | *说明* |
-| --------------------- | ---------------------------- | ------------------ |
-| dataSourceMap | Map\<String, DataSource\> | 数据源与其名称的映射 |
-| masterSlaveRuleConfig | MasterSlaveRuleConfiguration | 读写分离规则 |
-| props (?) | Properties | 属性配置 |
-
-#### MasterSlaveRuleConfiguration
-
-读写分离规则配置对象。
-
-| *名称* | *数据类型* | *说明* |
-| ------------------------ | ------------------------------- | ---------------- |
-| name | String | 读写分离数据源名称 |
-| masterDataSourceName | String | 主库数据源名称 |
-| slaveDataSourceNames | Collection\<String\> | 从库数据源名称列表 |
-| loadBalanceAlgorithm (?) | MasterSlaveLoadBalanceAlgorithm | 从库负载均衡算法 |
-
-#### Properties
-
-属性配置项,可以为以下属性。
-
-| *名称* | *数据类型* | *说明* |
-| ---------------------------------- | --------- | ------------------------------------------------- |
-| sql.show (?) | boolean | 是否打印SQL解析和改写日志,默认值: false |
-| executor.size (?) | int | 用于SQL执行的工作线程数量,为零则表示无限制。默认值: 0 |
-| max.connections.size.per.query (?) | int | 每个物理数据库为每次查询分配的最大连接数量。默认值: 1 |
-| check.table.metadata.enabled (?) | boolean | 是否在启动时检查分表元数据一致性,默认值: false |
-
-### 数据加密
-
-#### EncryptDataSourceFactory
-
-| *名称* | *数据类型* | *说明* |
-| --------------------- | ---------------------------- | ------------------ |
-| dataSource | DataSource | 数据源,任意连接池 |
-| encryptRuleConfig | EncryptRuleConfiguration | 数据加密规则 |
-| props (?) | Properties | 属性配置 |
-
-#### EncryptRuleConfiguration
-
-| *名称* |*数据类型* | *说明* |
-| ------------------- | ------------------------------------------- | ------------------------------------------------------------------------------ |
-| encryptors | Map<String, EncryptorRuleConfiguration> | 加解密器配置列表,可自定义或选择内置类型:MD5/AES |
-| tables | Map<String, EncryptTableRuleConfiguration> | 加密表配置列表 |
-
-#### Properties
-
-属性配置项,可以为以下属性。
-
-| *名称* | *数据类型* | *说明* |
-| ----------------------------------| --------- | -------------------------------------------------|
-| sql.show (?) | boolean | 是否开启SQL显示,默认值: false |
-| query.with.cipher.column (?) | boolean | 当存在明文列时,是否使用密文列查询,默认值: true |
-
-### 治理
-
-#### OrchestrationShardingDataSourceFactory
-
-数据分片 + 治理的数据源工厂。
-
-| *名称* | *数据类型* | *说明* |
-| ------------------- | ------------------------- | --------------------------- |
-| dataSourceMap | Map\<String, DataSource\> | 同ShardingDataSourceFactory |
-| shardingRuleConfig | ShardingRuleConfiguration | 同ShardingDataSourceFactory |
-| props (?) | Properties | 同ShardingDataSourceFactory |
-| orchestrationConfig | OrchestrationConfiguration | 治理规则配置 |
-
-#### OrchestrationMasterSlaveDataSourceFactory
-
-读写分离 + 治理的数据源工厂。
-
-| *名称* | *数据类型* | *说明* |
-| --------------------- | ---------------------------- | ------------------------------ |
-| dataSourceMap | Map\<String, DataSource\> | 同MasterSlaveDataSourceFactory |
-| masterSlaveRuleConfig | MasterSlaveRuleConfiguration | 同MasterSlaveDataSourceFactory |
-| props (?) | Properties | 同ShardingDataSourceFactory |
-| orchestrationConfig | OrchestrationConfiguration | 治理规则配置 |
-
-#### OrchestrationEncryptDataSourceFactory
-
-数据加密 + 治理的数据源工厂。
-
-| *名称* | *数据类型* | *说明* |
-| --------------------- | ---------------------------- | ------------------------------ |
-| dataSource | DataSource | 同EncryptDataSourceFactory |
-| encryptRuleConfig | EncryptRuleConfiguration | 同EncryptDataSourceFactory |
-| props (?) | Properties | 同ShardingDataSourceFactory |
-| orchestrationConfig | OrchestrationConfiguration | 治理规则配置 |
-
-#### OrchestrationConfiguration
-
-治理规则配置对象。
-
-| *名称* | *数据类型* | *说明* |
-| --------------- | --------------------------- | ---------------------------------------------------------- |
-| instanceConfigurationMap | Map\<String, CenterConfiguration\> | 配置/注册/元数据中心的配置map,key为名称,value为配置/注册/元数据中心 |
-
-#### CenterConfiguration
-
-用于配置配置/注册/元数据中心。
-
-| *名称* | *数据类型* | *说明* |
-| --------------------------------- | ---------- | ----------------------------------------------------------------------------------- |
-| instanceType | String | 配置/注册/元数据中心的实例类型,例如zookeeper或etcd、apollo、nacos |
-| properties | String | 配置本实例需要的其他参数,例如zookeeper的连接参数等,具体参考properties配置 |
-| orchestrationType | String | 治理类型,例如config_center/registry_center/metadata_center,如果都是,可以"setOrchestrationType("registry_center,config_center,metadata_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毫秒 |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-java.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-java.en.md
deleted file mode 100644
index 7f12ce5..0000000
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-java.en.md
+++ /dev/null
@@ -1,491 +0,0 @@
-+++
-title = "Java Configuration"
-weight = 1
-+++
-
-## Configuration Instance
-
-### Data Sharding
-
-```java
- DataSource getShardingDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
- shardingRuleConfig.getBroadcastTables().add("t_config");
- shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("user_id", "ds${user_id % 2}"));
- shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new ModuloShardingTableAlgorithm()));
- return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig, new Properties());
- }
-
- private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
- KeyGeneratorConfiguration result = new KeyGeneratorConfiguration("SNOWFLAKE", "order_id");
- return result;
- }
-
- TableRuleConfiguration getOrderTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order", "ds${0..1}.t_order${0..1}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
- return result;
- }
-
- TableRuleConfiguration getOrderItemTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "ds${0..1}.t_order_item${0..1}");
- return result;
- }
-
- Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds0", DataSourceUtil.createDataSource("ds0"));
- result.put("ds1", DataSourceUtil.createDataSource("ds1"));
- return result;
- }
-```
-
-### Read-Write Split
-
-```java
- DataSource getMasterSlaveDataSource() throws SQLException {
- MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration("ds_master_slave", "ds_master", Arrays.asList("ds_slave0", "ds_slave1"));
- return MasterSlaveDataSourceFactory.createDataSource(createDataSourceMap(), masterSlaveRuleConfig, new Properties());
- }
-
- Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("ds_master", DataSourceUtil.createDataSource("ds_master"));
- result.put("ds_slave0", DataSourceUtil.createDataSource("ds_slave0"));
- result.put("ds_slave1", DataSourceUtil.createDataSource("ds_slave1"));
- return result;
- }
-```
-
-### data encryption
-
-```java
- DataSource getEncryptDataSource() throws SQLException {
- return EncryptDataSourceFactory.createDataSource(DataSourceUtil.createDataSource("demo_ds"), getEncryptRuleConfiguration(), new Properties());
- }
-
- private static EncryptRuleConfiguration getEncryptRuleConfiguration() {
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456");
- EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("AES", props);
- EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration("plain_pwd", "cipher_pwd", "", "aes");
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration(Collections.singletonMap("pwd", columnConfig));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration();
- encryptRuleConfig.getEncryptors().put("aes", encryptorConfig);
- encryptRuleConfig.getTables().put("t_encrypt", tableConfig);
- return encryptRuleConfig;
- }
-```
-
-### Data Sharding + Read-Write Split
-
-```java
- DataSource getDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
- shardingRuleConfig.getBroadcastTables().add("t_config");
- shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new StandardShardingStrategyConfiguration("user_id", new PreciseModuloShardingDatabaseAlgorithm()));
- shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new PreciseModuloShardingTableAlgorithm()));
- shardingRuleConfig.setMasterSlaveRuleConfigs(getMasterSlaveRuleConfigurations());
- return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig, new Properties());
- }
-
- private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
- KeyGeneratorConfiguration result = new KeyGeneratorConfiguration("SNOWFLAKE", "order_id");
- return result;
- }
-
- TableRuleConfiguration getOrderTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order", "ds_${0..1}.t_order_${[0, 1]}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
- return result;
- }
-
- TableRuleConfiguration getOrderItemTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "ds_${0..1}.t_order_item_${[0, 1]}");
- return result;
- }
-
- List<MasterSlaveRuleConfiguration> getMasterSlaveRuleConfigurations() {
- MasterSlaveRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveRuleConfiguration("ds_0", "demo_ds_master_0", Arrays.asList("demo_ds_master_0_slave_0", "demo_ds_master_0_slave_1"));
- MasterSlaveRuleConfiguration masterSlaveRuleConfig2 = new MasterSlaveRuleConfiguration("ds_1", "demo_ds_master_1", Arrays.asList("demo_ds_master_1_slave_0", "demo_ds_master_1_slave_1"));
- return Lists.newArrayList(masterSlaveRuleConfig1, masterSlaveRuleConfig2);
- }
-
- Map<String, DataSource> createDataSourceMap() {
- final Map<String, DataSource> result = new HashMap<>();
- result.put("demo_ds_master_0", DataSourceUtil.createDataSource("demo_ds_master_0"));
- result.put("demo_ds_master_0_slave_0", DataSourceUtil.createDataSource("demo_ds_master_0_slave_0"));
- result.put("demo_ds_master_0_slave_1", DataSourceUtil.createDataSource("demo_ds_master_0_slave_1"));
- result.put("demo_ds_master_1", DataSourceUtil.createDataSource("demo_ds_master_1"));
- result.put("demo_ds_master_1_slave_0", DataSourceUtil.createDataSource("demo_ds_master_1_slave_0"));
- result.put("demo_ds_master_1_slave_1", DataSourceUtil.createDataSource("demo_ds_master_1_slave_1"));
- return result;
- }
-```
-### Data Sharding + data encryption
-
-```java
- public DataSource getDataSource() throws SQLException {
- ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
- shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
- shardingRuleConfig.getTableRuleConfigs().add(getOrderEncryptTableRuleConfiguration());
- shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
- shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("user_id", "demo_ds_${user_id % 2}"));
- shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new PreciseModuloShardingTableAlgorithm()));
- shardingRuleConfig.setEncryptRuleConfig(getEncryptRuleConfiguration());
- return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig, new Properties());
- }
-
- private static TableRuleConfiguration getOrderTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order", "demo_ds_${0..1}.t_order_${[0, 1]}");
- result.setKeyGeneratorConfig(getKeyGeneratorConfiguration());
- return result;
- }
-
- private static TableRuleConfiguration getOrderItemTableRuleConfiguration() {
- TableRuleConfiguration result = new TableRuleConfiguration("t_order_item", "demo_ds_${0..1}.t_order_item_${[0, 1]}");
- result.setEncryptorConfig(new EncryptorConfiguration("MD5", "status", new Properties()));
- return result;
- }
-
- private static EncryptRuleConfiguration getEncryptRuleConfiguration() {
- Properties props = new Properties();
- props.setProperty("aes.key.value", "123456");
- EncryptorRuleConfiguration encryptorConfig = new EncryptorRuleConfiguration("AES", props);
- EncryptColumnRuleConfiguration columnConfig = new EncryptColumnRuleConfiguration("plain_order", "cipher_order", "", "aes");
- EncryptTableRuleConfiguration tableConfig = new EncryptTableRuleConfiguration(Collections.singletonMap("order_id", columnConfig));
- EncryptRuleConfiguration encryptRuleConfig = new EncryptRuleConfiguration();
- encryptRuleConfig.getEncryptors().put("aes", encryptorConfig);
- encryptRuleConfig.getTables().put("t_order", tableConfig);
- return encryptRuleConfig;
- }
-
- private static Map<String, DataSource> createDataSourceMap() {
- Map<String, DataSource> result = new HashMap<>();
- result.put("demo_ds_0", DataSourceUtil.createDataSource("demo_ds_0"));
- result.put("demo_ds_1", DataSourceUtil.createDataSource("demo_ds_1"));
- return result;
- }
-
- private static KeyGeneratorConfiguration getKeyGeneratorConfiguration() {
- return new KeyGeneratorConfiguration("SNOWFLAKE", "order_id", new Properties());
- }
-```
-
-### Orchestration
-
-```java
- DataSource getDataSource() throws SQLException {
- // OrchestrationShardingDataSourceFactory 可替换成 OrchestrationMasterSlaveDataSourceFactory 或 OrchestrationEncryptDataSourceFactory
- return OrchestrationShardingDataSourceFactory.createDataSource(
- createDataSourceMap(), createShardingRuleConfig(), new HashMap<String, Object>(), new Properties(),
- new OrchestrationConfiguration(createCenterConfigurationMap()));
- }
- private Map<String, CenterConfiguration> createCenterConfigurationMap() {
- Map<String, CenterConfiguration> instanceConfigurationMap = new HashMap<String, CenterConfiguration>();
- CenterConfiguration config = createCenterConfiguration();
- instanceConfigurationMap.put("orchestration-shardingsphere-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("shardingsphere-orchestration");
- result.setOrchestrationType("registry_center,config_center,metadata_center");
- return result;
- }
-```
-
-## Configuration Item Explanation
-
-### Data Sharding
-
-#### ShardingDataSourceFactory
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------ | ------------------------- | -------------------------------- |
-| dataSourceMap | Map\<String, DataSource\> | Data sources configuration |
-| shardingRuleConfig | ShardingRuleConfiguration | Data sharding configuration rule |
-| props (?) | Properties | Property configuration |
-
-#### ShardingRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ----------------------------------------- | ------------------------------------------ | ------------------------------------------------------------ |
-| tableRuleConfigs | Collection\<TableRuleConfiguration\> | Sharding rule list |
-| bindingTableGroups (?) | Collection\<String\> | Binding table rule list |
-| broadcastTables (?) | Collection\<String\> | Broadcast table rule list |
-| defaultDataSourceName (?) | String | Tables not configured with sharding rules will locate according to default data sources |
-| defaultDatabaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | Default database sharding strategy |
-| defaultTableShardingStrategyConfig (?) | ShardingStrategyConfiguration | Default table sharding strategy |
-| defaultKeyGeneratorConfig (?) | KeyGeneratorConfiguration | Default key generator configuration, use user-defined ones or built-in ones, e.g. SNOWFLAKE/UUID. Default key generator is `org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator` |
-| masterSlaveRuleConfigs (?) | Collection\<MasterSlaveRuleConfiguration\> | Read-write split rules, default indicates not using read-write split |
-
-#### TableRuleConfiguration
-
-| *Name* | *DataType* | *Description* |
-| ---------------------------------- | ----------------------------- | ------------------------------------------------------------ |
-| logicTable | String | Name of logic table |
-| actualDataNodes (?) | String | Describe data source names and actual tables, delimiter as point, multiple data nodes split by comma, support inline expression. Absent means sharding databases only. Example: ds${0..7}.tbl${0..7} |
-| databaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | Databases sharding strategy, use default databases sharding strategy if absent |
-| tableShardingStrategyConfig (?) | ShardingStrategyConfiguration | Tables sharding strategy, use default databases sharding strategy if absent |
-| keyGeneratorConfig (?) | KeyGeneratorConfiguration | Key generator configuration, use default key generator if absent |
-| encryptorConfiguration (?) | EncryptorConfiguration | Encrypt generator configuration |
-
-
-#### StandardShardingStrategyConfiguration
-
-Subclass of ShardingStrategyConfiguration.
-
-| *Name* | *DataType* | *Explanation* |
-| -------------------------- | ------------------------ | ----------------------------------------------- |
-| shardingColumn | String | Sharding column name |
-| preciseShardingAlgorithm | PreciseShardingAlgorithm | Precise sharding algorithm used in `=` and `IN` |
-| rangeShardingAlgorithm (?) | RangeShardingAlgorithm | Range sharding algorithm used in `BETWEEN` |
-
-#### ComplexShardingStrategyConfiguration
-
-The implementation class of `ShardingStrategyConfiguration`, used in complex sharding situations with multiple sharding keys.
-
-| *Name* | *DataType* | *Explanation* |
-| ----------------- | ---------------------------- | ----------------------------------------- |
-| shardingColumns | String | Sharding column name, separated by commas |
-| shardingAlgorithm | ComplexKeysShardingAlgorithm | Complex sharding algorithm |
-
-#### InlineShardingStrategyConfiguration
-
-The implementation class of `ShardingStrategyConfiguration`, used in sharding strategy of inline expression.
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | ---------- | ------------------------------------------------------------ |
-| shardingColumn | String | Sharding column name |
-| algorithmExpression | String | Inline expression of sharding strategies, should conform to groovy syntax; refer to [Inline expression](/en/features/sharding/other-features/inline-expression) for more details |
-
-#### HintShardingStrategyConfiguration
-
-The implementation class of `ShardingStrategyConfiguration`, used to configure hint sharding strategies.
-
-| *Name* | *DataType* | *Description* |
-| ----------------- | --------------------- | ----------------------- |
-| shardingAlgorithm | HintShardingAlgorithm | Hint sharding algorithm |
-
-#### NoneShardingStrategyConfiguration
-
-The implementation class of `ShardingStrategyConfiguration`, used to configure none-sharding strategies.
-
-#### KeyGeneratorConfiguration
-
-| *Name* | *DataType* | *Description* |
-| ------ | ---------- | ------------------------------------------------------------ |
-| column | String | Column name of key generator |
-| type | String | Type of key generator, use user-defined ones or built-in ones, e.g. SNOWFLAKE, UUID |
-| props | Properties | The Property configuration of key generators |
-
-#### Properties
-
-Property configuration that can include these properties of these key generators.
-
-##### SNOWFLAKE
-
-| *Name* | *DataType* | *Explanation* |
-| --------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| worker.id (?) | long | The unique id for working machine, the default value is `0` |
-| max.tolerate.time.difference.milliseconds (?) | long | The max tolerate time for different server's time difference in milliseconds, the default value is `10` |
-| max.vibration.offset (?) | int | The max upper limit value of vibrate number, range `[0, 4096)`, the default value is `1`. Notice: To use the generated value of this algorithm as sharding value, it is recommended to configure this property. The algorithm generates key mod `2^n` (`2^n` is usually the sharding amount of tables or databases) in different milliseconds and the result is always `0` or `1`. To prevent the above sharding problem, it is recommended to configure this property, its value is `(2^n)-1` |
-
-#### EncryptRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | ------------------------------------------- | ------------------------------------------------------------------------------ |
-| encryptors | Map<String, EncryptorRuleConfiguration> | Encryptor names and encryptors |
-| tables | Map<String, EncryptTableRuleConfiguration> | Encrypt table names and encrypt tables |
-
-#### EncryptorRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------- |
-| type | String | Type of encryptor,use user-defined ones or built-in ones, e.g. MD5/AES |
-| properties | Properties | Properties, Notice: when use AES encryptor, `aes.key.value` for AES encryptor need to be set |
-
-#### EncryptTableRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | -------------------------------------------- | ------------------------------------------ |
-| tables | Map<String, EncryptColumnRuleConfiguration> | Encrypt column names and encrypt column |
-
-#### EncryptColumnRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------- |
-| plainColumn | String | Plain column name |
-| cipherColumn | String | Cipher column name |
-| assistedQueryColumn | String | AssistedColumns for query,when use ShardingQueryAssistedEncryptor, it can help query encrypted data |
-| encryptor | String | Encryptor name |
-
-#### Properties
-
-Property configuration items, can be of the following properties.
-
-| *Name* | *DataType* | *Explanation* |
-| ---------------------------------- | ---------- | ------------------------------------------------------------ |
-| sql.show (?) | boolean | Show SQL or not, default value: false |
-| executor.size (?) | int | Work thread number, default value: CPU core number |
-| max.connections.size.per.query (?) | int | The maximum connection number allocated by each query of each physical database. default value: 1 |
-| check.table.metadata.enabled (?) | boolean | Check meta-data consistency or not in initialization, default value: false |
-| query.with.cipher.column (?) | boolean | When there is a plainColumn, use cipherColumn or not to query, default value: true |
-| allow.range.query.with.inline.sharding (?) | boolean | Allow or not execute range query with inline sharding strategy, default value: false |
-
-### Read-Write Split
-
-#### MasterSlaveDataSourceFactory
-
-| *Name* | *DataType* | *Explanation* |
-| --------------------- | ---------------------------- | ----------------------------------- |
-| dataSourceMap | Map\<String, DataSource\> | Mapping of data source and its name |
-| masterSlaveRuleConfig | MasterSlaveRuleConfiguration | Master slave rule configuration |
-| props (?) | Properties | Property configurations |
-
-#### MasterSlaveRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------------ | ------------------------------- | --------------------------------- |
-| name | String | Read-write split data source name |
-| masterDataSourceName | String | Master database source name |
-| slaveDataSourceNames | Collection\<String\> | Slave database source name list |
-| loadBalanceAlgorithm (?) | MasterSlaveLoadBalanceAlgorithm | Slave database load balance |
-
-#### Properties
-
-Property configuration items, can be of the following properties.
-
-| *Name* | *Data Type* | *Explanation* |
-| ---------------------------------- | ----------- | ------------------------------------------------------------ |
-| sql.show (?) | boolean | Print SQL parse and rewrite log or not, default value: false |
-| executor.size (?) | int | Be used in work thread number implemented by SQL; no limits if it is 0. default value: 0 |
-| max.connections.size.per.query (?) | int | The maximum connection number allocated by each query of each physical database, default value: 1 |
-| check.table.metadata.enabled (?) | boolean | Check meta-data consistency or not in initialization, default value: false |
-
-### data encryption
-
-#### EncryptDataSourceFactory
-
-| *Name* | *DataType* | *Explanation* |
-| --------------------- | ---------------------------- | ------------------ |
-| dataSource | DataSource | Data source |
-| encryptRuleConfig | EncryptRuleConfiguration | encrypt rule configuration |
-| props (?) | Properties | Property configurations |
-
-#### EncryptRuleConfiguration
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | ------------------------------------------- | ----------------------------------------------------------- |
-| encryptors | Map<String, EncryptorRuleConfiguration> | Encryptor names and encryptors |
-| tables | Map<String, EncryptTableRuleConfiguration> | Encrypt table names and encrypt tables |
-
-#### Properties
-
-Property configuration items, can be of the following properties.
-
-| *Name* | *DataType*| *Explanation* |
-| ----------------------------------| --------- | ------------------------------------------------------------------------------------ |
-| sql.show (?) | boolean | Print SQL parse and rewrite log or not, default value: false |
-| query.with.cipher.column (?) | boolean | When there is a plainColumn, use cipherColumn or not to query, default value: true |
-
-### Orchestration
-
-#### OrchestrationShardingDataSourceFactory
-
-| *Name* | *DataType* | *Explanation* |
-| ------------------- | -------------------------- | -------------------------------------- |
-| dataSourceMap | Map\<String, DataSource\> | Same as `ShardingDataSourceFactory` |
-| shardingRuleConfig | ShardingRuleConfiguration | Same as `ShardingDataSourceFactory` |
-| props (?) | Properties | Same as `ShardingDataSourceFactory` |
-| orchestrationConfig | OrchestrationConfiguration | Orchestration rule configurations |
-
-#### OrchestrationMasterSlaveDataSourceFactory
-
-| *Name* | *Data Type* | *Explanation* |
-| --------------------- | ---------------------------- | -------------------------------------- |
-| dataSourceMap | Map<String, DataSource> | Same as `MasterSlaveDataSourceFactory` |
-| masterSlaveRuleConfig | MasterSlaveRuleConfiguration | Same as `MasterSlaveDataSourceFactory` |
-| configMap (?) | Map<String, Object> | Same as `MasterSlaveDataSourceFactory` |
-| props (?) | Properties | Same as `ShardingDataSourceFactory` |
-| orchestrationConfig | OrchestrationConfiguration | Orchestration rule configurations |
-
-#### OrchestrationEncryptDataSourceFactory
-
-| *Name* | *DataType* | *Explanation* |
-| --------------------- | ---------------------------- | ---------------------------------- |
-| dataSource | DataSource | Same as `EncryptDataSourceFactory` |
-| encryptRuleConfig | EncryptRuleConfiguration | Same as `EncryptDataSourceFactory` |
-| props (?) | Properties | Same as `EncryptDataSourceFactory` |
-| orchestrationConfig | OrchestrationConfiguration | Orchestration rule configurations |
-
-
-#### OrchestrationConfiguration
-
-| *Name* | *Data Type* | *Explanation* |
-| --------------- | --------------------------- | ------------------------------------------------------------ |
-| instanceConfigurationMap | Map\<String, CenterConfiguration\> | config map of config-center®istry-center,the key is center's name,the value is the config-center/registry-center |
-
-
-#### CenterConfiguration
-
-| *Name* | *Data Type* | *Explanation* |
-| -------------------------------- | ----------- | ------------------------------------------------------------ |
-| instanceType | String | The type of center instance(zookeeper/etcd/apollo/nacos) |
-| properties | String | Properties for center instance config, such as options of zookeeper |
-| orchestrationType | String | The type of orchestration center: config_center or registry_center or metadata_center, if both, use "setOrchestrationType("registry_center,config_center,metadata_center");" |
-| serverLists | String | Connect to server lists in center, including IP address and port number; addresses are separated by commas, such as `host1:2181,host2:2181` |
-| namespace (?) | String | Namespace of center instance |
-
-Common configuration in properties as follow:
-
-| *Name* | *Data Type* | *Explanation* |
-| -------------------------------- | ----------- | ------------------------------------------------------------ |
-| overwrite | boolean | Local configurations overwrite config center configurations or not; if they overwrite, each start takes reference of local configurations |
-
-If type of center is `zookeeper` with config-center®istry-center&metadata-center, properties could be set with the follow options:
-
-| *Name* | *Data Type* | *Explanation* |
-| -------------------------------- | ----------- | ------------------------------------------------------------ |
-| digest (?) | String | Connect to authority tokens in registry center; default indicates no need for authority |
-| operationTimeoutMilliseconds (?) | int | The operation timeout millisecond number, default to be 500 milliseconds |
-| maxRetries (?) | int | The maximum retry count, default to be 3 times |
-| retryIntervalMilliseconds (?) | int | The retry interval millisecond number, default to be 500 milliseconds |
-| timeToLiveSeconds (?) | int | The living time for temporary nodes, default to be 60 seconds |
-
-If type of center is `etcd` with config-center®istry-center&metadata-center, properties could be set with the follow options:
-
-| *Name* | *Data Type* | *Explanation* |
-| -------------------------------- | ----------- | ------------------------------------------------------------ |
-| timeToLiveSeconds (?) | long | The etcd TTL in seconds, default to be 30 seconds |
-
-If type of center is `apollo` with config-center, properties could be set with the follow options:
-
-| *Name* | *Data Type* | *Explanation* |
-| -------------------------------- | ----------- | ------------------------------------------------------------ |
-| appId (?) | String | Apollo appId, default to be "APOLLO_SHARDINGSPHERE" |
-| env (?) | String | Apollo env, default to be "DEV" |
-| clusterName (?) | String | Apollo clusterName, default to be "default" |
-| administrator (?) | String | Apollo administrator, default to be "" |
-| token (?) | String | Apollo token, default to be "" |
-| portalUrl (?) | String | Apollo portalUrl, default to be "" |
-| connectTimeout (?) | int | Apollo connectTimeout, default to be 1000 milliseconds |
-| readTimeout (?) | int | Apollo readTimeout, default to be 5000 milliseconds |
-
-If type of center is `nacos` with config-center®istry-center, properties could be set with the follow options:
-
-| *Name* | *Data Type* | *Explanation* |
-| -------------------------------- | ----------- | ------------------------------------------------------------ |
-| group (?) | String | Nacos group, "SHARDING_SPHERE_DEFAULT_GROUP" in default |
-| timeout (?) | long | Nacos timeout, default to be 3000 milliseconds |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md
index 818dbb6..7b40198 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md
@@ -573,7 +573,7 @@
#### \<sharding:key-generator />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| --------- | --------- | ------------------------------------------------------------ |
| column | Attribute | Auto-increment column name |
| type | Attribute | Auto-increment key generator `Type`; self-defined generator or internal Type generator (SNOWFLAKE/UUID) can both be selected |
@@ -585,7 +585,7 @@
##### SNOWFLAKE
-| *Name* | *DataType* | *Explanation* |
+| *Name* | *DataType* | *Description* |
| --------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| worker.id (?) | long | The unique id for working machine, the default value is `0` |
| max.tolerate.time.difference.milliseconds (?) | long | The max tolerate time for different server's time difference in milliseconds, the default value is `10` |
@@ -593,7 +593,7 @@
#### \<sharding:encrypt-rules />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| -------------------| ------ | ---------------- |
| encryptor-rule (+) | Tag | Encryptor rule |
@@ -605,7 +605,7 @@
#### \<sharding:props />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ---------------------------------- | --------- | ------------------------------------------------------------ |
| sql.show (?) | Attribute | Show SQL or not; default value: false |
| executor.size (?) | Attribute | Executing thread number; default value: CPU core number |
@@ -619,7 +619,7 @@
#### \<master-slave:data-source />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ----------------------- | --------- | ------------------------------------------------------------ |
| id | Attribute | Spring Bean id |
| master-data-source-name | Attribute | Bean id of data source in master database |
@@ -631,7 +631,7 @@
#### \<master-slave:props />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ---------------------------------- | --------- | ------------------------------------------------------------ |
| sql.show (?) | Attribute | Show SQL or not; default value: false |
| executor.size (?) | Attribute | Executing thread number; default value: CPU core number |
@@ -641,7 +641,7 @@
#### \<master-slave:load-balance-algorithm />
4.0.0-RC2 version added
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ---------------------------------- | --------- | ------------------------------------------------------------ |
| id | Attribute | Spring Bean Id |
| type | Attribute | Type of load balance algorithm, 'RANDOM'或'ROUND_ROBIN', support custom extension|
@@ -667,7 +667,7 @@
#### \<encrypt:encryptor />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ----------------------- | --------- | ----------------------------------------------------------- |
| id | Attribute | Names of Encryptor |
| type | Attribute | Types of Encryptor, including MD5/AES or customize type |
@@ -675,19 +675,19 @@
#### \<encrypt:tables />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ----------------------- | ----- | --------------------------------------------------------- |
| table(+) | Tag | Encrypt table configuration |
#### \<encrypt:table />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ----------------------- | ------ | ---------------------------------------------------------|
| column(+) | Tag | Encrypt column configuration |
#### \<encrypt:column />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ----------------------- | --------- | --------------------------------------------------------------------------------------------------- |
| logic-column | Attribute | Logic column name |
| plain-column | Attribute | Plain column name |
@@ -696,7 +696,7 @@
#### \<encrypt:props />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ---------------------------------- | --------- | ------------------------------------------------------------ |
| sql.show (?) | Attribute | Show SQL or not; default value: false |
| query.with.cipher.column (?) | Attribute | When there is a plainColumn, use cipherColumn or not to query, default value: true |
@@ -707,7 +707,7 @@
#### \<orchestration:master-slave-data-source />
-| *Name* | *Type* | *Explanation* |
+| *Name* | *Type* | *Description* |
| ------------------- | --------- | ------------------------------------------------------------ |
| id | Attribute | ID |
| data-source-ref (?) | Attribute | Orchestrated database id |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/_index.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/_index.cn.md
new file mode 100644
index 0000000..9db918e
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/_index.cn.md
@@ -0,0 +1,72 @@
++++
+title = "Java API"
+weight = 1
+chapter = true
++++
+
+## 简介
+
+Java API 是 ShardingSphere-JDBC 中所有配置方式的基础,其他配置最终都将转化成为Java API 的配置方式。
+
+Java API 是最复杂也是最灵活的配置方式,适合需要通过编程进行动态配置的场景下使用。
+
+## 使用方式
+
+### 创建简单数据源
+
+通过 ShardingSphereDataSourceFactory 工厂创建的 ShardingSphereDataSource 实现自 JDBC 的标准接口 DataSource。
+
+```java
+// 构建数据源
+Map<String, DataSource> dataSourceMap = // ...
+
+// 构建配置规则
+Collection<RuleConfiguration> configurations = // ...
+
+// 构建属性配置
+Properties props = // ...
+
+DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props);
+```
+
+### 创建携带治理功能的数据源
+
+通过 OrchestrationShardingSphereDataSourceFactory 工厂创建的 OrchestrationShardingSphereDataSource 实现自 JDBC 的标准接口 DataSource。
+
+```java
+// 构建数据源
+Map<String, DataSource> dataSourceMap = // ...
+
+// 构建配置规则
+Collection<RuleConfiguration> configurations = // ...
+
+// 构建属性配置
+Properties props = // ...
+
+// 构建注册中心配置对象
+OrchestrationConfiguration orchestrationConfig = // ...
+
+DataSource dataSource = OrchestrationShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props, orchestrationConfig);
+```
+
+### 使用数据源
+
+可通过 DataSource 选择使用原生 JDBC,或JPA, MyBatis 等 ORM 框架。
+
+以原生 JDBC 使用方式为例:
+
+```java
+DataSource dataSource = // 通过Apache ShardingSphere 工厂创建的数据源
+String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.user_id=? AND o.order_id=?";
+try (
+ Connection conn = dataSource.getConnection();
+ PreparedStatement ps = conn.prepareStatement(sql)) {
+ ps.setInt(1, 10);
+ ps.setInt(2, 1000);
+ try (ResultSet rs = preparedStatement.executeQuery()) {
+ while(rs.next()) {
+ // ...
+ }
+ }
+}
+```
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/_index.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/_index.en.md
new file mode 100644
index 0000000..6d9aa3c
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/_index.en.md
@@ -0,0 +1,74 @@
++++
+title = "Java API"
+weight = 1
+chapter = true
++++
+
+## Introduction
+
+Java API is the foundation of all configuration methods in ShardingSphere-JDBC,
+and other configurations will eventually be transformed into Java API configuration methods.
+
+The Java API is the most complex and flexible configuration method, which is suitable for the scenarios requiring dynamic configuration through programming.
+
+## Usage
+
+### Create Simple DataSource
+
+The ShardingSphereDataSource created by ShardingSphereDataSourceFactory implements the standard JDBC DataSource interface.
+
+```java
+// Build data source map
+Map<String, DataSource> dataSourceMap = // ...
+
+// Build rule configurations
+Collection<RuleConfiguration> configurations = // ...
+
+// Build properties
+Properties props = // ...
+
+DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props);
+```
+
+### Create Orchestration DataSource
+
+The OrchestrationShardingSphereDataSource created by OrchestrationShardingSphereDataSourceFactory implements the standard JDBC DataSource interface.
+
+
+```java
+// Build data source map
+Map<String, DataSource> dataSourceMap = // ...
+
+// Build rule configurations
+Collection<RuleConfiguration> configurations = // ...
+
+// Build properties
+Properties props = // ...
+
+// Build orchestration configuration
+OrchestrationConfiguration orchestrationConfig = // ...
+
+DataSource dataSource = OrchestrationShardingSphereDataSourceFactory.createDataSource(dataSourceMap, configurations, props, orchestrationConfig);
+```
+
+### Use DataSource
+
+Developer can choose to use native JDBC or ORM frameworks such as JPA or MyBatis through the DataSource.
+
+Take native JDBC usage as an example:
+
+```java
+DataSource dataSource = // Use Apache ShardingSphere factory to create DataSource
+String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.user_id=? AND o.order_id=?";
+try (
+ Connection conn = dataSource.getConnection();
+ PreparedStatement ps = conn.prepareStatement(sql)) {
+ ps.setInt(1, 10);
+ ps.setInt(2, 1000);
+ try (ResultSet rs = preparedStatement.executeQuery()) {
+ while(rs.next()) {
+ // ...
+ }
+ }
+}
+```
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/encrypt.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/encrypt.cn.md
new file mode 100644
index 0000000..c95868b
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/encrypt.cn.md
@@ -0,0 +1,77 @@
++++
+title = "数据加密"
+weight = 3
++++
+
+## 配置入口
+
+类名称:org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| -------------- | -------------------------------------------- | ---------------- |
+| tables (+) | Map\<String, EncryptTableRuleConfiguration\> | 加密表名称和列表 |
+| encryptors (+) | Map\<String, EncryptorRuleConfiguration\> | 加解密器名称和列表 |
+
+## 加密表配置
+
+类名称:org.apache.shardingsphere.encrypt.api.config.EncryptTableRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| -------------- | --------------------------------------------- | -------------- |
+| columns (+) | Map\<String, EncryptColumnRuleConfiguration\> | 加密列名称和列表 |
+
+### 加密列配置
+
+类名称:org.apache.shardingsphere.encrypt.api.config.EncryptColumnRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ----------------------- | -------- | ------------ |
+| plainColumn (?) | String | 原文列名称 |
+| cipherColumn | String | 密文列名称 |
+| assistedQueryColumn (?) | String | 查询辅助列名称 |
+| encryptor | String | 加密器类型 |
+
+## 加解密器配置
+
+类名称:org.apache.shardingsphere.encrypt.api.config.EncryptorRuleConfiguration
+
+可配置属性:
+
+| *名称* |*数据类型* | *说明* |
+| ---------- | ---------- | -------------- |
+| type | String | 加解密器类型 |
+| properties | Properties | 加解密器属性配置 |
+
+Apache ShardingSphere 内置的加解密器算法实现类包括:
+
+### MD5 加解密器
+
+类名称:org.apache.shardingsphere.encrypt.strategy.impl.MD5Encryptor
+
+可配置属性:无
+
+### AES 加解密器
+
+类名称:org.apache.shardingsphere.encrypt.strategy.impl.AESEncryptor
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ------------- | --------- | ------------- |
+| aes.key.value | String | AES 使用的 KEY |
+
+### RC4 加解密器
+
+类名称:org.apache.shardingsphere.encrypt.strategy.impl.RC4Encryptor
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ------------- | --------- | ------------- |
+| rc4.key.value | String | RC4 使用的 KEY |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/encrypt.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/encrypt.en.md
new file mode 100644
index 0000000..f0ea636
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/encrypt.en.md
@@ -0,0 +1,77 @@
++++
+title = "Encryption"
+weight = 3
++++
+
+## Root Configuration
+
+Class name: org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| -------------- | -------------------------------------------- | -------------------------------------- |
+| encryptors (+) | Map\<String, EncryptorRuleConfiguration\> | Encryptor names and encryptors |
+| tables (+) | Map\<String, EncryptTableRuleConfiguration\> | Encrypt table names and encrypt tables |
+
+## Encrypt Table Configuration
+
+Class name: org.apache.shardingsphere.encrypt.api.config.EncryptTableRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| -------------- | --------------------------------------------- | -------------------------------- |
+| columns (+) | Map\<String, EncryptColumnRuleConfiguration\> | Encrypt column names and columns |
+
+### Encrypt Column Configuration
+
+Class name: org.apache.shardingsphere.encrypt.api.config.EncryptColumnRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ----------------------- | ---------- | -------------------------- |
+| plainColumn (?) | String | Plain column name |
+| cipherColumn | String | Cipher column name |
+| assistedQueryColumn (?) | String | Assisted query column name |
+| encryptor | String | Encryptor type |
+
+## Encryptor Configuration
+
+Class name: org.apache.shardingsphere.encrypt.api.config.EncryptorRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ---------- | ---------- | --------------------- |
+| type | String | Encryptor type |
+| properties | Properties | Encryptor properties |
+
+Apache ShardingSphere built-in implemented classes of Encryptor are:
+
+### MD5 Encryptor
+
+Class name: org.apache.shardingsphere.encrypt.strategy.impl.MD5Encryptor
+
+Attributes: None
+
+### AES Encryptor
+
+Class name: org.apache.shardingsphere.encrypt.strategy.impl.AESEncryptor
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ------------- | ---------- | ------------- |
+| aes.key.value | String | AES KEY |
+
+### RC4 Encryptor
+
+Class name: org.apache.shardingsphere.encrypt.strategy.impl.RC4Encryptor
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ------------- | ---------- | ------------- |
+| rc4.key.value | String | RC4 KEY |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/governance.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/governance.cn.md
new file mode 100644
index 0000000..376bee9
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/governance.cn.md
@@ -0,0 +1,70 @@
++++
+title = "分布式治理"
+weight = 6
++++
+
+## 配置入口
+
+类名称:org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ------------------------ | ----------------------------------- | ----------------------------------------------------------------- |
+| instanceConfigurationMap | Map\<String, CenterConfiguration\> | 配置/注册/元数据中心的配置 map,key 为名称,value 为配置/注册/元数据中心 |
+
+## 配置/注册中心配置
+
+类名称:org.apache.shardingsphere.orchestration.center.config.CenterConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ----------------- | ---------- | --------------------------------------------------------------------------------------------- |
+| instanceType | String | 配置/注册中心的实例类型,例如:ZooKeeper 或 Etcd、Apollo、Nacos 等 |
+| properties | Properties | 配置本实例需要的其他参数,例如 ZooKeeper 的连接参数等 |
+| orchestrationType | String | 治理类型,例如:config_center、registry_center、metadata_center,多个类型用逗号分隔 |
+| serverLists | String | 连接配置/注册/元数据中心服务器的列表,包括IP地址和端口号,多个地址用逗号分隔。如: host1:2181,host2:2181 |
+| namespace (?) | String | 配置/注册/元数据中心的命名空间 |
+
+### 通用属性配置
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| --------------- | --------- | ---------------------------------------------------------- | ------- |
+| overwrite | boolean | 本地配置是否覆盖配置中心配置,如果可覆盖,每次启动都以本地配置为准 | false |
+
+### ZooKeeper 属性配置
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| -------------------------------- | ---------- | --------------------- | ------- |
+| digest (?) | String | 连接注册中心的权限令牌 | 无需验证 |
+| operationTimeoutMilliseconds (?) | int | 操作超时的毫秒数 | 500 毫秒 |
+| maxRetries (?) | int | 连接失败后的最大重试次数 | 3 次 |
+| retryIntervalMilliseconds (?) | int | 重试间隔毫秒数 | 500 毫秒 |
+| timeToLiveSeconds (?) | int | 临时节点存活秒数 | 60 秒 |
+
+### Etcd 属性配置
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| --------------------- | --------- | ---------- | ------- |
+| timeToLiveSeconds (?) | long | 数据存活秒数 | 30秒 |
+
+### Apollo 属性配置
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| ------------------ | -------- | -------------------- | --------------------- |
+| 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 | 连接超时毫秒数 | 1000 毫秒 |
+| readTimeout (?) | int | 读取超时毫秒数 | 5000 毫秒 |
+
+### Nacos 属性配置
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| ----------- | --------- | ---------------------- | ---------------------------- |
+| group (?) | String | nacos group 配置 | SHARDING_SPHERE_DEFAULT_GROUP |
+| timeout (?) | long | nacos 获取数据超时毫秒数 | 3000 毫秒 |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/governance.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/governance.en.md
new file mode 100644
index 0000000..e80669e
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/governance.en.md
@@ -0,0 +1,71 @@
++++
+title = "Governance"
+weight = 6
++++
+
+## Root Configuration
+
+Class name: org.apache.shardingsphere.orchestration.center.config.OrchestrationConfiguration
+
+Attributes:
+
+| *Name* | *Data Type* | *Description* |
+| ------------------------ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
+| instanceConfigurationMap | Map\<String, CenterConfiguration\> | Config map of config-center®istry-center, the key is center's name, the value is the config-center/registry-center |
+
+## Config / Registry Center Configuration
+
+Class name: org.apache.shardingsphere.orchestration.center.config.CenterConfiguration
+
+Attributes:
+
+| *Name* | *Data Type* | *Description* |
+| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
+| instanceType | String | The type of center instance(zookeeper/etcd/apollo/nacos) |
+| properties | String | Properties for center instance config, such as options of zookeeper |
+| orchestrationType | String | The type of orchestration center: config_center or registry_center or metadata_center, multiple types are separated by commas |
+| serverLists | String | Connect to server lists in center, including IP address and port number; addresses are separated by commas, such as `host1:2181,host2:2181` |
+| namespace (?) | String | Namespace of center instance |
+
+### Common Properties Configuration
+
+| *Name* | *Data Type* | *Description* | *Default Value* |
+| --------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
+| overwrite | boolean | Local configurations overwrite config center configurations or not; if they overwrite, each start takes reference of local configurations | false |
+
+### ZooKeeper Properties Configuration
+
+| *Name* | *Data Type* | *Description* | *Default Value* |
+| -------------------------------- | ----------- | ---------------------------------------------- | --------------------- |
+| digest (?) | String | Connect to authority tokens in registry center | No need for authority |
+| operationTimeoutMilliseconds (?) | int | The operation timeout milliseconds | 500 milliseconds |
+| maxRetries (?) | int | The maximum retry count | 3 |
+| retryIntervalMilliseconds (?) | int | The retry interval milliseconds | 500 milliseconds |
+| timeToLiveSeconds (?) | int | Time to live seconds for ephemeral nodes | 60 seconds |
+
+
+### Etcd Properties Configuration
+
+| *Name* | *Data Type* | *Description* | *Default Value* |
+| --------------------- | ----------- | ------------------------------------- | --------------- |
+| timeToLiveSeconds (?) | long | Time to live seconds for data persist | 30 seconds |
+
+### Apollo Properties Configuration
+
+| *Name* | *Data Type* | *Description* | *Default Value* |
+| ------------------ | ----------- | ---------------------------- | --------------------- |
+| appId (?) | String | Apollo appId | APOLLO_SHARDINGSPHERE |
+| env (?) | String | Apollo env | DEV |
+| clusterName (?) | String | Apollo clusterName | default |
+| administrator (?) | String | Apollo administrator | Empty |
+| token (?) | String | Apollo token | Empty |
+| portalUrl (?) | String | Apollo portalUrl | Empty |
+| connectTimeout (?) | int | Connect timeout milliseconds | 1000 milliseconds |
+| readTimeout (?) | int | Read timeout milliseconds | 5000 milliseconds |
+
+### Nacos Properties Configuration
+
+| *Name* | *Data Type* | *Description* | *Default Value* |
+| ----------- | ----------- | ------------- | ----------------------------- |
+| group (?) | String | group | SHARDING_SPHERE_DEFAULT_GROUP |
+| timeout (?) | long | timeout | 3000 milliseconds |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/read-write-split.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/read-write-split.cn.md
new file mode 100644
index 0000000..d4ac636
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/read-write-split.cn.md
@@ -0,0 +1,48 @@
++++
+title = "读写分离"
+weight = 2
++++
+
+## 配置入口
+
+类名称:org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| --------------- | ------------------------------------------------ | ------------ |
+| dataSources (+) | Collection\<MasterSlaveDataSourceConfiguration\> | 主从数据源列表 |
+
+## 主从数据源配置
+
+类名称:org.apache.shardingsphere.masterslave.api.config.MasterSlaveDataSourceConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| ------------------------------------ | -------------------------------- | ---------------- | -------------- |
+| name | String | 读写分离数据源名称 | - |
+| masterDataSourceName | String | 主库数据源名称 | - |
+| slaveDataSourceNames | Collection\<String\> | 从库数据源名称列表 | - |
+| loadBalanceStrategyConfiguration (?) | LoadBalanceStrategyConfiguration | 从库负载均衡算法 | 轮询负载均衡算法 |
+
+## 从库负载均衡策略配置
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| -------------- | ---------- | -------------------- | -------------- |
+| type | String | 从库负载均衡算法类型 | - |
+| properties (?) | Properties | 从库负载均衡算法属性配置 | 空 |
+
+Apache ShardingSphere 内置的从库负载均衡算法实现类包括:
+
+### 轮询算法
+
+类名称:org.apache.shardingsphere.masterslave.strategy.RoundRobinMasterSlaveLoadBalanceAlgorithm
+
+可配置属性:无
+
+### 随机访问算法
+
+类名称:org.apache.shardingsphere.masterslave.strategy.RandomMasterSlaveLoadBalanceAlgorithm
+
+可配置属性:无
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/read-write-split.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/read-write-split.en.md
new file mode 100644
index 0000000..0863abf
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/read-write-split.en.md
@@ -0,0 +1,48 @@
++++
+title = "Read-write Split"
+weight = 2
++++
+
+## Root Configuration
+
+Class name: org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ------------------------ | ------------------------------------------------ | ------------------------------------ |
+| dataSources (+) | Collection\<MasterSlaveDataSourceConfiguration\> | Data sources of master and slaves |
+
+## Master Slave Data Source Configuration
+
+Class name: org.apache.shardingsphere.masterslave.api.config.MasterSlaveDataSourceConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* | *Default Value* |
+| ------------------------------------ | -------------------------------- | ------------------------------------- | ---------------------------------- |
+| name | String | Read-write split data source name | - |
+| masterDataSourceName | String | Master database source name | - |
+| slaveDataSourceNames | Collection\<String\> | Slave database source name list | - |
+| loadBalanceStrategyConfiguration (?) | LoadBalanceStrategyConfiguration | Slave database load balance algorithm | Round robin load balance algorithm |
+
+## Slave Data Sources Load Balance Strategy Configuration
+
+| *Name* | *DataType* | *Description* | *Default Value* |
+| -------------- | ---------- | ---------------------------------------------------- | --------------- |
+| type | String | Slave data sources load balance algorithm type | - |
+| properties (?) | Properties | Slave data sources load balance algorithm Properties | Empty |
+
+Apache ShardingSphere built-in implemented classes of MasterSlaveLoadBalanceAlgorithm are:
+
+### Round Robin Algorithm
+
+Class name: org.apache.shardingsphere.masterslave.strategy.RoundRobinMasterSlaveLoadBalanceAlgorithm
+
+Attributes: None
+
+### Random Algorithm
+
+Class name: org.apache.shardingsphere.masterslave.strategy.RandomMasterSlaveLoadBalanceAlgorithm
+
+Attributes: None
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/replica.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/replica.cn.md
new file mode 100644
index 0000000..06d898e
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/replica.cn.md
@@ -0,0 +1,10 @@
++++
+title = "多数据副本"
+weight = 5
++++
+
+## 配置入口
+
+类名称:org.apache.shardingsphere.replica.api.config.ReplicaRuleConfiguration
+
+TODO
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/replica.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/replica.en.md
new file mode 100644
index 0000000..1efbfa8
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/replica.en.md
@@ -0,0 +1,10 @@
++++
+title = "Multi Replica"
+weight = 5
++++
+
+## Root Configuration
+
+Class name: org.apache.shardingsphere.replica.api.config.ReplicaRuleConfiguration
+
+TODO
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/shadow.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/shadow.cn.md
new file mode 100644
index 0000000..3e5bacc
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/shadow.cn.md
@@ -0,0 +1,10 @@
++++
+title = "影子库"
+weight = 4
++++
+
+## 配置入口
+
+类名称:org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration
+
+TODO
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/shadow.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/shadow.en.md
new file mode 100644
index 0000000..7925939
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/shadow.en.md
@@ -0,0 +1,10 @@
++++
+title = "Shadow DB"
+weight = 4
++++
+
+## Root Configuration
+
+Class name: org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration
+
+TODO
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/sharding.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/sharding.cn.md
new file mode 100644
index 0000000..d533a89
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/sharding.cn.md
@@ -0,0 +1,189 @@
++++
+title = "数据分片"
+weight = 1
++++
+
+## 配置入口
+
+类名称:org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| ----------------------------------------- | ------------------------------------ | ----------------- | ------- |
+| tableRuleConfigs (+) | Collection\<TableRuleConfiguration\> | 分片规则列表 | - |
+| bindingTableGroups (*) | Collection\<String\> | 绑定表规则列表 | 无 |
+| broadcastTables (*) | Collection\<String\> | 广播表规则列表 | 无 |
+| defaultDatabaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | 默认分库策略 | 不分片 |
+| defaultTableShardingStrategyConfig (?) | ShardingStrategyConfiguration | 默认分表策略 | 不分片 |
+| defaultKeyGeneratorConfig (?) | KeyGeneratorConfiguration | 默认自增列生成器配置 | 雪花算法 |
+
+## 逻辑表配置
+
+类名称:org.apache.shardingsphere.sharding.api.config.TableRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* | *默认值* |
+| ---------------------------------- | ----------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
+| logicTable | String | 逻辑表名称 | - |
+| actualDataNodes (?) | String | 由数据源名 + 表名组成,以小数点分隔。<br />多个表以逗号分隔,支持行表达式 | 使用已知数据源与逻辑表名称生成数据节点,用于广播表或只分库不分表且所有库的表结构完全一致的情况 |
+| databaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | 分库策略 | 使用默认分库策略 |
+| tableShardingStrategyConfig (?) | ShardingStrategyConfiguration | 分表策略 | 使用默认分表策略 |
+| keyGeneratorConfig (?) | KeyGeneratorConfiguration | 自增列生成器 | 使用默认自增主键生成器 |
+
+## 分片策略配置
+
+### 标准分片策略配置
+
+类名称:org.apache.shardingsphere.sharding.api.config.strategy.StandardShardingStrategyConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ----------------- | ------------------------- | ---------------- |
+| shardingColumn | String | 分片列名称 |
+| shardingAlgorithm | StandardShardingAlgorithm | 标准分片算法实现类 |
+
+Apache ShardingSphere 内置的标准分片算法实现类包括:
+
+#### 行表达式分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.inline.InlineShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* | *默认值* |
+| ----------------------------------------- | --------- | --------------------------------------------------- | ------- |
+| algorithm.expression | String | 分片算法的行表达式 | - |
+| allow.range.query.with.inline.sharding (?)| boolean | 是否允许范围查询。注意:范围查询会无视分片策略,进行全路由 | false |
+
+#### 取模分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.ModuloShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* |
+| --------- | --------- | ------- |
+| mod.value | int | 分片数量 |
+
+#### 哈希取模分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.HashShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* |
+| --------- | --------- | ------- |
+| mod.value | int | 分片数量 |
+
+#### 固定容量范围分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.range.StandardRangeShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* |
+| ---------------- | --------- | -------------------------- |
+| partition.lower | long | 范围下界,超过边界的数据会报错 |
+| partition.upper | long | 范围上界,超过边界的数据会报错 |
+| partition.volume | long | 分片容量 |
+
+#### 自定义边界范围分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.range.CustomRangeShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* |
+| ---------------- | --------- | --------------------------------- |
+| partition.ranges | String | 分片的范围边界,多个范围边界以逗号分隔 |
+
+#### 定长时间段分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.DatetimeShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* |
+| ----------------- | --------- | ----------------------------------------------- |
+| epoch | String | 分片时间的起始纪元,时间戳格式:yyyy-MM-dd HH:mm:ss |
+| partition.seconds | long | 单一分片所能承载的最大时间,单位:秒 |
+
+#### 自定义时间边界分片算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.sharding.CustomDateTimeShardingAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* |
+| -------------------- | --------- | ----------------------------------- |
+| datetime.format | String | 时间戳格式,例如:yyyy-MM-dd HH:mm:ss |
+| table.suffix.format | String | TODO |
+| datetime.lower | String | TODO |
+| datetime.upper | String | TODO |
+| datetime.step.unit | String | TODO |
+| datetime.step.amount | String | TODO |
+
+### 复合分片策略配置
+
+类名称:ComplexShardingStrategyConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ----------------- | ---------------------------- | ------------------------ |
+| shardingColumns | String | 分片列名称,多个列以逗号分隔 |
+| shardingAlgorithm | ComplexKeysShardingAlgorithm | 复合分片算法实现类 |
+
+Apache ShardingSphere 暂无内置复合分片算法实现类。
+
+### Hint 分片策略配置
+
+类名称:HintShardingStrategyConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ----------------- | --------------------- | ----------- |
+| shardingAlgorithm | HintShardingAlgorithm | Hint分片算法 |
+
+Apache ShardingSphere 暂无内置复合分片算法实现类。
+
+### 不分片策略配置
+
+类名称:NoneShardingStrategyConfiguration
+
+可配置属性:无
+
+## 自增主键策略配置
+
+类名称:KeyGeneratorConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| -------------------- | -------------------- | ---------------- |
+| column | String | 自增列名称 |
+| keyGenerateAlgorithm | KeyGenerateAlgorithm | 自增主键算法实现类 |
+
+Apache ShardingSphere 内置的自增主键算法实现类包括:
+
+### 雪花算法
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.keygen.SnowflakeKeyGenerateAlgorithm
+
+可配置属性:
+
+| *属性名称* | *数据类型* | *说明* | *默认值* |
+| --------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
+| worker.id (?) | long | 工作机器唯一标识 | 0 |
+| max.vibration.offset (?) | int | 最大抖动上限值,范围[0, 4096)。注:若使用此算法生成值作分片值,建议配置此属性。此算法在不同毫秒内所生成的 key 取模 2^n (2^n一般为分库或分表数) 之后结果总为 0 或 1。为防止上述分片问题,建议将此属性值配置为 (2^n)-1 | 1 |
+| max.tolerate.time.difference.milliseconds (?) | long | 最大容忍时钟回退时间,单位:毫秒 | 10 毫秒 |
+
+### UUID
+
+类名称:org.apache.shardingsphere.sharding.strategy.algorithm.keygen.UUIDKeyGenerateAlgorithm
+
+可配置属性:无
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/sharding.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/sharding.en.md
new file mode 100644
index 0000000..663870d
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/sharding.en.md
@@ -0,0 +1,211 @@
++++
+title = "Sharding"
+weight = 1
++++
+
+## Root Configuration
+
+Class name: org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* | *Default Value* |
+| ----------------------------------------- | ------------------------------------ | ---------------------------------- | --------------- |
+| tableRuleConfigs (+) | Collection\<TableRuleConfiguration\> | Sharding rules | - |
+| bindingTableGroups (*) | Collection\<String\> | Binding table rules | Empty |
+| broadcastTables (*) | Collection\<String\> | Broadcast table rules | Empty |
+| defaultDatabaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | Default database sharding strategy | Not sharding |
+| defaultTableShardingStrategyConfig (?) | ShardingStrategyConfiguration | Default table sharding strategy | Not sharding |
+| defaultKeyGeneratorConfig (?) | KeyGeneratorConfiguration | Default key generator | Snowflake |
+
+## Logic Table Configuration
+
+Class name: org.apache.shardingsphere.sharding.api.config.TableRuleConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* | *Default Value* |
+| ---------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
+| logicTable | String | Name of logic table | - |
+| actualDataNodes (?) | String | Describe data source names and actual tables, delimiter as point.<br /> Multiple data nodes split by comma, support inline expression | Broadcast table or databases sharding only. |
+| databaseShardingStrategyConfig (?) | ShardingStrategyConfiguration | Databases sharding strategy | Use default databases sharding strategy |
+| tableShardingStrategyConfig (?) | ShardingStrategyConfiguration | Tables sharding strategy | Use default tables sharding strategy |
+| keyGeneratorConfig (?) | KeyGeneratorConfiguration | Key generator configuration | Use default key generator |
+
+## Sharding Strategy Configuration
+
+### Standard Sharding Strategy Configuration
+
+Class name: org.apache.shardingsphere.sharding.api.config.strategy.StandardShardingStrategyConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| -------------------------- | ------------------------- | ----------------------------------------------- |
+| shardingColumn | String | Sharding column name |
+| shardingAlgorithm | StandardShardingAlgorithm | Standard sharding algorithm class |
+
+Apache ShardingSphere built-in implemented classes of StandardShardingAlgorithm are:
+
+#### Inline Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.inline.InlineShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* | *Default Value* |
+| ----------------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------- | --------------- |
+| algorithm.expression | String | Inline expression sharding algorithm | - |
+| allow.range.query.with.inline.sharding (?)| boolean | Whether range query is allowed. Note: range query will ignore sharding strategy and conduct full routing | false |
+
+#### Modulo Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.ModuloShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| --------- | ---------- | -------------- |
+| mod.value | int | Sharding count |
+
+#### Hash Modulo Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.HashShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| --------- | ---------- | -------------- |
+| mod.value | int | Sharding count |
+
+#### Volume Range Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.range.StandardRangeShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ---------------- | ---------- | -------------------------------------------------------- |
+| partition.lower | long | Range lower bound, throw exception if lower than bound |
+| partition.upper | long | Range upper bound, throw exception if upper than bound |
+| partition.volume | long | Sharding volume |
+
+#### Customized Range Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.range.CustomRangeShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ---------------- | ---------- | ----------------------------------------------------------------- |
+| partition.ranges | String | Range of sharding border, multiple boundaries separated by commas |
+
+#### Fixed Range Volume Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.range.StandardRangeShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ---------------- | ---------- | ------------------------------------------------------------------- |
+| partition.lower | long | Lower bound of range, data beyond the boundary will report an error |
+| partition.upper | long | Upper bound of range, data beyond the boundary will report an error |
+| partition.volume | long | Range volume |
+
+#### Custom Range Bound Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.range.CustomRangeShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ---------------- | ---------- | --------------------------------- |
+| partition.ranges | String | 分片的范围边界,多个范围边界以逗号分隔 |
+
+#### Fixed Time Range Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.DatetimeShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ----------------- | ---------- | -------------------------------------------------- |
+| epoch | String | Shard datetime epoch, pattern: yyyy-MM-dd HH:mm:ss |
+| partition.seconds | long | Max seconds for the data in one shard |
+
+#### Custom Datetime Bound Sharding Algorithm
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.sharding.CustomDateTimeShardingAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| -------------------- | ---------- | ---------------------------------------------- |
+| datetime.format | String | Datetime pattern, example: yyyy-MM-dd HH:mm:ss |
+| table.suffix.format | String | TODO |
+| datetime.lower | String | TODO |
+| datetime.upper | String | TODO |
+| datetime.step.unit | String | TODO |
+| datetime.step.amount | String | TODO |
+
+### Complex Sharding Strategy Configuration
+
+Class name: ComplexShardingStrategyConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ----------------- | ---------------------------- | ----------------------------------------- |
+| shardingColumns | String | Sharding column name, separated by commas |
+| shardingAlgorithm | ComplexKeysShardingAlgorithm | Complex sharding algorithm |
+
+There is no built-in complex keys sharding algorithm implementation class in Apache ShardingSphere.
+
+### Hint Sharding Strategy Configuration
+
+Class name: HintShardingStrategyConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| ----------------- | --------------------- | ----------------------- |
+| shardingAlgorithm | HintShardingAlgorithm | Hint sharding algorithm |
+
+There is no built-in hint sharding algorithm implementation class in Apache ShardingSphere.
+
+### None Sharding Strategy Configuration
+
+Class name: NoneShardingStrategyConfiguration
+
+Attributes: None
+
+## Key Generator Configuration
+
+Class name: KeyGeneratorConfiguration
+
+Attributes:
+
+| *Name* | *DataType* | *Description* |
+| -------------------- | -------------------- | ---------------------------- |
+| column | String | Column name of key generate |
+| keyGenerateAlgorithm | KeyGenerateAlgorithm | Key generate algorithm class |
+
+Apache ShardingSphere built-in implemented classes of KeyGenerateAlgorithm are:
+
+### Snowflake
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.keygen.SnowflakeKeyGenerateAlgorithm
+
+Attributes:
+
+| *Name* | *DataType* | *Description* | *Default Value* |
+| --------------------------------------------- | ---------- | ---------------------------------------------------------------------------- | --------------- |
+| worker.id (?) | long | The unique ID for working machine | 0 |
+| max.tolerate.time.difference.milliseconds (?) | long | The max tolerate time for different server's time difference in milliseconds | 10 milliseconds |
+| max.vibration.offset (?) | int | The max upper limit value of vibrate number, range `[0, 4096)`. Notice: To use the generated value of this algorithm as sharding value, it is recommended to configure this property. The algorithm generates key mod `2^n` (`2^n` is usually the sharding amount of tables or databases) in different milliseconds and the result is always `0` or `1`. To prevent the above sharding problem, it is recommended to configure this property, its value is `(2^n)-1`| 1 |
+
+### UUID
+
+Class name: org.apache.shardingsphere.sharding.strategy.algorithm.keygen.UUIDKeyGenerateAlgorithm
+
+Attributes: None
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.cn.md
index d17dc65..a58543a 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.cn.md
@@ -67,7 +67,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.en.md
index d6963a4..ec00f6f 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/java-api.en.md
@@ -67,7 +67,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.cn.md
index 8c24968..deef631 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.cn.md
@@ -61,7 +61,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.en.md
index 7e4c045..7cec3ec 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/governance/yaml.en.md
@@ -61,7 +61,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.cn.md
index 8491362..23c5bc8 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.cn.md
@@ -83,7 +83,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.en.md
index 3e9ddb6..fbccab5 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/java-api.en.md
@@ -84,7 +84,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.cn.md
index e242b14..3a94da6 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.cn.md
@@ -79,7 +79,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.en.md
index 0d46c50..1dc6952 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/sharding/yaml.en.md
@@ -82,7 +82,7 @@
Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, 10);
- ps.setInt(2, 1001);
+ ps.setInt(2, 1000);
try (ResultSet rs = preparedStatement.executeQuery()) {
while(rs.next()) {
// ...
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
index 11084f0..7aea262 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
@@ -52,6 +52,12 @@
public static final long EPOCH;
+ private static final String WORKER_ID_PROPERTY_KEY = "worker.id";
+
+ private static final String MAX_VIBRATION_OFFSET_PROPERTY_KEY = "max.vibration.offset";
+
+ private static final String MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS_PROPERTY_KEY = "max.tolerate.time.difference.milliseconds";
+
private static final long SEQUENCE_BITS = 12L;
private static final long WORKER_ID_BITS = 10L;
@@ -129,19 +135,19 @@
}
private long getWorkerId() {
- long result = Long.valueOf(properties.getProperty("worker.id", String.valueOf(WORKER_ID)));
+ long result = Long.valueOf(properties.getProperty(WORKER_ID_PROPERTY_KEY, String.valueOf(WORKER_ID)));
Preconditions.checkArgument(result >= 0L && result < WORKER_ID_MAX_VALUE);
return result;
}
private int getMaxVibrationOffset() {
- int result = Integer.parseInt(properties.getProperty("max.vibration.offset", String.valueOf(DEFAULT_VIBRATION_VALUE)));
+ int result = Integer.parseInt(properties.getProperty(MAX_VIBRATION_OFFSET_PROPERTY_KEY, String.valueOf(DEFAULT_VIBRATION_VALUE)));
Preconditions.checkArgument(result >= 0 && result <= SEQUENCE_MASK, "Illegal max vibration offset");
return result;
}
private int getMaxTolerateTimeDifferenceMilliseconds() {
- return Integer.valueOf(properties.getProperty("max.tolerate.time.difference.milliseconds", String.valueOf(MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS)));
+ return Integer.valueOf(properties.getProperty(MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS_PROPERTY_KEY, String.valueOf(MAX_TOLERATE_TIME_DIFFERENCE_MILLISECONDS)));
}
private long waitUntilNextTime(final long lastTime) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/CustomDateTimeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/CustomDateTimeShardingAlgorithm.java
index d5d55ee..a3d8e94 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/CustomDateTimeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/CustomDateTimeShardingAlgorithm.java
@@ -61,32 +61,32 @@
*
* <p>examples: when shard by {@link IsoFields#QUARTER_OF_YEAR}, datetime.step.unit = Months and datetime.step.amount = 3 is a better choice.
*/
-public class CustomDateTimeShardingAlgorithm implements StandardShardingAlgorithm<Comparable<?>> {
-
+public final class CustomDateTimeShardingAlgorithm implements StandardShardingAlgorithm<Comparable<?>> {
+
private static final String DATE_TIME_FORMAT = "datetime.format";
-
+
private static final String TABLE_SUFFIX_FORMAT = "table.suffix.format";
-
+
private static final String DEFAULT_LOWER = "datetime.lower";
-
+
private static final String DEFAULT_UPPER = "datetime.upper";
-
+
private static final String STEP_UNIT = "datetime.step.unit";
-
+
private static final String STEP_AMOUNT = "datetime.step.amount";
-
+
private DateTimeFormatter datetimeFormatter;
-
+
private ChronoUnit stepUnit;
-
+
private int stepAmount;
-
- private volatile boolean init;
-
+
+ private volatile boolean initialized;
+
@Getter
@Setter
private Properties properties = new Properties();
-
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Comparable<?>> shardingValue) {
checkInit();
@@ -95,7 +95,7 @@
.findFirst().orElseThrow(() -> new UnsupportedOperationException(
String.format("failed to shard value %s, and availableTables %s", shardingValue, availableTargetNames)));
}
-
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Comparable<?>> shardingValue) {
checkInit();
@@ -121,31 +121,31 @@
mergeTableIfMatch(end, tables, availableTargetNames);
return tables;
}
-
+
private LocalDateTime parseDateTimeForValue(final String value) {
return LocalDateTime.parse(value.substring(0, properties.getProperty(DATE_TIME_FORMAT).length()), datetimeFormatter);
}
-
+
private String formatForDateTime(final LocalDateTime localDateTime) {
return localDateTime.format(DateTimeFormatter.ofPattern(properties.get(TABLE_SUFFIX_FORMAT).toString()));
}
-
+
private void mergeTableIfMatch(final LocalDateTime dateTime, final Collection<String> tables, final Collection<String> availableTargetNames) {
String suffix = formatForDateTime(dateTime);
availableTargetNames.parallelStream().filter(tableName -> tableName.endsWith(suffix)).findAny().map(tables::add);
}
-
+
private void checkInit() {
- if (!init) {
+ if (!initialized) {
synchronized (this) {
- if (!init) {
+ if (!initialized) {
verifyProperties();
- init = true;
+ initialized = true;
}
}
}
}
-
+
private void verifyProperties() {
Preconditions.checkNotNull(properties.getProperty(DATE_TIME_FORMAT));
Preconditions.checkNotNull(properties.getProperty(TABLE_SUFFIX_FORMAT));
@@ -164,7 +164,7 @@
throw new UnsupportedOperationException("can't apply shard value for default lower/upper values", e);
}
}
-
+
private ChronoUnit generateStepUnit() {
for (ChronoUnit unit : ChronoUnit.values()) {
if (unit.toString().equalsIgnoreCase(properties.getProperty(STEP_UNIT))) {
@@ -174,10 +174,9 @@
throw new UnsupportedOperationException(
String.format("can't find step unit for specified datetime.step.unit prop: %s", properties.getProperty(STEP_UNIT)));
}
-
+
@Override
public String getType() {
return "CUSTOM_DATE_TIME";
}
-
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/DatetimeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/DatetimeShardingAlgorithm.java
index 579a8f4..e80a6d8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/DatetimeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/DatetimeShardingAlgorithm.java
@@ -89,8 +89,7 @@
private void checkProperties() {
Preconditions.checkNotNull(properties.get(PARTITION_SECONDS), "Sharding partition volume cannot be null.");
- Preconditions.checkState(null != properties.get(EPOCH) && checkDatetimePattern(properties.get(EPOCH).toString()),
- "%s pattern is required.", DATETIME_PATTERN);
+ Preconditions.checkState(null != properties.get(EPOCH) && checkDatetimePattern(properties.get(EPOCH).toString()), "%s pattern is required.", DATETIME_PATTERN);
}
private boolean checkDatetimePattern(final String datetime) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/inline/InlineShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/inline/InlineShardingAlgorithm.java
index c9881cd..84a7083 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/inline/InlineShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/inline/InlineShardingAlgorithm.java
@@ -32,10 +32,10 @@
*/
public final class InlineShardingAlgorithm implements StandardShardingAlgorithm<Comparable<?>> {
- private static final String ALLOW_RANGE_QUERY = "allow.range.query.with.inline.sharding";
-
private static final String ALGORITHM_EXPRESSION = "algorithm.expression";
+ private static final String ALLOW_RANGE_QUERY = "allow.range.query.with.inline.sharding";
+
private Properties properties = new Properties();
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
index 4a4b49b..80b5bd8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
@@ -25,40 +25,35 @@
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Map.Entry;
/**
* Abstract range sharding algorithm.
*/
public abstract class AbstractRangeShardingAlgorithm implements StandardShardingAlgorithm<Long> {
-
- private volatile boolean init;
-
- /**
- * getTargetNameByPreciseShardingValue.
- *
- * @param availableTargetNames available data sources or tables's names
- * @param shardingValue sharding value
- * @param partitionRangeMap the mapping of partition and range
- * @return sharding result for data source or table's name
- */
- protected String getTargetNameByPreciseShardingValue(final Collection<String> availableTargetNames,
- final PreciseShardingValue<Long> shardingValue,
- final Map<Integer, Range<Long>> partitionRangeMap) {
- return availableTargetNames.stream().filter(each -> each.endsWith(getPartition(partitionRangeMap, shardingValue.getValue()) + ""))
- .findFirst().orElseThrow(UnsupportedOperationException::new);
+
+ private volatile boolean initialized;
+
+ protected final void checkInit() {
+ if (!initialized) {
+ synchronized (this) {
+ if (!initialized) {
+ initProperties();
+ initialized = true;
+ }
+ }
+ }
}
-
- /**
- * getTargetNameByRangeShardingValue.
- *
- * @param availableTargetNames available data sources or tables's names
- * @param shardingValue sharding value
- * @param partitionRangeMap the mapping of partition and range
- * @return sharding results for data sources or tables's names
- */
- protected Collection<String> getTargetNameByRangeShardingValue(final Collection<String> availableTargetNames,
- final RangeShardingValue<Long> shardingValue,
- final Map<Integer, Range<Long>> partitionRangeMap) {
+
+ protected abstract void initProperties();
+
+ protected final String getTargetNameByPreciseShardingValue(final Collection<String> availableTargetNames,
+ final PreciseShardingValue<Long> shardingValue, final Map<Integer, Range<Long>> partitionRangeMap) {
+ return availableTargetNames.stream().filter(each -> each.endsWith(getPartition(partitionRangeMap, shardingValue.getValue()) + "")).findFirst().orElseThrow(UnsupportedOperationException::new);
+ }
+
+ protected final Collection<String> getTargetNameByRangeShardingValue(final Collection<String> availableTargetNames,
+ final RangeShardingValue<Long> shardingValue, final Map<Integer, Range<Long>> partitionRangeMap) {
Collection<String> result = new LinkedHashSet<>(availableTargetNames.size());
int lowerEndpointPartition = getPartition(partitionRangeMap, shardingValue.getValueRange().lowerEndpoint());
int upperEndpointPartition = getPartition(partitionRangeMap, shardingValue.getValueRange().upperEndpoint());
@@ -71,28 +66,9 @@
}
return result;
}
-
- /**
- * check properties whether init.
- */
- protected void checkInit() {
- if (!init) {
- synchronized (this) {
- if (!init) {
- initProperties();
- init = true;
- }
- }
- }
- }
-
- /**
- * init properties.
- */
- protected abstract void initProperties();
-
+
private Integer getPartition(final Map<Integer, Range<Long>> partitionRangeMap, final Long value) {
- for (Map.Entry<Integer, Range<Long>> entry : partitionRangeMap.entrySet()) {
+ for (Entry<Integer, Range<Long>> entry : partitionRangeMap.entrySet()) {
if (entry.getValue().contains(value)) {
return entry.getKey();
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/CustomRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/CustomRangeShardingAlgorithm.java
index b551028..1d970e9 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/CustomRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/CustomRangeShardingAlgorithm.java
@@ -50,32 +50,27 @@
* </p>
*/
public final class CustomRangeShardingAlgorithm extends AbstractRangeShardingAlgorithm {
-
+
private static final String PARTITION_RANGES = "partition.ranges";
-
+
private Map<Integer, Range<Long>> partitionRangeMap;
-
+
@Getter
@Setter
private Properties properties = new Properties();
-
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
checkInit();
return getTargetNameByPreciseShardingValue(availableTargetNames, shardingValue, partitionRangeMap);
}
-
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Long> shardingValue) {
checkInit();
return getTargetNameByRangeShardingValue(availableTargetNames, shardingValue, partitionRangeMap);
}
-
- @Override
- public String getType() {
- return "CUSTOM_RANGE";
- }
-
+
@Override
public void initProperties() {
Preconditions.checkNotNull(properties.get(PARTITION_RANGES), "Custom range sharding algorithm partition ranges cannot be null.");
@@ -96,4 +91,9 @@
}
}
}
+
+ @Override
+ public String getType() {
+ return "CUSTOM_RANGE";
+ }
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/StandardRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/StandardRangeShardingAlgorithm.java
index b4f56ea..ad705ed 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/StandardRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/strategy/algorithm/sharding/range/StandardRangeShardingAlgorithm.java
@@ -33,6 +33,7 @@
/**
* Standard range sharding algorithm.
+ *
* <p>
* Standard range sharding algorithm is similar to the rule of partition table, but it can only be split by the same size.
* User can specify the range by setting `partition.lower`, `partition.upper` and `partition.volume` parameters.
@@ -45,36 +46,31 @@
* </p>
*/
public final class StandardRangeShardingAlgorithm extends AbstractRangeShardingAlgorithm {
-
+
private static final String PARTITION_LOWER = "partition.lower";
-
+
private static final String PARTITION_UPPER = "partition.upper";
-
+
private static final String PARTITION_VOLUME = "partition.volume";
-
+
private Map<Integer, Range<Long>> partitionRangeMap;
-
+
@Getter
@Setter
private Properties properties = new Properties();
-
+
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Long> shardingValue) {
checkInit();
return getTargetNameByPreciseShardingValue(availableTargetNames, shardingValue, partitionRangeMap);
}
-
+
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Long> shardingValue) {
checkInit();
return getTargetNameByRangeShardingValue(availableTargetNames, shardingValue, partitionRangeMap);
}
-
- @Override
- public String getType() {
- return "STANDARD_RANGE";
- }
-
+
@Override
public void initProperties() {
Preconditions.checkNotNull(properties.get(PARTITION_LOWER), "Standard range sharding algorithm partition lower cannot be null.");
@@ -92,4 +88,9 @@
}
partitionRangeMap.put(partitionSize + 1, Range.atLeast(upper));
}
+
+ @Override
+ public String getType() {
+ return "STANDARD_RANGE";
+ }
}