Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
91ce77d9
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 搜索 >>
提交
91ce77d9
编写于
11月 01, 2017
作者:
H
haocao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add orchestration spring boot support 3th.
上级
744565c6
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
176 addition
and
39 deletion
+176
-39
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/api/ShardingDataSourceFactory.java
...a/io/shardingjdbc/core/api/ShardingDataSourceFactory.java
+4
-4
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/masterslave/YamlMasterSlaveDataSource.java
...jdbc/core/yaml/masterslave/YamlMasterSlaveDataSource.java
+4
-4
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/masterslave/YamlMasterSlaveRuleConfiguration.java
...re/yaml/masterslave/YamlMasterSlaveRuleConfiguration.java
+1
-1
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/sharding/YamlShardingRuleConfiguration.java
...dbc/core/yaml/sharding/YamlShardingRuleConfiguration.java
+3
-3
sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingjdbc/orchestration/spring/boot/masterslave/OrchestrationSpringBootMasterSlaveRuleConfigurationProperties.java
...tionSpringBootMasterSlaveRuleConfigurationProperties.java
+2
-2
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/masterslave/YamlOrchesrationMasterSlaveRuleConfiguration.java
...erslave/YamlOrchesrationMasterSlaveRuleConfiguration.java
+2
-2
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/masterslave/YamlOrchestrationMasterSlaveDataSource.java
...l/masterslave/YamlOrchestrationMasterSlaveDataSource.java
+70
-0
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingDataSource.java
...on/yaml/sharding/YamlOrchestrationShardingDataSource.java
+70
-0
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/AllYamlTests.java
...java/io/shardingjdbc/orchestration/yaml/AllYamlTests.java
+6
-6
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/masterslave/YamlOrchestrationMasterSlaveIntegrateTest.java
...asterslave/YamlOrchestrationMasterSlaveIntegrateTest.java
+4
-5
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingIntegrateTest.java
...yaml/sharding/YamlOrchestrationShardingIntegrateTest.java
+4
-5
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingWithMasterSlaveIntegrateTest.java
...amlOrchestrationShardingWithMasterSlaveIntegrateTest.java
+4
-5
sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingjdbc/spring/boot/masterslave/SpringBootMasterSlaveRuleConfigurationProperties.java
...ave/SpringBootMasterSlaveRuleConfigurationProperties.java
+2
-2
未找到文件。
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/api/ShardingDataSourceFactory.java
浏览文件 @
91ce77d9
...
...
@@ -69,7 +69,7 @@ public final class ShardingDataSourceFactory {
* @param yamlFile yaml file for rule configuration of databases and tables sharding with data sources
* @return sharding data source
* @throws SQLException SQL exception
* @throws
SQL
Exception IO exception
* @throws
IO
Exception IO exception
*/
public
static
DataSource
createDataSource
(
final
File
yamlFile
)
throws
SQLException
,
IOException
{
return
new
YamlShardingDataSource
(
yamlFile
);
...
...
@@ -82,7 +82,7 @@ public final class ShardingDataSourceFactory {
* @param yamlFile yaml file for rule configuration of databases and tables sharding without data sources
* @return sharding data source
* @throws SQLException SQL exception
* @throws
SQL
Exception IO exception
* @throws
IO
Exception IO exception
*/
public
static
DataSource
createDataSource
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
File
yamlFile
)
throws
SQLException
,
IOException
{
return
new
YamlShardingDataSource
(
dataSourceMap
,
yamlFile
);
...
...
@@ -94,7 +94,7 @@ public final class ShardingDataSourceFactory {
* @param yamlByteArray yaml byte array for rule configuration of databases and tables sharding with data sources
* @return sharding data source
* @throws SQLException SQL exception
* @throws
SQL
Exception IO exception
* @throws
IO
Exception IO exception
*/
public
static
DataSource
createDataSource
(
final
byte
[]
yamlByteArray
)
throws
SQLException
,
IOException
{
return
new
YamlShardingDataSource
(
yamlByteArray
);
...
...
@@ -107,7 +107,7 @@ public final class ShardingDataSourceFactory {
* @param yamlByteArray yaml byte array for rule configuration of databases and tables sharding without data sources
* @return sharding data source
* @throws SQLException SQL exception
* @throws
SQL
Exception IO exception
* @throws
IO
Exception IO exception
*/
public
static
DataSource
createDataSource
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
byte
[]
yamlByteArray
)
throws
SQLException
,
IOException
{
return
new
YamlShardingDataSource
(
dataSourceMap
,
yamlByteArray
);
...
...
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/masterslave/YamlMasterSlaveDataSource.java
浏览文件 @
91ce77d9
...
...
@@ -54,16 +54,16 @@ public class YamlMasterSlaveDataSource extends MasterSlaveDataSource {
super
(
unmarshal
(
yamlByteArray
).
getMasterSlaveRule
(
dataSourceMap
));
}
private
static
YamMasterSlaveRuleConfiguration
unmarshal
(
final
File
yamlFile
)
throws
IOException
{
private
static
Yam
l
MasterSlaveRuleConfiguration
unmarshal
(
final
File
yamlFile
)
throws
IOException
{
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
yamlFile
);
InputStreamReader
inputStreamReader
=
new
InputStreamReader
(
fileInputStream
,
"UTF-8"
)
)
{
return
new
Yaml
(
new
Constructor
(
Yam
MasterSlaveRuleConfiguration
.
class
)).
loadAs
(
inputStreamReader
,
Yam
MasterSlaveRuleConfiguration
.
class
);
return
new
Yaml
(
new
Constructor
(
Yam
lMasterSlaveRuleConfiguration
.
class
)).
loadAs
(
inputStreamReader
,
Yaml
MasterSlaveRuleConfiguration
.
class
);
}
}
private
static
YamMasterSlaveRuleConfiguration
unmarshal
(
final
byte
[]
yamlByteArray
)
throws
IOException
{
return
new
Yaml
(
new
Constructor
(
Yam
MasterSlaveRuleConfiguration
.
class
)).
loadAs
(
new
ByteArrayInputStream
(
yamlByteArray
),
Yam
MasterSlaveRuleConfiguration
.
class
);
private
static
Yam
l
MasterSlaveRuleConfiguration
unmarshal
(
final
byte
[]
yamlByteArray
)
throws
IOException
{
return
new
Yaml
(
new
Constructor
(
Yam
lMasterSlaveRuleConfiguration
.
class
)).
loadAs
(
new
ByteArrayInputStream
(
yamlByteArray
),
Yaml
MasterSlaveRuleConfiguration
.
class
);
}
}
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/masterslave/YamMasterSlaveRuleConfiguration.java
→
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/masterslave/Yam
l
MasterSlaveRuleConfiguration.java
浏览文件 @
91ce77d9
...
...
@@ -37,7 +37,7 @@ import java.util.Map;
*/
@Getter
@Setter
public
class
YamMasterSlaveRuleConfiguration
{
public
class
Yam
l
MasterSlaveRuleConfiguration
{
private
Map
<
String
,
DataSource
>
dataSources
=
new
HashMap
<>();
...
...
sharding-jdbc-core/src/main/java/io/shardingjdbc/core/yaml/sharding/YamlShardingRuleConfiguration.java
浏览文件 @
91ce77d9
...
...
@@ -20,7 +20,7 @@ package io.shardingjdbc.core.yaml.sharding;
import
io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.api.config.ShardingRuleConfiguration
;
import
io.shardingjdbc.core.rule.ShardingRule
;
import
io.shardingjdbc.core.yaml.masterslave.YamMasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.yaml.masterslave.Yam
l
MasterSlaveRuleConfiguration
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -57,7 +57,7 @@ public class YamlShardingRuleConfiguration {
private
String
defaultKeyGeneratorClass
;
private
Map
<
String
,
YamMasterSlaveRuleConfiguration
>
masterSlaveRules
=
new
HashMap
<>();
private
Map
<
String
,
Yam
l
MasterSlaveRuleConfiguration
>
masterSlaveRules
=
new
HashMap
<>();
private
Properties
props
=
new
Properties
();
...
...
@@ -94,7 +94,7 @@ public class YamlShardingRuleConfiguration {
}
result
.
setDefaultKeyGeneratorClass
(
defaultKeyGeneratorClass
);
Collection
<
MasterSlaveRuleConfiguration
>
masterSlaveRuleConfigs
=
new
LinkedList
<>();
for
(
Map
.
Entry
<
String
,
YamMasterSlaveRuleConfiguration
>
each
:
masterSlaveRules
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Yam
l
MasterSlaveRuleConfiguration
>
each
:
masterSlaveRules
.
entrySet
())
{
MasterSlaveRuleConfiguration
config
=
new
MasterSlaveRuleConfiguration
();
config
.
setName
(
each
.
getKey
());
config
.
setMasterDataSourceName
(
each
.
getValue
().
getMasterDataSourceName
());
...
...
sharding-jdbc-orchestration-spring/sharding-jdbc-orchestration-spring-boot-starter/src/main/java/io/shardingjdbc/orchestration/spring/boot/masterslave/OrchestrationSpringBootMasterSlaveRuleConfigurationProperties.java
浏览文件 @
91ce77d9
package
io.shardingjdbc.orchestration.spring.boot.masterslave
;
import
io.shardingjdbc.core.yaml.masterslave.YamMasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.yaml.masterslave.Yam
l
MasterSlaveRuleConfiguration
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
...
...
@@ -9,5 +9,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author caohao
*/
@ConfigurationProperties
(
prefix
=
"sharding.jdbc.config.masterslave"
)
public
class
OrchestrationSpringBootMasterSlaveRuleConfigurationProperties
extends
YamMasterSlaveRuleConfiguration
{
public
class
OrchestrationSpringBootMasterSlaveRuleConfigurationProperties
extends
Yam
l
MasterSlaveRuleConfiguration
{
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/masterslave/YamOrchesrationMasterSlaveRuleConfiguration.java
→
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/masterslave/Yam
l
OrchesrationMasterSlaveRuleConfiguration.java
浏览文件 @
91ce77d9
...
...
@@ -17,7 +17,7 @@
package
io.shardingjdbc.orchestration.yaml.masterslave
;
import
io.shardingjdbc.core.yaml.masterslave.YamMasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.yaml.masterslave.Yam
l
MasterSlaveRuleConfiguration
;
import
io.shardingjdbc.orchestration.reg.base.RegistryCenter
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -29,7 +29,7 @@ import lombok.Setter;
*/
@Getter
@Setter
public
class
Yam
OrchesrationMasterSlaveRuleConfiguration
extends
Yam
MasterSlaveRuleConfiguration
{
public
class
Yam
lOrchesrationMasterSlaveRuleConfiguration
extends
Yaml
MasterSlaveRuleConfiguration
{
private
boolean
overwrite
;
...
...
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/masterslave/YamlOrchestrationMasterSlaveDataSource.java
0 → 100644
浏览文件 @
91ce77d9
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
io.shardingjdbc.orchestration.yaml.masterslave
;
import
io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource
;
import
io.shardingjdbc.core.yaml.masterslave.YamlMasterSlaveRuleConfiguration
;
import
org.yaml.snakeyaml.Yaml
;
import
org.yaml.snakeyaml.constructor.Constructor
;
import
javax.sql.DataSource
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.sql.SQLException
;
import
java.util.Collections
;
import
java.util.Map
;
/**
* Orchestration master-slave datasource for yaml.
*
* @author caohao
*/
public
class
YamlOrchestrationMasterSlaveDataSource
extends
MasterSlaveDataSource
{
public
YamlOrchestrationMasterSlaveDataSource
(
final
File
yamlFile
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlFile
).
getMasterSlaveRule
(
Collections
.<
String
,
DataSource
>
emptyMap
()));
}
public
YamlOrchestrationMasterSlaveDataSource
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
File
yamlFile
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlFile
).
getMasterSlaveRule
(
dataSourceMap
));
}
public
YamlOrchestrationMasterSlaveDataSource
(
final
byte
[]
yamlByteArray
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlByteArray
).
getMasterSlaveRule
(
Collections
.<
String
,
DataSource
>
emptyMap
()));
}
public
YamlOrchestrationMasterSlaveDataSource
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
byte
[]
yamlByteArray
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlByteArray
).
getMasterSlaveRule
(
dataSourceMap
));
}
private
static
YamlMasterSlaveRuleConfiguration
unmarshal
(
final
File
yamlFile
)
throws
IOException
{
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
yamlFile
);
InputStreamReader
inputStreamReader
=
new
InputStreamReader
(
fileInputStream
,
"UTF-8"
)
)
{
return
new
Yaml
(
new
Constructor
(
YamlOrchesrationMasterSlaveRuleConfiguration
.
class
)).
loadAs
(
inputStreamReader
,
YamlOrchesrationMasterSlaveRuleConfiguration
.
class
);
}
}
private
static
YamlMasterSlaveRuleConfiguration
unmarshal
(
final
byte
[]
yamlByteArray
)
throws
IOException
{
return
new
Yaml
(
new
Constructor
(
YamlMasterSlaveRuleConfiguration
.
class
)).
loadAs
(
new
ByteArrayInputStream
(
yamlByteArray
),
YamlMasterSlaveRuleConfiguration
.
class
);
}
}
sharding-jdbc-orchestration/src/main/java/io/shardingjdbc/orchestration/yaml/sharding/YamlOrchestrationShardingDataSource.java
0 → 100644
浏览文件 @
91ce77d9
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
io.shardingjdbc.orchestration.yaml.sharding
;
import
io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource
;
import
io.shardingjdbc.core.yaml.sharding.YamlShardingRuleConfiguration
;
import
org.yaml.snakeyaml.Yaml
;
import
org.yaml.snakeyaml.constructor.Constructor
;
import
javax.sql.DataSource
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.sql.SQLException
;
import
java.util.Collections
;
import
java.util.Map
;
/**
* Orchestration sharding datasource for yaml.
*
* @author caohao
*/
public
class
YamlOrchestrationShardingDataSource
extends
ShardingDataSource
{
public
YamlOrchestrationShardingDataSource
(
final
File
yamlFile
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlFile
).
getShardingRule
(
Collections
.<
String
,
DataSource
>
emptyMap
()),
unmarshal
(
yamlFile
).
getProps
());
}
public
YamlOrchestrationShardingDataSource
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
File
yamlFile
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlFile
).
getShardingRule
(
dataSourceMap
),
unmarshal
(
yamlFile
).
getProps
());
}
public
YamlOrchestrationShardingDataSource
(
final
byte
[]
yamlByteArray
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlByteArray
).
getShardingRule
(
Collections
.<
String
,
DataSource
>
emptyMap
()),
unmarshal
(
yamlByteArray
).
getProps
());
}
public
YamlOrchestrationShardingDataSource
(
final
Map
<
String
,
DataSource
>
dataSourceMap
,
final
byte
[]
yamlByteArray
)
throws
IOException
,
SQLException
{
super
(
unmarshal
(
yamlByteArray
).
getShardingRule
(
dataSourceMap
),
unmarshal
(
yamlByteArray
).
getProps
());
}
private
static
YamlShardingRuleConfiguration
unmarshal
(
final
File
yamlFile
)
throws
IOException
{
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
yamlFile
);
InputStreamReader
inputStreamReader
=
new
InputStreamReader
(
fileInputStream
,
"UTF-8"
)
)
{
return
new
Yaml
(
new
Constructor
(
YamlOrchestrationShardingRuleConfiguration
.
class
)).
loadAs
(
inputStreamReader
,
YamlOrchestrationShardingRuleConfiguration
.
class
);
}
}
private
static
YamlShardingRuleConfiguration
unmarshal
(
final
byte
[]
yamlByteArray
)
throws
IOException
{
return
new
Yaml
(
new
Constructor
(
YamlOrchestrationShardingRuleConfiguration
.
class
)).
loadAs
(
new
ByteArrayInputStream
(
yamlByteArray
),
YamlOrchestrationShardingRuleConfiguration
.
class
);
}
}
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/AllYamlTests.java
浏览文件 @
91ce77d9
...
...
@@ -17,17 +17,17 @@
package
io.shardingjdbc.orchestration.yaml
;
import
io.shardingjdbc.orchestration.yaml.masterslave.
OrchestrationYaml
MasterSlaveIntegrateTest
;
import
io.shardingjdbc.orchestration.yaml.sharding.
OrchestrationYaml
ShardingIntegrateTest
;
import
io.shardingjdbc.orchestration.yaml.sharding.
OrchestrationYaml
ShardingWithMasterSlaveIntegrateTest
;
import
io.shardingjdbc.orchestration.yaml.masterslave.
YamlOrchestration
MasterSlaveIntegrateTest
;
import
io.shardingjdbc.orchestration.yaml.sharding.
YamlOrchestration
ShardingIntegrateTest
;
import
io.shardingjdbc.orchestration.yaml.sharding.
YamlOrchestration
ShardingWithMasterSlaveIntegrateTest
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
@RunWith
(
Suite
.
class
)
@Suite
.
SuiteClasses
({
OrchestrationYaml
ShardingIntegrateTest
.
class
,
OrchestrationYaml
MasterSlaveIntegrateTest
.
class
,
OrchestrationYaml
ShardingWithMasterSlaveIntegrateTest
.
class
YamlOrchestration
ShardingIntegrateTest
.
class
,
YamlOrchestration
MasterSlaveIntegrateTest
.
class
,
YamlOrchestration
ShardingWithMasterSlaveIntegrateTest
.
class
})
public
class
AllYamlTests
{
}
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/masterslave/
OrchestrationYaml
MasterSlaveIntegrateTest.java
→
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/masterslave/
YamlOrchestration
MasterSlaveIntegrateTest.java
浏览文件 @
91ce77d9
...
...
@@ -20,7 +20,6 @@ package io.shardingjdbc.orchestration.yaml.masterslave;
import
com.google.common.base.Function
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
io.shardingjdbc.core.yaml.masterslave.YamlMasterSlaveDataSource
;
import
io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest
;
import
lombok.RequiredArgsConstructor
;
import
org.junit.Test
;
...
...
@@ -39,7 +38,7 @@ import java.util.Collection;
@RunWith
(
Parameterized
.
class
)
@RequiredArgsConstructor
public
class
OrchestrationYaml
MasterSlaveIntegrateTest
extends
AbstractYamlDataSourceTest
{
public
class
YamlOrchestration
MasterSlaveIntegrateTest
extends
AbstractYamlDataSourceTest
{
private
final
String
filePath
;
...
...
@@ -55,12 +54,12 @@ public class OrchestrationYamlMasterSlaveIntegrateTest extends AbstractYamlDataS
@Test
public
void
testWithDataSource
()
throws
SQLException
,
URISyntaxException
,
IOException
{
File
yamlFile
=
new
File
(
OrchestrationYaml
MasterSlaveIntegrateTest
.
class
.
getResource
(
filePath
).
toURI
());
File
yamlFile
=
new
File
(
YamlOrchestration
MasterSlaveIntegrateTest
.
class
.
getResource
(
filePath
).
toURI
());
DataSource
dataSource
;
if
(
hasDataSource
)
{
dataSource
=
new
YamlMasterSlaveDataSource
(
yamlFile
);
dataSource
=
new
Yaml
Orchestration
MasterSlaveDataSource
(
yamlFile
);
}
else
{
dataSource
=
new
YamlMasterSlaveDataSource
(
Maps
.
asMap
(
Sets
.
newHashSet
(
"db_master"
,
"db_slave_0"
,
"db_slave_1"
),
new
Function
<
String
,
DataSource
>()
{
dataSource
=
new
Yaml
Orchestration
MasterSlaveDataSource
(
Maps
.
asMap
(
Sets
.
newHashSet
(
"db_master"
,
"db_slave_0"
,
"db_slave_1"
),
new
Function
<
String
,
DataSource
>()
{
@Override
public
DataSource
apply
(
final
String
key
)
{
return
createDataSource
(
key
);
...
...
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/
OrchestrationYaml
ShardingIntegrateTest.java
→
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/
YamlOrchestration
ShardingIntegrateTest.java
浏览文件 @
91ce77d9
...
...
@@ -20,7 +20,6 @@ package io.shardingjdbc.orchestration.yaml.sharding;
import
com.google.common.base.Function
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
io.shardingjdbc.core.yaml.sharding.YamlShardingDataSource
;
import
io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest
;
import
lombok.RequiredArgsConstructor
;
import
org.junit.Test
;
...
...
@@ -39,7 +38,7 @@ import java.util.Collection;
@RunWith
(
Parameterized
.
class
)
@RequiredArgsConstructor
public
class
OrchestrationYaml
ShardingIntegrateTest
extends
AbstractYamlDataSourceTest
{
public
class
YamlOrchestration
ShardingIntegrateTest
extends
AbstractYamlDataSourceTest
{
private
final
String
filePath
;
...
...
@@ -57,12 +56,12 @@ public class OrchestrationYamlShardingIntegrateTest extends AbstractYamlDataSour
@Test
public
void
testWithDataSource
()
throws
SQLException
,
URISyntaxException
,
IOException
{
File
yamlFile
=
new
File
(
OrchestrationYaml
ShardingIntegrateTest
.
class
.
getResource
(
filePath
).
toURI
());
File
yamlFile
=
new
File
(
YamlOrchestration
ShardingIntegrateTest
.
class
.
getResource
(
filePath
).
toURI
());
DataSource
dataSource
;
if
(
hasDataSource
)
{
dataSource
=
new
YamlShardingDataSource
(
yamlFile
);
dataSource
=
new
Yaml
Orchestration
ShardingDataSource
(
yamlFile
);
}
else
{
dataSource
=
new
YamlShardingDataSource
(
Maps
.
asMap
(
Sets
.
newHashSet
(
"db0"
,
"db1"
),
new
Function
<
String
,
DataSource
>()
{
dataSource
=
new
Yaml
Orchestration
ShardingDataSource
(
Maps
.
asMap
(
Sets
.
newHashSet
(
"db0"
,
"db1"
),
new
Function
<
String
,
DataSource
>()
{
@Override
public
DataSource
apply
(
final
String
key
)
{
return
createDataSource
(
key
);
...
...
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/
OrchestrationYaml
ShardingWithMasterSlaveIntegrateTest.java
→
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/yaml/sharding/
YamlOrchestration
ShardingWithMasterSlaveIntegrateTest.java
浏览文件 @
91ce77d9
...
...
@@ -20,7 +20,6 @@ package io.shardingjdbc.orchestration.yaml.sharding;
import
com.google.common.base.Function
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
io.shardingjdbc.core.yaml.sharding.YamlShardingDataSource
;
import
io.shardingjdbc.orchestration.yaml.AbstractYamlDataSourceTest
;
import
lombok.RequiredArgsConstructor
;
import
org.junit.Test
;
...
...
@@ -41,7 +40,7 @@ import java.util.Map;
@RunWith
(
Parameterized
.
class
)
@RequiredArgsConstructor
public
class
OrchestrationYaml
ShardingWithMasterSlaveIntegrateTest
extends
AbstractYamlDataSourceTest
{
public
class
YamlOrchestration
ShardingWithMasterSlaveIntegrateTest
extends
AbstractYamlDataSourceTest
{
private
final
String
filePath
;
...
...
@@ -59,10 +58,10 @@ public class OrchestrationYamlShardingWithMasterSlaveIntegrateTest extends Abstr
@Test
public
void
testWithDataSource
()
throws
SQLException
,
URISyntaxException
,
IOException
{
File
yamlFile
=
new
File
(
OrchestrationYaml
ShardingWithMasterSlaveIntegrateTest
.
class
.
getResource
(
filePath
).
toURI
());
File
yamlFile
=
new
File
(
YamlOrchestration
ShardingWithMasterSlaveIntegrateTest
.
class
.
getResource
(
filePath
).
toURI
());
DataSource
dataSource
;
if
(
hasDataSource
)
{
dataSource
=
new
YamlShardingDataSource
(
yamlFile
);
dataSource
=
new
Yaml
Orchestration
ShardingDataSource
(
yamlFile
);
}
else
{
Map
<
String
,
DataSource
>
dataSourceMap
=
Maps
.
asMap
(
Sets
.
newHashSet
(
"db0_master"
,
"db0_slave"
,
"db1_master"
,
"db1_slave"
),
new
Function
<
String
,
DataSource
>()
{
@Override
...
...
@@ -74,7 +73,7 @@ public class OrchestrationYamlShardingWithMasterSlaveIntegrateTest extends Abstr
for
(
Map
.
Entry
<
String
,
DataSource
>
each
:
dataSourceMap
.
entrySet
())
{
result
.
put
(
each
.
getKey
(),
each
.
getValue
());
}
dataSource
=
new
YamlShardingDataSource
(
result
,
yamlFile
);
dataSource
=
new
Yaml
Orchestration
ShardingDataSource
(
result
,
yamlFile
);
}
try
(
Connection
conn
=
dataSource
.
getConnection
();
Statement
stm
=
conn
.
createStatement
())
{
...
...
sharding-jdbc-spring/sharding-jdbc-spring-boot-starter/src/main/java/io/shardingjdbc/spring/boot/masterslave/SpringBootMasterSlaveRuleConfigurationProperties.java
浏览文件 @
91ce77d9
package
io.shardingjdbc.spring.boot.masterslave
;
import
io.shardingjdbc.core.yaml.masterslave.YamMasterSlaveRuleConfiguration
;
import
io.shardingjdbc.core.yaml.masterslave.Yam
l
MasterSlaveRuleConfiguration
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
...
...
@@ -9,5 +9,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author caohao
*/
@ConfigurationProperties
(
prefix
=
"sharding.jdbc.config.masterslave"
)
public
class
SpringBootMasterSlaveRuleConfigurationProperties
extends
YamMasterSlaveRuleConfiguration
{
public
class
SpringBootMasterSlaveRuleConfigurationProperties
extends
Yam
l
MasterSlaveRuleConfiguration
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录