Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
4c9d34ea
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,发现更多精彩内容 >>
提交
4c9d34ea
编写于
4月 09, 2019
作者:
L
liya.cookie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move logic to broadcast-table-example
上级
de3a1e0a
变更
57
隐藏空白更改
内联
并排
Showing
57 changed file
with
607 addition
and
101 deletion
+607
-101
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/JavaConfigurationExample.java
...le/broadcast/table/raw/jdbc/JavaConfigurationExample.java
+49
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/YamlConfigurationExample.java
...le/broadcast/table/raw/jdbc/YamlConfigurationExample.java
+49
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/config/MasterSlaveConfiguration.java
...dcast/table/raw/jdbc/config/MasterSlaveConfiguration.java
+47
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
...aw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
+46
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/factory/DataSourceFactory.java
...e/broadcast/table/raw/jdbc/factory/DataSourceFactory.java
+39
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/factory/YamlDataSourceFactory.java
...oadcast/table/raw/jdbc/factory/YamlDataSourceFactory.java
+45
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/resources/META-INF/master-slave.yaml
...dbc-example/src/main/resources/META-INF/master-slave.yaml
+24
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
...ample/src/main/resources/META-INF/sharding-databases.yaml
+18
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/resources/logback.xml
...ast-table-raw-jdbc-example/src/main/resources/logback.xml
+17
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/spring/boot/SpringBootExample.java
...xample/broadcast/table/spring/boot/SpringBootExample.java
+39
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/application-master-slave.properties
...le/src/main/resources/application-master-slave.properties
+24
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/application-sharding-databases.properties
.../main/resources/application-sharding-databases.properties
+15
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/application.properties
...ng-boot-example/src/main/resources/application.properties
+6
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/logback.xml
...-table-spring-boot-example/src/main/resources/logback.xml
+19
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/spring/namespace/SpringNamespaceExample.java
...adcast/table/spring/namespace/SpringNamespaceExample.java
+37
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/resources/META-INF/application-master-slave.xml
.../src/main/resources/META-INF/application-master-slave.xml
+56
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases.xml
...ain/resources/META-INF/application-sharding-databases.xml
+60
-0
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/resources/logback.xml
...e-spring-namespace-example/src/main/resources/logback.xml
+17
-0
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/JavaConfigurationExample.java
...e/example/sharding/raw/jdbc/JavaConfigurationExample.java
+0
-10
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/YamlConfigurationExample.java
...e/example/sharding/raw/jdbc/YamlConfigurationExample.java
+0
-10
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesAndTablesConfigurationPrecise.java
...onfig/ShardingDatabasesAndTablesConfigurationPrecise.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesAndTablesConfigurationRange.java
.../config/ShardingDatabasesAndTablesConfigurationRange.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
...aw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationRange.java
.../raw/jdbc/config/ShardingDatabasesConfigurationRange.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingMasterSlaveConfigurationPrecise.java
.../jdbc/config/ShardingMasterSlaveConfigurationPrecise.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingMasterSlaveConfigurationRange.java
...aw/jdbc/config/ShardingMasterSlaveConfigurationRange.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingTablesConfigurationPrecise.java
...g/raw/jdbc/config/ShardingTablesConfigurationPrecise.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingTablesConfigurationRange.java
...ing/raw/jdbc/config/ShardingTablesConfigurationRange.java
+0
-1
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
...src/main/resources/META-INF/sharding-databases-range.yaml
+0
-3
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables-range.yaml
...n/resources/META-INF/sharding-databases-tables-range.yaml
+0
-3
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
...rc/main/resources/META-INF/sharding-databases-tables.yaml
+0
-3
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
...ample/src/main/resources/META-INF/sharding-databases.yaml
+0
-3
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-master-slave-range.yaml
.../main/resources/META-INF/sharding-master-slave-range.yaml
+0
-4
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-master-slave.yaml
...le/src/main/resources/META-INF/sharding-master-slave.yaml
+0
-4
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables-range.yaml
...le/src/main/resources/META-INF/sharding-tables-range.yaml
+0
-2
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml
...-example/src/main/resources/META-INF/sharding-tables.yaml
+0
-2
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/SpringBootExample.java
...e/example/sharding/spring/boot/jpa/SpringBootExample.java
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
...esources/application-sharding-databases-tables.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
.../main/resources/application-sharding-databases.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-master-slave.properties
...in/resources/application-sharding-master-slave.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
...src/main/resources/application-sharding-tables.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/mybatis/SpringBootMybatisMain.java
...e/sharding/spring/boot/mybatis/SpringBootMybatisMain.java
+0
-5
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
...is-example/src/main/resources/META-INF/mybatis-config.xml
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
...esources/application-sharding-databases-tables.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
.../main/resources/application-sharding-databases.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-master-slave.properties
...in/resources/application-sharding-master-slave.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
...src/main/resources/application-sharding-tables.properties
+0
-1
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/SpringNamespaceJPAMain.java
...sharding/spring/namespace/jpa/SpringNamespaceJPAMain.java
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
...ources/META-INF/application-sharding-databases-tables.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
...ain/resources/META-INF/application-sharding-databases.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-master-slave.xml
.../resources/META-INF/application-sharding-master-slave.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
...c/main/resources/META-INF/application-sharding-tables.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/SpringNamespaceExample.java
...ding/spring/namespace/mybatis/SpringNamespaceExample.java
+0
-5
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
...ources/META-INF/application-sharding-databases-tables.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
...ain/resources/META-INF/application-sharding-databases.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-master-slave.xml
.../resources/META-INF/application-sharding-master-slave.xml
+0
-3
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
...c/main/resources/META-INF/application-sharding-tables.xml
+0
-3
未找到文件。
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/JavaConfigurationExample.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.
*/
/*
* Please make sure master-slave data sync on MySQL is running correctly. Otherwise this example will query empty data from slave.
*/
package
org.apache.shardingsphere.example.broadcast.table.raw.jdbc
;
import
org.apache.shardingsphere.example.broadcast.table.raw.jdbc.factory.DataSourceFactory
;
import
org.apache.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl
;
import
org.apache.shardingsphere.example.common.jdbc.service.CountryServiceImpl
;
import
org.apache.shardingsphere.example.common.service.CommonService
;
import
org.apache.shardingsphere.example.type.ShardingType
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
public
class
JavaConfigurationExample
{
private
static
ShardingType
shardingType
=
ShardingType
.
SHARDING_DATABASES
;
// private static ShardingType shardingType = ShardingType.MASTER_SLAVE;
public
static
void
main
(
final
String
[]
args
)
throws
SQLException
{
DataSource
dataSource
=
DataSourceFactory
.
newInstance
(
shardingType
);
CommonService
countryService
=
getCountryService
(
dataSource
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
private
static
CommonService
getCountryService
(
final
DataSource
dataSource
)
{
return
new
CountryServiceImpl
(
new
CountryRepositroyImpl
(
dataSource
));
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/YamlConfigurationExample.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.raw.jdbc
;
import
org.apache.shardingsphere.example.broadcast.table.raw.jdbc.factory.YamlDataSourceFactory
;
import
org.apache.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl
;
import
org.apache.shardingsphere.example.common.jdbc.service.CountryServiceImpl
;
import
org.apache.shardingsphere.example.common.service.CommonService
;
import
org.apache.shardingsphere.example.type.ShardingType
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.sql.SQLException
;
/*
* Please make sure master-slave data sync on MySQL is running correctly. Otherwise this example will query empty data from slave.
*/
public
class
YamlConfigurationExample
{
private
static
ShardingType
shardingType
=
ShardingType
.
SHARDING_DATABASES
;
// private static ShardingType shardingType = ShardingType.MASTER_SLAVE;
public
static
void
main
(
final
String
[]
args
)
throws
SQLException
,
IOException
{
DataSource
dataSource
=
YamlDataSourceFactory
.
newInstance
(
shardingType
);
CommonService
countryService
=
getCountryService
(
dataSource
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
private
static
CommonService
getCountryService
(
final
DataSource
dataSource
)
{
return
new
CountryServiceImpl
(
new
CountryRepositroyImpl
(
dataSource
));
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/config/MasterSlaveConfiguration.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.raw.jdbc.config
;
import
org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration
;
import
org.apache.shardingsphere.example.common.DataSourceUtil
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.api.MasterSlaveDataSourceFactory
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
public
class
MasterSlaveConfiguration
implements
ExampleConfiguration
{
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
=
new
MasterSlaveRuleConfiguration
(
"demo_ds_master_slave"
,
"demo_ds_master"
,
Arrays
.
asList
(
"demo_ds_slave_0"
,
"demo_ds_slave_1"
));
return
MasterSlaveDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
masterSlaveRuleConfig
,
new
Properties
());
}
private
Map
<
String
,
DataSource
>
createDataSourceMap
()
{
Map
<
String
,
DataSource
>
result
=
new
HashMap
<>();
result
.
put
(
"demo_ds_master"
,
DataSourceUtil
.
createDataSource
(
"demo_ds_master"
));
result
.
put
(
"demo_ds_slave_0"
,
DataSourceUtil
.
createDataSource
(
"demo_ds_slave_0"
));
result
.
put
(
"demo_ds_slave_1"
,
DataSourceUtil
.
createDataSource
(
"demo_ds_slave_1"
));
return
result
;
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.raw.jdbc.config
;
import
org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration
;
import
org.apache.shardingsphere.example.common.DataSourceUtil
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
public
class
ShardingDatabasesConfigurationPrecise
implements
ExampleConfiguration
{
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
ShardingRuleConfiguration
shardingRuleConfig
=
new
ShardingRuleConfiguration
();
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
return
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
());
}
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
;
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/factory/DataSourceFactory.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.raw.jdbc.factory
;
import
org.apache.shardingsphere.example.broadcast.table.raw.jdbc.config.MasterSlaveConfiguration
;
import
org.apache.shardingsphere.example.broadcast.table.raw.jdbc.config.ShardingDatabasesConfigurationPrecise
;
import
org.apache.shardingsphere.example.type.ShardingType
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
public
class
DataSourceFactory
{
public
static
DataSource
newInstance
(
final
ShardingType
shardingType
)
throws
SQLException
{
switch
(
shardingType
)
{
case
SHARDING_DATABASES:
return
new
ShardingDatabasesConfigurationPrecise
().
getDataSource
();
case
MASTER_SLAVE:
return
new
MasterSlaveConfiguration
().
getDataSource
();
default
:
throw
new
UnsupportedOperationException
(
shardingType
.
name
());
}
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/raw/jdbc/factory/YamlDataSourceFactory.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.raw.jdbc.factory
;
import
org.apache.shardingsphere.example.type.ShardingType
;
import
org.apache.shardingsphere.shardingjdbc.api.yaml.YamlMasterSlaveDataSourceFactory
;
import
org.apache.shardingsphere.shardingjdbc.api.yaml.YamlShardingDataSourceFactory
;
import
javax.sql.DataSource
;
import
java.io.File
;
import
java.io.IOException
;
import
java.sql.SQLException
;
public
class
YamlDataSourceFactory
{
public
static
DataSource
newInstance
(
final
ShardingType
shardingType
)
throws
SQLException
,
IOException
{
switch
(
shardingType
)
{
case
SHARDING_DATABASES:
return
YamlShardingDataSourceFactory
.
createDataSource
(
getFile
(
"/META-INF/sharding-databases.yaml"
));
case
MASTER_SLAVE:
return
YamlMasterSlaveDataSourceFactory
.
createDataSource
(
getFile
(
"/META-INF/master-slave.yaml"
));
default
:
throw
new
UnsupportedOperationException
(
shardingType
.
name
());
}
}
private
static
File
getFile
(
final
String
fileName
)
{
return
new
File
(
Thread
.
currentThread
().
getClass
().
getResource
(
fileName
).
getFile
());
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/resources/META-INF/master-slave.yaml
0 → 100644
浏览文件 @
4c9d34ea
dataSources
:
ds_master
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/demo_ds_master?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
ds_slave_0
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/demo_ds_slave_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
ds_slave_1
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/demo_ds_slave_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
masterSlaveRule
:
name
:
ds_ms
masterDataSourceName
:
ds_master
slaveDataSourceNames
:
[
ds_slave_0
,
ds_slave_1
]
props
:
sql.show
:
false
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
0 → 100644
浏览文件 @
4c9d34ea
dataSources
:
ds_0
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
ds_1
:
!!com.zaxxer.hikari.HikariDataSource
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username
:
root
password
:
shardingRule
:
broadcastTables
:
-
t_country
props
:
sql.show
:
false
sharding-jdbc-example/broadcast-table-example/broadcast-table-raw-jdbc-example/src/main/resources/logback.xml
0 → 100644
浏览文件 @
4c9d34ea
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"log.context.name"
value=
"sharding-jdbc-api-quickstart"
/>
<property
name=
"log.charset"
value=
"UTF-8"
/>
<property
name=
"log.pattern"
value=
"[%-5level] %date --%thread-- [%logger] %msg %n"
/>
<contextName>
${log.context.name}
</contextName>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
charset=
"${log.charset}"
>
<pattern>
${log.pattern}
</pattern>
</encoder>
</appender>
<root>
<level
value=
"INFO"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/spring/boot/SpringBootExample.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.spring.boot
;
import
org.apache.shardingsphere.example.common.jpa.service.JPACountryService
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.ComponentScan
;
@ComponentScan
(
"org.apache.shardingsphere.example.common.jpa"
)
@EntityScan
(
basePackages
=
"org.apache.shardingsphere.example.common.jpa.entity"
)
@SpringBootApplication
(
exclude
=
JtaAutoConfiguration
.
class
)
public
class
SpringBootExample
{
public
static
void
main
(
final
String
[]
args
)
{
try
(
ConfigurableApplicationContext
applicationContext
=
SpringApplication
.
run
(
SpringBootExample
.
class
,
args
))
{
JPACountryService
countryService
=
applicationContext
.
getBean
(
JPACountryService
.
class
);
countryService
.
processSuccess
();
}
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/application-master-slave.properties
0 → 100644
浏览文件 @
4c9d34ea
sharding.jdbc.datasource.names
=
ds_master,ds_slave_0,ds_slave_1
sharding.jdbc.datasource.ds_master.type
=
com.zaxxer.hikari.HikariDataSource
sharding.jdbc.datasource.ds_master.driver-class-name
=
com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_master.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_master?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
sharding.jdbc.datasource.ds_master.username
=
root
sharding.jdbc.datasource.ds_master.password
=
sharding.jdbc.datasource.ds_slave_0.type
=
com.zaxxer.hikari.HikariDataSource
sharding.jdbc.datasource.ds_slave_0.driver-class-name
=
com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_slave_0.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_slave_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
sharding.jdbc.datasource.ds_slave_0.username
=
root
sharding.jdbc.datasource.ds_slave_0.password
=
sharding.jdbc.datasource.ds_slave_1.type
=
com.zaxxer.hikari.HikariDataSource
sharding.jdbc.datasource.ds_slave_1.driver-class-name
=
com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_slave_1.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_slave_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
sharding.jdbc.datasource.ds_slave_1.username
=
root
sharding.jdbc.datasource.ds_slave_1.password
=
sharding.jdbc.config.masterslave.load-balance-algorithm-type
=
round_robin
sharding.jdbc.config.masterslave.name
=
ds_ms
sharding.jdbc.config.masterslave.master-data-source-name
=
ds_master
sharding.jdbc.config.masterslave.slave-data-source-names
=
ds_slave_0,ds_slave_1
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/application-sharding-databases.properties
0 → 100644
浏览文件 @
4c9d34ea
sharding.jdbc.datasource.names
=
ds_0,ds_1
sharding.jdbc.datasource.ds_0.type
=
com.zaxxer.hikari.HikariDataSource
sharding.jdbc.datasource.ds_0.driver-class-name
=
com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_0.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
sharding.jdbc.datasource.ds_0.username
=
root
sharding.jdbc.datasource.ds_0.password
=
sharding.jdbc.datasource.ds_1.type
=
com.zaxxer.hikari.HikariDataSource
sharding.jdbc.datasource.ds_1.driver-class-name
=
com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_1.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
sharding.jdbc.datasource.ds_1.username
=
root
sharding.jdbc.datasource.ds_1.password
=
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/application.properties
0 → 100644
浏览文件 @
4c9d34ea
spring.jpa.properties.hibernate.hbm2ddl.auto
=
create-drop
spring.jpa.properties.hibernate.dialect
=
org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.show_sql
=
false
spring.profiles.active
=
sharding-databases
#spring.profiles.active=master-slave
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-boot-example/src/main/resources/logback.xml
0 → 100644
浏览文件 @
4c9d34ea
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"log.context.name"
value=
"spring-boot-nodep-jpa-example"
/>
<property
name=
"log.charset"
value=
"UTF-8"
/>
<property
name=
"log.pattern"
value=
"[%-5level] %date --%thread-- [%logger] %msg %n"
/>
<contextName>
${log.context.name}
</contextName>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
charset=
"${log.charset}"
>
<pattern>
${log.pattern}
</pattern>
</encoder>
</appender>
<logger
name=
"org.springframework"
level=
"WARN"
/>
<logger
name=
"com.zaxxer.hikari"
level=
"WARN"
/>
<root>
<level
value=
"INFO"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/java/org/apache/shardingsphere/example/broadcast/table/spring/namespace/SpringNamespaceExample.java
0 → 100644
浏览文件 @
4c9d34ea
/*
* 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.example.broadcast.table.spring.namespace
;
import
org.apache.shardingsphere.example.common.mybatis.service.SpringCountryService
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
public
class
SpringNamespaceExample
{
private
static
final
String
CONFIG_FILE
=
"META-INF/application-sharding-databases.xml"
;
// private static final String CONFIG_FILE = "META-INF/application-master-slave.xml";
public
static
void
main
(
final
String
[]
args
)
{
try
(
ConfigurableApplicationContext
applicationContext
=
new
ClassPathXmlApplicationContext
(
CONFIG_FILE
))
{
SpringCountryService
countryService
=
applicationContext
.
getBean
(
SpringCountryService
.
class
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
}
}
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/resources/META-INF/application-master-slave.xml
0 → 100644
浏览文件 @
4c9d34ea
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:master-slave=
"http://shardingsphere.apache.org/schema/shardingsphere/masterslave"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://shardingsphere.apache.org/schema/shardingsphere/masterslave
http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd"
>
<context:component-scan
base-package=
"org.apache.shardingsphere.example.common.mybatis"
/>
<bean
id=
"demo_ds_master"
class=
"com.zaxxer.hikari.HikariDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"jdbcUrl"
value=
"jdbc:mysql://localhost:3306/demo_ds_master?useSSL=false&useUnicode=true&characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"root"
/>
<property
name=
"password"
value=
""
/>
</bean>
<bean
id=
"demo_ds_slave_0"
class=
"com.zaxxer.hikari.HikariDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"jdbcUrl"
value=
"jdbc:mysql://localhost:3306/demo_ds_slave_0?useSSL=false&useUnicode=true&characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"root"
/>
<property
name=
"password"
value=
""
/>
</bean>
<bean
id=
"demo_ds_slave_1"
class=
"com.zaxxer.hikari.HikariDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"jdbcUrl"
value=
"jdbc:mysql://localhost:3306/demo_ds_slave_1?useSSL=false"
/>
<property
name=
"username"
value=
"root"
/>
<property
name=
"password"
value=
""
/>
</bean>
<bean
id=
"randomStrategy"
class=
"org.apache.shardingsphere.core.strategy.masterslave.RandomMasterSlaveLoadBalanceAlgorithm"
/>
<master-slave:data-source
id=
"masterSlaveDataSource"
master-data-source-name=
"demo_ds_master"
slave-data-source-names=
"demo_ds_slave_0, demo_ds_slave_1"
strategy-ref=
"randomStrategy"
/>
<bean
id=
"transactionManager"
class=
"org.springframework.jdbc.datasource.DataSourceTransactionManager"
>
<property
name=
"dataSource"
ref=
"masterSlaveDataSource"
/>
</bean>
<tx:annotation-driven
/>
<bean
id=
"sqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"dataSource"
ref=
"masterSlaveDataSource"
/>
<property
name=
"mapperLocations"
value=
"classpath*:META-INF/mappers/*.xml"
/>
</bean>
<bean
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"basePackage"
value=
"org.apache.shardingsphere.example.common.mybatis.repository"
/>
<property
name=
"sqlSessionFactoryBeanName"
value=
"sqlSessionFactory"
/>
</bean>
</beans>
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/resources/META-INF/application-sharding-databases.xml
0 → 100644
浏览文件 @
4c9d34ea
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:sharding=
"http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://shardingsphere.apache.org/schema/shardingsphere/sharding
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd"
>
<context:component-scan
base-package=
"org.apache.shardingsphere.example.common.mybatis"
/>
<bean
id=
"demo_ds_0"
class=
"com.zaxxer.hikari.HikariDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"jdbcUrl"
value=
"jdbc:mysql://localhost:3306/demo_ds_0?useSSL=false&useUnicode=true&characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"root"
/>
<property
name=
"password"
value=
""
/>
</bean>
<bean
id=
"demo_ds_1"
class=
"com.zaxxer.hikari.HikariDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"jdbcUrl"
value=
"jdbc:mysql://localhost:3306/demo_ds_1?useSSL=false&useUnicode=true&characterEncoding=UTF-8"
/>
<property
name=
"username"
value=
"root"
/>
<property
name=
"password"
value=
""
/>
</bean>
<sharding:inline-strategy
id=
"databaseStrategy"
sharding-column=
"user_id"
algorithm-expression=
"demo_ds_${user_id % 2}"
/>
<sharding:key-generator
id=
"orderKeyGenerator"
type=
"SNOWFLAKE"
column=
"order_id"
/>
<sharding:data-source
id=
"shardingDataSource"
>
<sharding:sharding-rule
data-source-names=
"demo_ds_0, demo_ds_1"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
database-strategy-ref=
"databaseStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
</sharding:data-source>
<bean
id=
"transactionManager"
class=
"org.springframework.jdbc.datasource.DataSourceTransactionManager"
>
<property
name=
"dataSource"
ref=
"shardingDataSource"
/>
</bean>
<tx:annotation-driven
/>
<bean
id=
"sqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"dataSource"
ref=
"shardingDataSource"
/>
<property
name=
"mapperLocations"
value=
"classpath*:META-INF/mappers/*.xml"
/>
</bean>
<bean
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"basePackage"
value=
"org.apache.shardingsphere.example.common.mybatis.repository"
/>
<property
name=
"sqlSessionFactoryBeanName"
value=
"sqlSessionFactory"
/>
</bean>
</beans>
sharding-jdbc-example/broadcast-table-example/broadcast-table-spring-namespace-example/src/main/resources/logback.xml
0 → 100644
浏览文件 @
4c9d34ea
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"log.context.name"
value=
"sharding-jdbc-spring-namespace-mybatis-quickstart"
/>
<property
name=
"log.charset"
value=
"UTF-8"
/>
<property
name=
"log.pattern"
value=
"[%-5level] %date --%thread-- [%logger] %msg %n"
/>
<contextName>
${log.context.name}
</contextName>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
charset=
"${log.charset}"
>
<pattern>
${log.pattern}
</pattern>
</encoder>
</appender>
<root>
<level
value=
"INFO"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/JavaConfigurationExample.java
浏览文件 @
4c9d34ea
...
...
@@ -17,11 +17,9 @@
package
org.apache.shardingsphere.example.sharding.raw.jdbc
;
import
org.apache.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl
;
import
org.apache.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl
;
import
org.apache.shardingsphere.example.common.jdbc.repository.OrderRepositoryImpl
;
import
org.apache.shardingsphere.example.common.jdbc.service.CommonServiceImpl
;
import
org.apache.shardingsphere.example.common.jdbc.service.CountryServiceImpl
;
import
org.apache.shardingsphere.example.common.service.CommonService
;
import
org.apache.shardingsphere.example.sharding.raw.jdbc.factory.DataSourceFactory
;
import
org.apache.shardingsphere.example.type.ShardingType
;
...
...
@@ -46,17 +44,9 @@ public class JavaConfigurationExample {
commonService
.
initEnvironment
();
commonService
.
processSuccess
();
commonService
.
cleanEnvironment
();
CommonService
countryService
=
getCountryService
(
dataSource
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
private
static
CommonService
getCommonService
(
final
DataSource
dataSource
)
{
return
new
CommonServiceImpl
(
new
OrderRepositoryImpl
(
dataSource
),
new
OrderItemRepositoryImpl
(
dataSource
));
}
private
static
CommonService
getCountryService
(
final
DataSource
dataSource
)
{
return
new
CountryServiceImpl
(
new
CountryRepositroyImpl
(
dataSource
));
}
}
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/YamlConfigurationExample.java
浏览文件 @
4c9d34ea
...
...
@@ -17,11 +17,9 @@
package
org.apache.shardingsphere.example.sharding.raw.jdbc
;
import
org.apache.shardingsphere.example.common.jdbc.repository.CountryRepositroyImpl
;
import
org.apache.shardingsphere.example.common.jdbc.repository.OrderItemRepositoryImpl
;
import
org.apache.shardingsphere.example.common.jdbc.repository.OrderRepositoryImpl
;
import
org.apache.shardingsphere.example.common.jdbc.service.CommonServiceImpl
;
import
org.apache.shardingsphere.example.common.jdbc.service.CountryServiceImpl
;
import
org.apache.shardingsphere.example.common.service.CommonService
;
import
org.apache.shardingsphere.example.sharding.raw.jdbc.factory.YamlDataSourceFactory
;
import
org.apache.shardingsphere.example.type.ShardingType
;
...
...
@@ -47,17 +45,9 @@ public class YamlConfigurationExample {
commonService
.
initEnvironment
();
commonService
.
processSuccess
();
commonService
.
cleanEnvironment
();
CommonService
countryService
=
getCountryService
(
dataSource
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
private
static
CommonService
getCommonService
(
final
DataSource
dataSource
)
{
return
new
CommonServiceImpl
(
new
OrderRepositoryImpl
(
dataSource
),
new
OrderItemRepositoryImpl
(
dataSource
));
}
private
static
CommonService
getCountryService
(
final
DataSource
dataSource
)
{
return
new
CountryServiceImpl
(
new
CountryRepositroyImpl
(
dataSource
));
}
}
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesAndTablesConfigurationPrecise.java
浏览文件 @
4c9d34ea
...
...
@@ -41,7 +41,6 @@ public final class ShardingDatabasesAndTablesConfigurationPrecise implements Exa
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
InlineShardingStrategyConfiguration
(
"user_id"
,
"demo_ds_${user_id % 2}"
));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
return
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
());
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesAndTablesConfigurationRange.java
浏览文件 @
4c9d34ea
...
...
@@ -43,7 +43,6 @@ public final class ShardingDatabasesAndTablesConfigurationRange implements Examp
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"user_id"
,
new
PreciseModuloShardingDatabaseAlgorithm
(),
new
RangeModuloShardingDatabaseAlgorithm
()));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationPrecise.java
浏览文件 @
4c9d34ea
...
...
@@ -38,7 +38,6 @@ public final class ShardingDatabasesConfigurationPrecise implements ExampleConfi
ShardingRuleConfiguration
shardingRuleConfig
=
new
ShardingRuleConfiguration
();
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
InlineShardingStrategyConfiguration
(
"user_id"
,
"demo_ds_${user_id % 2}"
));
return
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
());
}
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingDatabasesConfigurationRange.java
浏览文件 @
4c9d34ea
...
...
@@ -40,7 +40,6 @@ public final class ShardingDatabasesConfigurationRange implements ExampleConfigu
ShardingRuleConfiguration
shardingRuleConfig
=
new
ShardingRuleConfiguration
();
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"user_id"
,
new
PreciseModuloShardingDatabaseAlgorithm
(),
new
RangeModuloShardingDatabaseAlgorithm
()));
return
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
());
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingMasterSlaveConfigurationPrecise.java
浏览文件 @
4c9d34ea
...
...
@@ -45,7 +45,6 @@ public final class ShardingMasterSlaveConfigurationPrecise implements ExampleCon
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"user_id"
,
new
PreciseModuloShardingDatabaseAlgorithm
()));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
shardingRuleConfig
.
setMasterSlaveRuleConfigs
(
getMasterSlaveRuleConfigurations
());
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingMasterSlaveConfigurationRange.java
浏览文件 @
4c9d34ea
...
...
@@ -47,7 +47,6 @@ public final class ShardingMasterSlaveConfigurationRange implements ExampleConfi
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"user_id"
,
new
PreciseModuloShardingDatabaseAlgorithm
(),
new
RangeModuloShardingDatabaseAlgorithm
()));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingTablesConfigurationPrecise.java
浏览文件 @
4c9d34ea
...
...
@@ -40,7 +40,6 @@ public final class ShardingTablesConfigurationPrecise implements ExampleConfigur
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
return
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
());
}
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/sharding/raw/jdbc/config/ShardingTablesConfigurationRange.java
浏览文件 @
4c9d34ea
...
...
@@ -41,7 +41,6 @@ public final class ShardingTablesConfigurationRange implements ExampleConfigurat
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderTableRuleConfiguration
());
shardingRuleConfig
.
getTableRuleConfigs
().
add
(
getOrderItemTableRuleConfiguration
());
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_country"
);
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
(),
new
RangeModuloShardingTableAlgorithm
()));
return
ShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
());
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
浏览文件 @
4c9d34ea
...
...
@@ -24,9 +24,6 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
defaultDatabaseStrategy
:
standard
:
shardingColumn
:
user_id
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables-range.yaml
浏览文件 @
4c9d34ea
...
...
@@ -34,9 +34,6 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
defaultDatabaseStrategy
:
standard
:
shardingColumn
:
user_id
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
浏览文件 @
4c9d34ea
...
...
@@ -32,9 +32,6 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
defaultDatabaseStrategy
:
inline
:
shardingColumn
:
user_id
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
浏览文件 @
4c9d34ea
...
...
@@ -24,9 +24,6 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
defaultDatabaseStrategy
:
inline
:
shardingColumn
:
user_id
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-master-slave-range.yaml
浏览文件 @
4c9d34ea
...
...
@@ -54,15 +54,11 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
defaultDatabaseStrategy
:
standard
:
shardingColumn
:
user_id
preciseAlgorithmClassName
:
org.apache.shardingsphere.example.algorithm.PreciseModuloShardingDatabaseAlgorithm
rangeAlgorithmClassName
:
org.apache.shardingsphere.example.algorithm.RangeModuloShardingDatabaseAlgorithm
masterSlaveRules
:
ds_0
:
masterDataSourceName
:
ds_master_0
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-master-slave.yaml
浏览文件 @
4c9d34ea
...
...
@@ -52,14 +52,10 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
defaultDatabaseStrategy
:
inline
:
shardingColumn
:
user_id
algorithmExpression
:
ds_${user_id % 2}
masterSlaveRules
:
ds_0
:
masterDataSourceName
:
ds_master_0
...
...
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables-range.yaml
浏览文件 @
4c9d34ea
...
...
@@ -29,8 +29,6 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
props
:
sql.show
:
false
sharding-jdbc-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml
浏览文件 @
4c9d34ea
...
...
@@ -27,8 +27,6 @@ shardingRule:
column
:
order_item_id
bindingTables
:
-
t_order,t_order_item
broadcastTables
:
-
t_country
props
:
sql.show
:
false
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/SpringBootExample.java
浏览文件 @
4c9d34ea
...
...
@@ -18,7 +18,6 @@
package
org.apache.shardingsphere.example.sharding.spring.boot.jpa
;
import
org.apache.shardingsphere.example.common.jpa.service.JPACommonService
;
import
org.apache.shardingsphere.example.common.jpa.service.JPACountryService
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
...
...
@@ -35,8 +34,6 @@ public class SpringBootExample {
try
(
ConfigurableApplicationContext
applicationContext
=
SpringApplication
.
run
(
SpringBootExample
.
class
,
args
))
{
JPACommonService
commonService
=
applicationContext
.
getBean
(
JPACommonService
.
class
);
commonService
.
processSuccess
();
JPACountryService
countryService
=
applicationContext
.
getBean
(
JPACountryService
.
class
);
countryService
.
processSuccess
();
}
}
}
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
浏览文件 @
4c9d34ea
...
...
@@ -27,4 +27,3 @@ sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression
=
t_order_item_$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
浏览文件 @
4c9d34ea
...
...
@@ -21,4 +21,3 @@ sharding.jdbc.config.sharding.tables.t_order.key-generator.type=SNOWFLAKE
sharding.jdbc.config.sharding.tables.t_order_item.actual-data-nodes
=
ds_$->{0..1}.t_order_item
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-master-slave.properties
浏览文件 @
4c9d34ea
...
...
@@ -55,7 +55,6 @@ sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression
=
t_order_item_$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding.jdbc.config.sharding.master-slave-rules.ds_0.master-data-source-name
=
ds_master_0
sharding.jdbc.config.sharding.master-slave-rules.ds_0.slave-data-source-names
=
ds_master_0_slave_0, ds_master_0_slave_1
...
...
sharding-jdbc-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
浏览文件 @
4c9d34ea
...
...
@@ -17,4 +17,3 @@ sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression
=
t_order_item_$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/mybatis/SpringBootMybatisMain.java
浏览文件 @
4c9d34ea
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.example.sharding.spring.boot.mybatis
;
import
org.apache.shardingsphere.example.common.mybatis.service.SpringCountryService
;
import
org.apache.shardingsphere.example.common.mybatis.service.SpringPojoService
;
import
org.apache.shardingsphere.example.common.service.CommonService
;
import
org.mybatis.spring.annotation.MapperScan
;
...
...
@@ -38,10 +37,6 @@ public class SpringBootMybatisMain {
commonService
.
initEnvironment
();
commonService
.
processSuccess
();
commonService
.
cleanEnvironment
();
SpringCountryService
countryService
=
applicationContext
.
getBean
(
SpringCountryService
.
class
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
}
}
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
浏览文件 @
4c9d34ea
...
...
@@ -6,6 +6,5 @@
<mappers>
<mapper
resource=
"META-INF/mappers/OrderMapper.xml"
/>
<mapper
resource=
"META-INF/mappers/OrderItemMapper.xml"
/>
<mapper
resource=
"META-INF/mappers/CountryMapper.xml"
/>
</mappers>
</configuration>
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
浏览文件 @
4c9d34ea
...
...
@@ -25,4 +25,3 @@ sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression
=
t_order_item_$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
浏览文件 @
4c9d34ea
...
...
@@ -21,5 +21,4 @@ sharding.jdbc.config.sharding.tables.t_order.key-generator.type=SNOWFLAKE
sharding.jdbc.config.sharding.tables.t_order_item.actual-data-nodes
=
ds_$->{0..1}.t_order_item
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-master-slave.properties
浏览文件 @
4c9d34ea
...
...
@@ -47,7 +47,6 @@ sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression
=
t_order_item_$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding.jdbc.config.sharding.master-slave-rules.ds_0.master-data-source-name
=
ds_master_0
sharding.jdbc.config.sharding.master-slave-rules.ds_0.slave-data-source-names
=
ds_master_0_slave_0, ds_master_0_slave_1
...
...
sharding-jdbc-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
浏览文件 @
4c9d34ea
...
...
@@ -16,4 +16,3 @@ sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression
=
t_order_item_$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.column
=
order_item_id
sharding.jdbc.config.sharding.tables.t_order_item.key-generator.type
=
SNOWFLAKE
sharding.jdbc.config.sharding.broadcast-tables
=
t_country
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/jpa/SpringNamespaceJPAMain.java
浏览文件 @
4c9d34ea
...
...
@@ -18,7 +18,6 @@
package
org.apache.shardingsphere.example.sharding.spring.namespace.jpa
;
import
org.apache.shardingsphere.example.common.jpa.service.JPACommonService
;
import
org.apache.shardingsphere.example.common.jpa.service.JPACountryService
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
...
...
@@ -34,8 +33,6 @@ public class SpringNamespaceJPAMain {
try
(
ConfigurableApplicationContext
applicationContext
=
new
ClassPathXmlApplicationContext
(
CONFIG_FILE
))
{
JPACommonService
commonService
=
applicationContext
.
getBean
(
JPACommonService
.
class
);
commonService
.
processSuccess
();
JPACountryService
countryService
=
applicationContext
.
getBean
(
JPACountryService
.
class
);
countryService
.
processSuccess
();
}
}
}
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
浏览文件 @
4c9d34ea
...
...
@@ -62,9 +62,6 @@
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"demo_ds_${0..1}.t_order_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderTableStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
actual-data-nodes=
"demo_ds_${0..1}.t_order_item_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderItemTableStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop
key=
"sql.show"
>
false
</prop>
...
...
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
浏览文件 @
4c9d34ea
...
...
@@ -58,9 +58,6 @@
<sharding:table-rule
logic-table=
"t_order"
database-strategy-ref=
"databaseStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
database-strategy-ref=
"databaseStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
</sharding:data-source>
</beans>
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-master-slave.xml
浏览文件 @
4c9d34ea
...
...
@@ -100,9 +100,6 @@
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"demo_ds_ms_${0..1}.t_order_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderTableStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
actual-data-nodes=
"demo_ds_ms_${0..1}.t_order_item_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderItemTableStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop
key=
"sql.show"
>
false
</prop>
...
...
sharding-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
浏览文件 @
4c9d34ea
...
...
@@ -52,9 +52,6 @@
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"demo_ds.t_order_${0..1}"
table-strategy-ref=
"orderTableStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
actual-data-nodes=
"demo_ds.t_order_item_${0..1}"
table-strategy-ref=
"orderItemTableStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
</sharding:data-source>
</beans>
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/namespace/mybatis/SpringNamespaceExample.java
浏览文件 @
4c9d34ea
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.example.sharding.spring.namespace.mybatis
;
import
org.apache.shardingsphere.example.common.mybatis.service.SpringCountryService
;
import
org.apache.shardingsphere.example.common.mybatis.service.SpringPojoService
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
...
...
@@ -36,10 +35,6 @@ public class SpringNamespaceExample {
commonService
.
initEnvironment
();
commonService
.
processSuccess
();
commonService
.
cleanEnvironment
();
SpringCountryService
countryService
=
applicationContext
.
getBean
(
SpringCountryService
.
class
);
countryService
.
initEnvironment
();
countryService
.
processSuccess
();
countryService
.
cleanEnvironment
();
}
}
}
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
浏览文件 @
4c9d34ea
...
...
@@ -41,9 +41,6 @@
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"demo_ds_${0..1}.t_order_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderTableStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
actual-data-nodes=
"demo_ds_${0..1}.t_order_item_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderItemTableStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop
key=
"sql.show"
>
false
</prop>
...
...
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
浏览文件 @
4c9d34ea
...
...
@@ -39,9 +39,6 @@
<sharding:table-rule
logic-table=
"t_order"
database-strategy-ref=
"databaseStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
database-strategy-ref=
"databaseStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
</sharding:data-source>
...
...
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-master-slave.xml
浏览文件 @
4c9d34ea
...
...
@@ -75,9 +75,6 @@
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"demo_ds_ms_${0..1}.t_order_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderTableStrategy"
key-generator-ref=
"orderKeyGenerator"
/>
<sharding:table-rule
logic-table=
"t_order_item"
actual-data-nodes=
"demo_ds_ms_${0..1}.t_order_item_${0..1}"
database-strategy-ref=
"databaseStrategy"
table-strategy-ref=
"orderItemTableStrategy"
key-generator-ref=
"itemKeyGenerator"
/>
</sharding:table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop
key=
"sql.show"
>
false
</prop>
...
...
sharding-jdbc-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
浏览文件 @
4c9d34ea
...
...
@@ -36,9 +36,6 @@
<sharding:binding-table-rules>
<sharding:binding-table-rule
logic-tables=
"t_order, t_order_item"
/>
</sharding:binding-table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_country"
/>
</sharding:broadcast-table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop
key=
"sql.show"
>
false
</prop>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录