Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
5da9e194
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5da9e194
编写于
5月 14, 2020
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix orchestration spring boot starter
上级
5c12fc61
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
225 addition
and
122 deletion
+225
-122
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
...ion/spring/boot/OrchestrationSpringBootConfiguration.java
+2
-2
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/sharding/OrchestrationSpringBootRuleConfigurationsYamlSwapper.java
...OrchestrationSpringBootRuleConfigurationsYamlSwapper.java
+81
-0
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/sharding/OrchestrationSpringBootRulesConfigurationProperties.java
.../OrchestrationSpringBootRulesConfigurationProperties.java
+15
-3
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/type/OrchestrationSpringBootRegistryEncryptTest.java
...boot/type/OrchestrationSpringBootRegistryEncryptTest.java
+22
-19
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/type/OrchestrationSpringBootRegistryMasterSlaveTest.java
.../type/OrchestrationSpringBootRegistryMasterSlaveTest.java
+33
-31
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/type/OrchestrationSpringBootRegistryShardingTest.java
...oot/type/OrchestrationSpringBootRegistryShardingTest.java
+71
-66
sharding-spring/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/spring/boot/sharding/SpringBootRuleConfigurationsYamlSwapper.java
...oot/sharding/SpringBootRuleConfigurationsYamlSwapper.java
+1
-1
未找到文件。
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.java
浏览文件 @
5da9e194
...
...
@@ -25,11 +25,11 @@ import org.apache.shardingsphere.orchestration.center.config.OrchestrationConfig
import
org.apache.shardingsphere.orchestration.center.yaml.config.YamlCenterRepositoryConfiguration
;
import
org.apache.shardingsphere.orchestration.center.yaml.swapper.CenterRepositoryConfigurationYamlSwapper
;
import
org.apache.shardingsphere.sharding.core.strategy.algorithm.sharding.inline.InlineExpressionParser
;
import
org.apache.shardingsphere.sharding.core.yaml.swapper.root.RuleRootConfigurationsYamlSwapper
;
import
org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingSphereDataSource
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.internal.datasource.OrchestrationShardingSphereDataSource
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.common.SpringBootRootConfigurationProperties
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.sharding.LocalShardingRuleCondition
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.sharding.OrchestrationSpringBootRuleConfigurationsYamlSwapper
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.sharding.OrchestrationSpringBootRulesConfigurationProperties
;
import
org.apache.shardingsphere.spring.boot.datasource.DataSourcePropertiesSetterHolder
;
import
org.apache.shardingsphere.spring.boot.util.DataSourceUtil
;
...
...
@@ -107,7 +107,7 @@ public class OrchestrationSpringBootConfiguration implements EnvironmentAware {
@Conditional
(
LocalShardingRuleCondition
.
class
)
public
DataSource
shardingSphereDataSourceByLocal
(
final
OrchestrationConfiguration
orchestrationConfiguration
)
throws
SQLException
{
return
new
OrchestrationShardingSphereDataSource
(
new
ShardingSphereDataSource
(
dataSourceMap
,
new
RuleRoot
ConfigurationsYamlSwapper
().
swap
(
rules
),
root
.
getProps
()),
orchestrationConfiguration
);
new
ShardingSphereDataSource
(
dataSourceMap
,
new
OrchestrationSpringBootRule
ConfigurationsYamlSwapper
().
swap
(
rules
),
root
.
getProps
()),
orchestrationConfiguration
);
}
/**
...
...
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/sharding/OrchestrationSpringBootRuleConfigurationsYamlSwapper.java
0 → 100644
浏览文件 @
5da9e194
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.sharding
;
import
org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration
;
import
org.apache.shardingsphere.encrypt.yaml.swapper.EncryptRuleConfigurationYamlSwapper
;
import
org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration
;
import
org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration
;
import
org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
;
import
org.apache.shardingsphere.sharding.core.yaml.swapper.MasterSlaveRuleConfigurationYamlSwapper
;
import
org.apache.shardingsphere.sharding.core.yaml.swapper.ShadowRuleConfigurationYamlSwapper
;
import
org.apache.shardingsphere.sharding.core.yaml.swapper.ShardingRuleConfigurationYamlSwapper
;
import
org.apache.shardingsphere.underlying.common.config.RuleConfiguration
;
import
org.apache.shardingsphere.underlying.common.yaml.swapper.YamlSwapper
;
import
java.util.Collection
;
import
java.util.LinkedList
;
/**
* Orchestration Spring boot root configurations YAML swapper.
*/
public
final
class
OrchestrationSpringBootRuleConfigurationsYamlSwapper
implements
YamlSwapper
<
OrchestrationSpringBootRulesConfigurationProperties
,
Collection
<
RuleConfiguration
>>
{
private
final
ShardingRuleConfigurationYamlSwapper
shardingRuleConfigurationYamlSwapper
=
new
ShardingRuleConfigurationYamlSwapper
();
private
final
MasterSlaveRuleConfigurationYamlSwapper
masterSlaveRuleConfigurationYamlSwapper
=
new
MasterSlaveRuleConfigurationYamlSwapper
();
private
final
EncryptRuleConfigurationYamlSwapper
encryptRuleConfigurationYamlSwapper
=
new
EncryptRuleConfigurationYamlSwapper
();
private
final
ShadowRuleConfigurationYamlSwapper
shadowRuleConfigurationYamlSwapper
=
new
ShadowRuleConfigurationYamlSwapper
();
@Override
public
OrchestrationSpringBootRulesConfigurationProperties
swap
(
final
Collection
<
RuleConfiguration
>
data
)
{
OrchestrationSpringBootRulesConfigurationProperties
result
=
new
OrchestrationSpringBootRulesConfigurationProperties
();
for
(
RuleConfiguration
each
:
data
)
{
if
(
each
instanceof
ShardingRuleConfiguration
)
{
result
.
setShardingRule
(
shardingRuleConfigurationYamlSwapper
.
swap
((
ShardingRuleConfiguration
)
each
));
}
else
if
(
each
instanceof
MasterSlaveRuleConfiguration
)
{
result
.
setMasterSlaveRule
(
masterSlaveRuleConfigurationYamlSwapper
.
swap
((
MasterSlaveRuleConfiguration
)
each
));
}
else
if
(
each
instanceof
EncryptRuleConfiguration
)
{
result
.
setEncryptRule
(
encryptRuleConfigurationYamlSwapper
.
swap
((
EncryptRuleConfiguration
)
each
));
}
else
if
(
each
instanceof
ShadowRuleConfiguration
)
{
result
.
setShadowRule
(
shadowRuleConfigurationYamlSwapper
.
swap
((
ShadowRuleConfiguration
)
each
));
}
}
return
result
;
}
@Override
public
Collection
<
RuleConfiguration
>
swap
(
final
OrchestrationSpringBootRulesConfigurationProperties
configurations
)
{
Collection
<
RuleConfiguration
>
result
=
new
LinkedList
<>();
if
(
null
!=
configurations
.
getShardingRule
())
{
result
.
add
(
shardingRuleConfigurationYamlSwapper
.
swap
(
configurations
.
getShardingRule
()));
}
if
(
null
!=
configurations
.
getMasterSlaveRule
())
{
result
.
add
(
masterSlaveRuleConfigurationYamlSwapper
.
swap
(
configurations
.
getMasterSlaveRule
()));
}
if
(
null
!=
configurations
.
getEncryptRule
())
{
result
.
add
(
encryptRuleConfigurationYamlSwapper
.
swap
(
configurations
.
getEncryptRule
()));
}
if
(
null
!=
configurations
.
getShadowRule
())
{
result
.
add
(
shadowRuleConfigurationYamlSwapper
.
swap
(
configurations
.
getShadowRule
()));
}
return
result
;
}
}
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/sharding/OrchestrationSpringBootRulesConfigurationProperties.java
浏览文件 @
5da9e194
...
...
@@ -19,14 +19,26 @@ package org.apache.shardingsphere.shardingjdbc.orchestration.spring.boot.shardin
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.shardingsphere.sharding.core.yaml.config.YamlRootRuleConfigurations
;
import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration
;
import
org.apache.shardingsphere.sharding.core.yaml.config.masterslave.YamlMasterSlaveRuleConfiguration
;
import
org.apache.shardingsphere.sharding.core.yaml.config.shadow.YamlShadowRuleConfiguration
;
import
org.apache.shardingsphere.sharding.core.yaml.config.sharding.YamlShardingRuleConfiguration
;
import
org.apache.shardingsphere.underlying.common.yaml.config.YamlConfiguration
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
*
Spring boot rules configuration properties for orchestration
.
*
Orchestration spring boot rules configuration properties
.
*/
@ConfigurationProperties
(
prefix
=
"spring.shardingsphere.rules"
)
@Getter
@Setter
public
final
class
OrchestrationSpringBootRulesConfigurationProperties
extends
YamlRootRuleConfigurations
{
public
class
OrchestrationSpringBootRulesConfigurationProperties
implements
YamlConfiguration
{
private
YamlShardingRuleConfiguration
shardingRule
;
private
YamlMasterSlaveRuleConfiguration
masterSlaveRule
;
private
YamlEncryptRuleConfiguration
encryptRule
;
private
YamlShadowRuleConfiguration
shadowRule
;
}
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/type/OrchestrationSpringBootRegistryEncryptTest.java
浏览文件 @
5da9e194
...
...
@@ -52,25 +52,28 @@ public class OrchestrationSpringBootRegistryEncryptTest {
public
static
void
init
()
{
EmbedTestingServer
.
start
();
TestCenterRepository
testCenter
=
new
TestCenterRepository
();
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/datasource"
,
"dataSource: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 100\n"
+
" password: ''\n"
+
" username: sa\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/rule"
,
"encryptRule:\n encryptors:\n"
+
" order_encrypt:\n"
+
" props:\n"
+
" aes.key.value: '123456'\n"
+
" type: aes\n"
+
" tables:\n"
+
" t_order:\n"
+
" columns:\n"
+
" user_id:\n"
+
" cipherColumn: user_id\n"
+
" encryptor: order_encrypt\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/datasource"
,
""
+
"dataSource: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 100\n"
+
" password: ''\n"
+
" username: sa\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/rule"
,
""
+
"rules:\n"
+
"- !!org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration\n"
+
" encryptors:\n"
+
" order_encrypt:\n"
+
" props:\n"
+
" aes.key.value: '123456'\n"
+
" type: aes\n"
+
" tables:\n"
+
" t_order:\n"
+
" columns:\n"
+
" user_id:\n"
+
" cipherColumn: user_id\n"
+
" encryptor: order_encrypt\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/props"
,
"sql.show: 'true'\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/registry/datasources"
,
""
);
}
...
...
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/type/OrchestrationSpringBootRegistryMasterSlaveTest.java
浏览文件 @
5da9e194
...
...
@@ -52,37 +52,39 @@ public class OrchestrationSpringBootRegistryMasterSlaveTest {
public
static
void
init
()
{
EmbedTestingServer
.
start
();
TestCenterRepository
testCenter
=
new
TestCenterRepository
();
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/datasource"
,
"ds_master: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: root\n"
+
"ds_slave_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: root\n"
+
"ds_slave_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: root\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/rule"
,
"masterSlaveRule:\n"
+
" dataSources:\n"
+
" ds_ms:\n"
+
" loadBalanceAlgorithmType: ROUND_ROBIN\n"
+
" masterDataSourceName: ds_master\n"
+
" name: ds_ms\n"
+
" slaveDataSourceNames: \n"
+
" - ds_slave_0\n"
+
" - ds_slave_1\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/datasource"
,
""
+
"ds_master: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: root\n"
+
"ds_slave_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:demo_ds_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: root\n"
+
"ds_slave_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:demo_ds_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: root\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/rule"
,
""
+
"rules:\n"
+
"- !!org.apache.shardingsphere.sharding.core.yaml.config.masterslave.YamlMasterSlaveRuleConfiguration\n"
+
" dataSources:\n"
+
" ds_ms:\n"
+
" loadBalanceAlgorithmType: ROUND_ROBIN\n"
+
" masterDataSourceName: ds_master\n"
+
" name: ds_ms\n"
+
" slaveDataSourceNames: \n"
+
" - ds_slave_0\n"
+
" - ds_slave_1\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/props"
,
"{}\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/registry/datasources"
,
""
);
}
...
...
sharding-spring/sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/test/java/org/apache/shardingsphere/shardingjdbc/orchestration/spring/boot/type/OrchestrationSpringBootRegistryShardingTest.java
浏览文件 @
5da9e194
...
...
@@ -60,72 +60,77 @@ public class OrchestrationSpringBootRegistryShardingTest {
public
static
void
init
()
{
EmbedTestingServer
.
start
();
TestCenterRepository
testCenter
=
new
TestCenterRepository
();
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/datasource"
,
"ds: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: sa\n"
+
"ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: sa\n"
+
"ds_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: sa\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/rule"
,
"shardingRule:\n"
+
" bindingTables:\n"
+
" - t_order\n"
+
" - t_order_item\n"
+
" broadcastTables:\n"
+
" - t_config\n"
+
" defaultDatabaseStrategy:\n"
+
" standard:\n"
+
" shardingAlgorithm:\n"
+
" type: INLINE\n"
+
" props:\n"
+
" algorithm.expression: ds_${user_id % 2}\n"
+
" shardingColumn: user_id\n"
+
" tables:\n"
+
" t_order:\n"
+
" actualDataNodes: ds_${0..1}.t_order_${0..1}\n"
+
" keyGenerator:\n"
+
" column: order_id\n"
+
" props:\n"
+
" worker.id: '123'\n"
+
" type: SNOWFLAKE\n"
+
" logicTable: t_order\n"
+
" tableStrategy:\n"
+
" standard:\n"
+
" shardingAlgorithm:\n"
+
" type: INLINE\n"
+
" props:\n"
+
" algorithm.expression: t_order_${order_id % 2}\n"
+
" shardingColumn: order_id\n"
+
" t_order_item:\n"
+
" actualDataNodes: ds_${0..1}.t_order_item_${0..1}\n"
+
" keyGenerator:\n"
+
" column: order_item_id\n"
+
" props:\n"
+
" worker.id: '123'\n"
+
" type: SNOWFLAKE\n"
+
" logicTable: t_order_item\n"
+
" tableStrategy:\n"
+
" standard:\n"
+
" shardingAlgorithm:\n"
+
" type: INLINE\n"
+
" props:\n"
+
" algorithm.expression: t_order_item_${order_id % 2}\n"
+
" shardingColumn: order_id\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/props"
,
"executor.size: '100'\nsql.show: 'true'\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/datasource"
,
""
+
"ds: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: sa\n"
+
"ds_0: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: sa\n"
+
"ds_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourceConfiguration\n"
+
" dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource\n"
+
" properties:\n"
+
" url: jdbc:h2:mem:ds_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL\n"
+
" maxTotal: 16\n"
+
" password: ''\n"
+
" username: sa\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/schema/logic_db/rule"
,
""
+
"rules:\n"
+
"- !!org.apache.shardingsphere.sharding.core.yaml.config.sharding.YamlShardingRuleConfiguration\n"
+
" bindingTables:\n"
+
" - t_order\n"
+
" - t_order_item\n"
+
" broadcastTables:\n"
+
" - t_config\n"
+
" defaultDatabaseStrategy:\n"
+
" standard:\n"
+
" shardingAlgorithm:\n"
+
" type: INLINE\n"
+
" props:\n"
+
" algorithm.expression: ds_${user_id % 2}\n"
+
" shardingColumn: user_id\n"
+
" tables:\n"
+
" t_order:\n"
+
" actualDataNodes: ds_${0..1}.t_order_${0..1}\n"
+
" keyGenerator:\n"
+
" column: order_id\n"
+
" props:\n"
+
" worker.id: '123'\n"
+
" type: SNOWFLAKE\n"
+
" logicTable: t_order\n"
+
" tableStrategy:\n"
+
" standard:\n"
+
" shardingAlgorithm:\n"
+
" type: INLINE\n"
+
" props:\n"
+
" algorithm.expression: t_order_${order_id % 2}\n"
+
" shardingColumn: order_id\n"
+
" t_order_item:\n"
+
" actualDataNodes: ds_${0..1}.t_order_item_${0..1}\n"
+
" keyGenerator:\n"
+
" column: order_item_id\n"
+
" props:\n"
+
" worker.id: '123'\n"
+
" type: SNOWFLAKE\n"
+
" logicTable: t_order_item\n"
+
" tableStrategy:\n"
+
" standard:\n"
+
" shardingAlgorithm:\n"
+
" type: INLINE\n"
+
" props:\n"
+
" algorithm.expression: t_order_item_${order_id % 2}\n"
+
" shardingColumn: order_id\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/config/props"
,
""
+
"executor.size: '100'\n"
+
"sql.show: 'true'\n"
);
testCenter
.
persist
(
"/demo_spring_boot_ds_center/registry/datasources"
,
""
);
}
...
...
sharding-spring/sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/org/apache/shardingsphere/shardingjdbc/spring/boot/sharding/SpringBootRuleConfigurationsYamlSwapper.java
浏览文件 @
5da9e194
...
...
@@ -32,7 +32,7 @@ import java.util.Collection;
import
java.util.LinkedList
;
/**
*
Rule root
configurations YAML swapper.
*
Spring boot rule
configurations YAML swapper.
*/
public
final
class
SpringBootRuleConfigurationsYamlSwapper
implements
YamlSwapper
<
SpringBootRulesConfigurationProperties
,
Collection
<
RuleConfiguration
>>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录