提交 c8a42fed 编写于 作者: T terrymanu

update sharding-jdbc/configuration/overview

上级 d60bd2c5
......@@ -10,3 +10,31 @@ chapter = true
配置是整个Sharding-JDBC的核心,是Sharding-JDBC中唯一与应用开发者打交道的模块。配置模块也是Sharding-JDBC的门户,通过它可以快速清晰的理解Sharding-JDBC所提供的功能。
本部分是Sharding-JDBC的配置参考手册,需要时可当做字典查阅。
Sharding-JDBC提供了4种配置方式,用于不同的使用场景。通过配置,应用开发者可以灵活的使用分库分表、读写分离以及分库分表 + 读写分离共用。
![配置领域模型类图](http://ovfotjrsi.bkt.clouddn.com/docs/img/config_domain.png)
## 工厂方法API
图中黄色部分表示的是Sharding-JDBC的入口API,采用工厂方法的形式提供。
目前有ShardingDataSourceFactory和MasterSlaveDataSourceFactory两个工厂类。ShardingDataSourceFactory用于创建分库分表或分库分表+读写分离的JDBC驱动,MasterSlaveDataSourceFactory用于创建独立使用读写分离的JDBC驱动。
## 配置对象
图中蓝色部分表示的是Sharding-JDBC的配置对象,提供灵活多变的配置方式。
ShardingRuleConfiguration是分库分表配置的核心和入口,它可以包含多个TableRuleConfiguration和MasterSlaveRuleConfiguration。每一组相同规则分片的表配置一个TableRuleConfiguration。如果需要分库分表和读写分离共同使用,每一个读写分离的逻辑库配置一个MasterSlaveRuleConfiguration。
每个TableRuleConfiguration对应一个ShardingStrategyConfiguration,它有5中实现类可供选择。
仅读写分离使用MasterSlaveRuleConfiguration即可。
## 内部对象
图中红色部分表示的是内部对象,由Sharding-JDBC内部使用,应用开发者无需关注。Sharding-JDBC通过ShardingRuleConfiguration和MasterSlaveRuleConfiguration生成真正供ShardingDataSource和MasterSlaveDataSource使用的规则对象。ShardingDataSource和MasterSlaveDataSource实现了DataSource接口,是JDBC的完整实现方案。
## 初始化流程
1. 配置Configuration对象。
2. 通过Factory对象将Configuration对象转化为Rule对象。
3. 通过Factory对象将Rule对象与DataSource对象装配。
4. Sharding-JDBC使用DataSource对象进行分库。
+++
toc = true
title = "Java配置"
weight = 2
weight = 1
+++
## JAVA配置
......
+++
toc = true
title = "概览"
weight = 1
+++
![配置领域模型类图](http://ovfotjrsi.bkt.clouddn.com/docs/img/config_domain.png)
## 工厂方法API
图中黄色部分表示的是Sharding-JDBC的入口API,采用工厂方法的形式提供。
目前有ShardingDataSourceFactory和MasterSlaveDataSourceFactory两个工厂类。ShardingDataSourceFactory用于创建分库分表或分库分表+读写分离的JDBC驱动,MasterSlaveDataSourceFactory用于创建独立使用读写分离的JDBC驱动。
## 配置对象
图中蓝色部分表示的是Sharding-JDBC的配置对象,提供灵活多变的配置方式。
ShardingRuleConfiguration是分库分表配置的核心和入口,它可以包含多个TableRuleConfiguration和MasterSlaveRuleConfiguration。每一组相同规则分片的表配置一个TableRuleConfiguration。如果需要分库分表和读写分离共同使用,每一个读写分离的逻辑库配置一个MasterSlaveRuleConfiguration。
每个TableRuleConfiguration对应一个ShardingStrategyConfiguration,它有5中实现类可供选择。关于分片策略使用的细节,请阅读[分库分表](/02-guide/sharding/)
仅读写分离使用MasterSlaveRuleConfiguration即可。
## 内部对象
图中红色部分表示的是内部对象,由Sharding-JDBC内部使用,应用开发者无需关注。Sharding-JDBC通过ShardingRuleConfiguration和MasterSlaveRuleConfiguration生成真正供ShardingDataSource和MasterSlaveDataSource使用的规则对象。ShardingDataSource和MasterSlaveDataSource实现了DataSource接口,是JDBC的完整实现方案。
## 初始化流程
1. 配置Configuration对象。
2. 通过Factory对象将Configuration对象转化为Rule对象。
3. 通过Factory对象将Rule对象与DataSource对象装配。
4. Sharding-JDBC使用DataSource对象进行分库分表和读写分离。
\ No newline at end of file
+++
toc = true
title = "Spring Boot配置"
weight = 4
weight = 3
+++
## Spring Boot配置
......
+++
toc = true
title = "Spring命名空间配置"
weight = 5
weight = 4
+++
## Spring命名空间配置
......
+++
toc = true
title = "YAML配置"
weight = 3
weight = 2
+++
......
......@@ -10,3 +10,53 @@ chapter = true
Configuration is core module of Sharding-JDBC, it is only one module which end-users need to study. Configuration module is main entrance of Sharding-JDBC, end-users can use it to know what features that Sharding-JDBC supported.
This section is a configuration manual, users can use it as a dictionary, may lookup some configuration if necessary.
Sharding-JDBC provides 4 types of configurations. User can use sharding, read-write-splitting or sharding + read-write-splitting together.
![The class diagrams for Domain Model](http://ovfotjrsi.bkt.clouddn.com/docs/img/config_domain.png)
## The Factory Method Pattern
The yellow part of the figure represents the Sharding-JDBC entry API, which is provided in the form of factory methods. It includes ShardingDataSourceFactory factory class and MasterSlaveDataSourceFactory factory class. ShardingDataSourceFactory is used to create JDBC driver for Sharding + Read-write splitting, but MasterSlaveDataSourceFactory is to create JDBC driver only for Read-write splitting.
## Configuration Object
The blue part of the figure shows the sharding-jdbc configuration objects. ShardingRuleConfiguration is the entrance to configure the Sharding strategy, and it can include multiple TableRuleConfiguration and MasterSlaveRuleConfiguration. A TableRuleConfiguration is configured for a group of tables with the same sharding strategy. If both Sharding and Read-write splitting are used, you need to set MasterSlaveRuleConfiguration for each logic database used to do Read-write splitting. There is one-to-one correspondence between each TableRuleConfiguration and each ShardingStrategyConfiguration which consists of 5 kinds of strategies to choose from. For details on the use of sharding strategies, please read the [Database Sharding] (/02-guide/sharding/).
MasterSlaveRuleConfiguration is only used for Read-write splitting.
## Internal Object
The red part of the figure represents internal objects, which are used by Sharding-JDBC itself. Therefore users do not look inside those objects. By using ShardingRuleConfiguration and MasterSlaveRuleConfiguration, Sharding-JDBC provides final rules to ShardingDataSource and MasterSlaveDataSource which implement the DataSource interface.
## Operation Steps
1. Create Configuration object.
2. The Configuration object is transformed into the Rule object through the Factory object.
3. The Rule object is bound to the DataSource object through the Factory object.
4. Sharding-JDBC operates Sharding and Read-write splitting on DataSource object.
This section explains configuration domain models in Sharding-JDBC. The following class diagram is about those domain models in Sharding-JDBC.
![The class diagrams for Domain Model](http://ovfotjrsi.bkt.clouddn.com/docs/img/config_domain.png)
## The Factory Method Pattern
The yellow part of the figure represents the Sharding-JDBC entry API, which is provided in the form of factory methods. It includes ShardingDataSourceFactory factory class and MasterSlaveDataSourceFactory factory class. ShardingDataSourceFactory is used to create JDBC driver for Sharding + Read-write splitting, but MasterSlaveDataSourceFactory is to create JDBC driver only for Read-write splitting.
## Configuration Object
The blue part of the figure shows the sharding-jdbc configuration objects. ShardingRuleConfiguration is the entrance to configure the Sharding strategy, and it can include multiple TableRuleConfiguration and MasterSlaveRuleConfiguration. A TableRuleConfiguration is configured for a group of tables with the same sharding strategy. If both Sharding and Read-write splitting are used, you need to set MasterSlaveRuleConfiguration for each logic database used to do Read-write splitting. There is one-to-one correspondence between each TableRuleConfiguration and each ShardingStrategyConfiguration which consists of 5 kinds of strategies to choose from. For details on the use of sharding strategies, please read the [Database Sharding] (/02-guide/sharding/).
MasterSlaveRuleConfiguration is only used for Read-write splitting.
## Internal Object
The red part of the figure represents internal objects, which are used by Sharding-JDBC itself. Therefore users do not look inside those objects. By using ShardingRuleConfiguration and MasterSlaveRuleConfiguration, Sharding-JDBC provides final rules to ShardingDataSource and MasterSlaveDataSource which implement the DataSource interface.
## Operation Steps
1. Create Configuration object.
1. The Configuration object is transformed into the Rule object through the Factory object.
1. The Rule object is bound to the DataSource object through the Factory object.
1. Sharding-JDBC operates Sharding and Read-write splitting on DataSource object.
+++
toc = true
title = "Java"
weight = 2
weight = 1
+++
## JAVA configuration
......
+++
toc = true
title = "Overview"
weight = 1
+++
This section explains configuration domain models in Sharding-JDBC. The following class diagram is about those domain models in Sharding-JDBC.
![The class diagrams for Domain Model](http://ovfotjrsi.bkt.clouddn.com/docs/img/config_domain.png)
## The Factory Method Pattern
The yellow part of the figure represents the Sharding-JDBC entry API, which is provided in the form of factory methods. It includes ShardingDataSourceFactory factory class and MasterSlaveDataSourceFactory factory class. ShardingDataSourceFactory is used to create JDBC driver for Sharding + Read-write splitting, but MasterSlaveDataSourceFactory is to create JDBC driver only for Read-write splitting.
## Configuration Object
The blue part of the figure shows the sharding-jdbc configuration objects. ShardingRuleConfiguration is the entrance to configure the Sharding strategy, and it can include multiple TableRuleConfiguration and MasterSlaveRuleConfiguration. A TableRuleConfiguration is configured for a group of tables with the same sharding strategy. If both Sharding and Read-write splitting are used, you need to set MasterSlaveRuleConfiguration for each logic database used to do Read-write splitting. There is one-to-one correspondence between each TableRuleConfiguration and each ShardingStrategyConfiguration which consists of 5 kinds of strategies to choose from. For details on the use of sharding strategies, please read the [Database Sharding] (/02-guide/sharding/).
MasterSlaveRuleConfiguration is only used for Read-write splitting.
## Internal Object
The red part of the figure represents internal objects, which are used by Sharding-JDBC itself. Therefore users do not look inside those objects. By using ShardingRuleConfiguration and MasterSlaveRuleConfiguration, Sharding-JDBC provides final rules to ShardingDataSource and MasterSlaveDataSource which implement the DataSource interface.
## Operation Steps
1. Create Configuration object.
2. The Configuration object is transformed into the Rule object through the Factory object.
3. The Rule object is bound to the DataSource object through the Factory object.
4. Sharding-JDBC operates Sharding and Read-write splitting on DataSource object.
This section explains configuration domain models in Sharding-JDBC. The following class diagram is about those domain models in Sharding-JDBC.
![The class diagrams for Domain Model](http://ovfotjrsi.bkt.clouddn.com/docs/img/config_domain.png)
## The Factory Method Pattern
The yellow part of the figure represents the Sharding-JDBC entry API, which is provided in the form of factory methods. It includes ShardingDataSourceFactory factory class and MasterSlaveDataSourceFactory factory class. ShardingDataSourceFactory is used to create JDBC driver for Sharding + Read-write splitting, but MasterSlaveDataSourceFactory is to create JDBC driver only for Read-write splitting.
## Configuration Object
The blue part of the figure shows the sharding-jdbc configuration objects. ShardingRuleConfiguration is the entrance to configure the Sharding strategy, and it can include multiple TableRuleConfiguration and MasterSlaveRuleConfiguration. A TableRuleConfiguration is configured for a group of tables with the same sharding strategy. If both Sharding and Read-write splitting are used, you need to set MasterSlaveRuleConfiguration for each logic database used to do Read-write splitting. There is one-to-one correspondence between each TableRuleConfiguration and each ShardingStrategyConfiguration which consists of 5 kinds of strategies to choose from. For details on the use of sharding strategies, please read the [Database Sharding] (/02-guide/sharding/).
MasterSlaveRuleConfiguration is only used for Read-write splitting.
## Internal Object
The red part of the figure represents internal objects, which are used by Sharding-JDBC itself. Therefore users do not look inside those objects. By using ShardingRuleConfiguration and MasterSlaveRuleConfiguration, Sharding-JDBC provides final rules to ShardingDataSource and MasterSlaveDataSource which implement the DataSource interface.
## Operation Steps
1. Create Configuration object.
2. The Configuration object is transformed into the Rule object through the Factory object.
3. The Rule object is bound to the DataSource object through the Factory object.
4. Sharding-JDBC operates Sharding and Read-write splitting on DataSource object.
\ No newline at end of file
+++
toc = true
title = "Spring Boot"
weight = 4
weight = 3
+++
## Spring Boot configuration
......
+++
toc = true
title = "Spring namespace"
weight = 5
weight = 4
+++
## Spring namespace configuration
......
+++
toc = true
title = "YAML"
weight = 3
weight = 2
+++
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册