You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/03/15 14:01:34 UTC

[GitHub] [shardingsphere] xiaoshen11 commented on a change in pull request #9660: Add JAVA-API each versions of the document

xiaoshen11 commented on a change in pull request #9660:
URL: https://github.com/apache/shardingsphere/pull/9660#discussion_r594360645



##########
File path: docs/document/content/user-manual/shardingsphere-jdbc/configuration/java-api/change-history.en.md
##########
@@ -31,4 +31,199 @@ Attributes:
 | replicaDataSourceNames (+) | Collection\<String\> | Replica sources source name list               | -                                  |
 | loadBalancerName (?)       | String               | Load balance algorithm name of replica sources | Round robin load balance algorithm |
 
-Please refer to [Built-in Load Balance Algorithm List](/en/user-manual/shardingsphere-jdbc/configuration/built-in-algorithm/load-balance) for more details about type of algorithm.
+Please refer to [Built-in Load Balance Algorithm List](/docs/document/content/user-manual/shardingsphere-jdbc/configuration/built-in-algorithm/load-balance.en.md) for more details about type of algorithm.
+
+## ShardingSphere-4.x
+
+### 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 |
+
+## ShardingSphere-3.x
+
+### Read-Write Split
+
+#### MasterSlaveDataSourceFactory
+
+| *Name*                | *DataType*                   | *Description*                       |
+| :-------------------- | :--------------------------- | :---------------------------------- |
+| dataSourceMap         | Map<String, DataSource>      | Map of data sources and their names |
+| masterSlaveRuleConfig | MasterSlaveRuleConfiguration | Master slave rule configuration     |
+| configMap (?)         | Map<String, Object>          | Config map                          |
+| props (?)             | Properties                   | Properties                          |
+
+#### MasterSlaveRuleConfiguration
+
+| *Name*                   | *DataType*                      | *Description*                    |
+| :----------------------- | :------------------------------ | :------------------------------- |
+| name                     | String                          | Name of master slave data source |
+| masterDataSourceName     | String                          | Name of master data source       |
+| slaveDataSourceNames     | Collection<String>              | Names of Slave data sources      |
+| loadBalanceAlgorithm (?) | MasterSlaveLoadBalanceAlgorithm | Load balance algorithm           |
+
+#### configMap
+
+User-defined arguments.
+
+#### PropertiesConstant
+
+Enumeration of properties.
+
+| *Name*                             | *DataType* | *Description*                                                |
+| :--------------------------------- | :--------- | :----------------------------------------------------------- |
+| sql.show (?)                       | boolean    | To show SQLS or not, default value: false                    |
+| executor.size (?)                  | int        | The number of working threads, default value: CPU count      |
+| max.connections.size.per.query (?) | int        | Max connection size for every query to every actual database. default value: 1 |
+| check.table.metadata.enabled (?)   | boolean    | Check the metadata consistency of all the tables, default value : false |
+
+## ShardingSphere-2.x
+
+### Read-Write Split
+
+#### concept
+
+In order to relieve the pressure on the database, the write and read operations are separated into different data sources. The write library is called the master library, and the read library is called the slave library. One master library can be configured with multiple slave libraries.
+
+#### Support item
+
+1. Provides a read-write separation configuration with one master and multiple slaves, which can be used independently or with sub-databases and sub-meters.
+2. Independent use of read-write separation to support SQL transparent transmission.
+3. In the same thread and the same database connection, if there is a write operation, subsequent read operations will be read from the main library to ensure data consistency.
+4. Spring namespace.
+5. Hint-based mandatory main library routing.
+
+#### Unsupported item
+
+1. Data synchronization between the master library and the slave library.
+2. Data inconsistency caused by the data synchronization delay of the master library and the slave library.
+3. Double writing or multiple writing in the main library.
+
+#### Code development example
+
+##### only read-write split
+
+```java
+// 构建读写分离数据源, 读写分离数据源实现了DataSource接口, 可直接当做数据源处理. masterDataSource, slaveDataSource0, slaveDataSource1等为使用DBCP等连接池配置的真实数据源
+Map<String, DataSource> dataSourceMap = new HashMap<>();
+dataSourceMap.put("masterDataSource", masterDataSource);
+dataSourceMap.put("slaveDataSource0", slaveDataSource0);
+dataSourceMap.put("slaveDataSource1", slaveDataSource1);
+
+// 构建读写分离配置
+MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration();
+masterSlaveRuleConfig.setName("ms_ds");
+masterSlaveRuleConfig.setMasterDataSourceName("masterDataSource");
+masterSlaveRuleConfig.getSlaveDataSourceNames().add("slaveDataSource0");
+masterSlaveRuleConfig.getSlaveDataSourceNames().add("slaveDataSource1");
+
+DataSource dataSource = MasterSlaveDataSourceFactory.createDataSource(dataSourceMap, masterSlaveRuleConfig);
+```
+
+##### sharding table and database + read-write split
+
+```java
+// 构建读写分离数据源, 读写分离数据源实现了DataSource接口, 可直接当做数据源处理. masterDataSource0, slaveDataSource00, slaveDataSource01等为使用DBCP等连接池配置的真实数据源
+Map<String, DataSource> dataSourceMap = new HashMap<>();
+dataSourceMap.put("masterDataSource0", masterDataSource0);
+dataSourceMap.put("slaveDataSource00", slaveDataSource00);
+dataSourceMap.put("slaveDataSource01", slaveDataSource01);
+
+dataSourceMap.put("masterDataSource1", masterDataSource1);
+dataSourceMap.put("slaveDataSource10", slaveDataSource10);
+dataSourceMap.put("slaveDataSource11", slaveDataSource11);
+
+// 构建读写分离配置
+MasterSlaveRuleConfiguration masterSlaveRuleConfig0 = new MasterSlaveRuleConfiguration();
+masterSlaveRuleConfig0.setName("ds_0");
+masterSlaveRuleConfig0.setMasterDataSourceName("masterDataSource0");
+masterSlaveRuleConfig0.getSlaveDataSourceNames().add("slaveDataSource00");
+masterSlaveRuleConfig0.getSlaveDataSourceNames().add("slaveDataSource01");
+
+MasterSlaveRuleConfiguration masterSlaveRuleConfig1 = new MasterSlaveRuleConfiguration();
+masterSlaveRuleConfig1.setName("ds_1");
+masterSlaveRuleConfig1.setMasterDataSourceName("masterDataSource1");
+masterSlaveRuleConfig1.getSlaveDataSourceNames().add("slaveDataSource10");
+masterSlaveRuleConfig1.getSlaveDataSourceNames().add("slaveDataSource11");
+
+// 通过ShardingSlaveDataSourceFactory继续创建ShardingDataSource
+ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
+shardingRuleConfig.getMasterSlaveRuleConfigs().add(masterSlaveRuleConfig0);
+shardingRuleConfig.getMasterSlaveRuleConfigs().add(masterSlaveRuleConfig1);
+
+DataSource dataSource = ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingRuleConfig);
+```
+
+## ShardingSphere-1.x
+
+### Read-Write Split
+
+#### concept
+
+In order to relieve the pressure on the database, the write and read operations are separated into different data sources. The write library is called the master library, and the read library is called the slave library. One master library can be configured with multiple slave libraries.
+
+#### Support item
+
+1. Provides a read-write separation configuration with one master and multiple slaves, which can be used independently or with sub-databases and sub-meters.
+2. In the same thread and the same database connection, if there is a write operation, subsequent read operations will be read from the main library to ensure data consistency.
+3. Spring namespace.
+4. Hint-based mandatory main library routing.
+
+#### Unsupported item
+
+1. Data synchronization between the master library and the slave library.
+2. Data inconsistency caused by the data synchronization delay of the master library and the slave library.
+3. Double writing or multiple writing in the main library.
+
+#### Code development example
+
+```java
+// 构建读写分离数据源, 读写分离数据源实现了DataSource接口, 可直接当做数据源处理. masterDataSource0, slaveDataSource00, slaveDataSource01等为使用DBCP等连接池配置的真实数据源

Review comment:
       have translated




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org