20260108:

1、去掉shardingShpere
This commit is contained in:
George 2026-01-08 23:41:07 +08:00
parent ab82d28a2e
commit 52925ad284
10 changed files with 229 additions and 376 deletions

View File

@ -44,56 +44,58 @@ spring:
# url: jdbc:mysql://1.116.124.85:3306/fastbee1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://1.116.124.85:3306/fastbee1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root # username: root
# password: fastbee # password: fastbee
shardingsphere: # ===== ShardingSphere 分库分表配置(已禁用)=====
# 如需启用分库分表,请取消以下注释
# shardingsphere:
# # props:
# # 是否显示 ShardingSpher 的sql,用于Debug
# # sql-show: true
# datasource:
# # 配置真实数据源
# names: ds0
# ds0: # 配置 mysql 数据源
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: fastbee
# filters: stat,wall
# filter:
# stat:
# enabled: true
# # 慢SQL记录
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
#
# rules: # 配置表规则
# sharding:
# # 表策略配置
# tables:
# # iot_device_log 是逻辑表
# iot_device_log:
# actualDataNodes: ds0.iot_device_log_$->{2024..2030}0$->{1..9},ds0.iot_device_log_$->{2024..2030}1$->{0..2}
# tableStrategy:
# # 使用标准分片策略
# standard:
# # 配置分片字段
# shardingColumn: create_time
# # 分片算法名称,不支持大写字母和下划线,否则启动就会报错
# shardingAlgorithmName: time-sharding-algorithm
# # 分片算法配置
# shardingAlgorithms:
# # 分片算法名称,不支持大写字母和下划线,否则启动就会报错
# time-sharding-algorithm:
# # 类型:自定义策略
# type: CLASS_BASED
# props: # props:
# 是否显示 ShardingSpher 的sql,用于Debug # # 分片策略
# sql-show: true # strategy: standard
datasource: # # 分片算法类
# 配置真实数据源 # algorithmClassName: com.fastbee.framework.config.sharding.TimeShardingAlgorithm
names: ds0
ds0: # 配置 mysql 数据源
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: fastbee
filters: stat,wall
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
rules: # 配置表规则
sharding:
# 表策略配置
tables:
# iot_device_log 是逻辑表
iot_device_log:
actualDataNodes: ds0.iot_device_log_$->{2024..2030}0$->{1..9},ds0.iot_device_log_$->{2024..2030}1$->{0..2}
tableStrategy:
# 使用标准分片策略
standard:
# 配置分片字段
shardingColumn: create_time
# 分片算法名称,不支持大写字母和下划线,否则启动就会报错
shardingAlgorithmName: time-sharding-algorithm
# 分片算法配置
shardingAlgorithms:
# 分片算法名称,不支持大写字母和下划线,否则启动就会报错
time-sharding-algorithm:
# 类型:自定义策略
type: CLASS_BASED
props:
# 分片策略
strategy: standard
# 分片算法类
algorithmClassName: com.fastbee.framework.config.sharding.TimeShardingAlgorithm
# redis 配置 # redis 配置

View File

@ -44,56 +44,58 @@ spring:
# url: jdbc:mysql://localhost:3306/fastbee1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://localhost:3306/fastbee1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root # username: root
# password: fastbee # password: fastbee
shardingsphere: # ===== ShardingSphere 分库分表配置(已禁用)=====
# 如需启用分库分表,请取消以下注释
# shardingsphere:
# # props:
# # 是否显示 ShardingSpher 的sql,用于Debug
# # sql-show: true
# datasource:
# # 配置真实数据源
# names: ds0
# ds0: # 配置 mysql 数据源
# type: com.alibaba.druid.pool.DruidDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://177.7.0.11:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: fastbee
# filters: stat,wall
# filter:
# stat:
# enabled: true
# # 慢SQL记录
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
#
# rules: # 配置表规则
# sharding:
# # 表策略配置
# tables:
# # iot_device_log 是逻辑表
# iot_device_log:
# actualDataNodes: ds0.iot_device_log_$->{2024..2030}0$->{1..9},ds0.iot_device_log_$->{2024..2030}1$->{0..2}
# tableStrategy:
# # 使用标准分片策略
# standard:
# # 配置分片字段
# shardingColumn: create_time
# # 分片算法名称,不支持大写字母和下划线,否则启动就会报错
# shardingAlgorithmName: time-sharding-algorithm
# # 分片算法配置
# shardingAlgorithms:
# # 分片算法名称,不支持大写字母和下划线,否则启动就会报错
# time-sharding-algorithm:
# # 类型:自定义策略
# type: CLASS_BASED
# props: # props:
# 是否显示 ShardingSpher 的sql,用于Debug # # 分片策略
# sql-show: true # strategy: standard
datasource: # # 分片算法类
# 配置真实数据源 # algorithmClassName: com.fastbee.framework.config.sharding.TimeShardingAlgorithm
names: ds0
ds0: # 配置 mysql 数据源
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://177.7.0.11:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: fastbee
filters: stat,wall
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
rules: # 配置表规则
sharding:
# 表策略配置
tables:
# iot_device_log 是逻辑表
iot_device_log:
actualDataNodes: ds0.iot_device_log_$->{2024..2030}0$->{1..9},ds0.iot_device_log_$->{2024..2030}1$->{0..2}
tableStrategy:
# 使用标准分片策略
standard:
# 配置分片字段
shardingColumn: create_time
# 分片算法名称,不支持大写字母和下划线,否则启动就会报错
shardingAlgorithmName: time-sharding-algorithm
# 分片算法配置
shardingAlgorithms:
# 分片算法名称,不支持大写字母和下划线,否则启动就会报错
time-sharding-algorithm:
# 类型:自定义策略
type: CLASS_BASED
props:
# 分片策略
strategy: standard
# 分片算法类
algorithmClassName: com.fastbee.framework.config.sharding.TimeShardingAlgorithm
# redis 配置 # redis 配置
redis: redis:
host: 177.7.0.10 # 地址 host: 177.7.0.10 # 地址

View File

@ -71,56 +71,58 @@ spring:
# username: root # username: root
# password: fastbee # password: fastbee
shardingsphere: # ===== ShardingSphere 分库分表配置(已禁用)=====
props: # 如需启用分库分表,请取消以下注释
# 是否显示 ShardingSpher 的sql,用于Debug # shardingsphere:
sql-show: true # props:
datasource: # # 是否显示 ShardingSpher 的sql,用于Debug
# 配置真实数据源 # sql-show: true
names: ds0 # datasource:
ds0: # 配置 mysql 数据源 # # 配置真实数据源
type: com.alibaba.druid.pool.DruidDataSource # names: ds0
driver-class-name: com.mysql.cj.jdbc.Driver # ds0: # 配置 mysql 数据源
url: jdbc:mysql://localhost:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # type: com.alibaba.druid.pool.DruidDataSource
username: root # driver-class-name: com.mysql.cj.jdbc.Driver
password: fastbee # url: jdbc:mysql://localhost:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
filters: stat,wall # username: root
filter: # password: fastbee
stat: # filters: stat,wall
enabled: true # filter:
# 慢SQL记录 # stat:
log-slow-sql: true # enabled: true
slow-sql-millis: 1000 # # 慢SQL记录
merge-sql: true # log-slow-sql: true
wall: # slow-sql-millis: 1000
config: # merge-sql: true
multi-statement-allow: true # wall:
# config:
rules: # 配置表规则 # multi-statement-allow: true
sharding: #
# 表策略配置 # rules: # 配置表规则
tables: # sharding:
# iot_device_log 是逻辑表 # # 表策略配置
iot_device_log: # tables:
actualDataNodes: ds0.iot_device_log_$->{2024..2030}0$->{1..9},ds0.iot_device_log_$->{2024..2030}1$->{0..2} # # iot_device_log 是逻辑表
tableStrategy: # iot_device_log:
# 使用标准分片策略 # actualDataNodes: ds0.iot_device_log_$->{2024..2030}0$->{1..9},ds0.iot_device_log_$->{2024..2030}1$->{0..2}
standard: # tableStrategy:
# 配置分片字段 # # 使用标准分片策略
shardingColumn: create_time # standard:
# 分片算法名称,不支持大写字母和下划线,否则启动就会报错 # # 配置分片字段
shardingAlgorithmName: time-sharding-algorithm # shardingColumn: create_time
# 分片算法配置 # # 分片算法名称,不支持大写字母和下划线,否则启动就会报错
shardingAlgorithms: # shardingAlgorithmName: time-sharding-algorithm
# 分片算法名称,不支持大写字母和下划线,否则启动就会报错 # # 分片算法配置
time-sharding-algorithm: # shardingAlgorithms:
# 类型:自定义策略 # # 分片算法名称,不支持大写字母和下划线,否则启动就会报错
type: CLASS_BASED # time-sharding-algorithm:
props: # # 类型:自定义策略
# 分片策略 # type: CLASS_BASED
strategy: standard # props:
# 分片算法类 # # 分片策略
algorithmClassName: com.fastbee.framework.config.sharding.TimeShardingAlgorithm # strategy: standard
# # 分片算法类
# algorithmClassName: com.fastbee.framework.config.sharding.TimeShardingAlgorithm
# redis 配置 # redis 配置
redis: redis:

View File

@ -42,18 +42,24 @@
<version>${druid.version}</version> <version>${druid.version}</version>
</dependency> </dependency>
<!-- ===== ShardingSphere 分库分表依赖(已禁用)===== -->
<!-- 如需启用分库分表,请取消以下注释 -->
<!--
<dependency> <dependency>
<groupId>org.apache.shardingsphere</groupId> <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId> <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>${shardingsphere.version}</version> <version>${shardingsphere.version}</version>
</dependency> </dependency>
-->
<!-- ShardingJDBC 5.1.0使用druid连接池需要加dbcp依赖 --> <!-- ShardingJDBC 5.1.0使用druid连接池需要加dbcp依赖(已禁用)-->
<!--
<dependency> <dependency>
<groupId>org.apache.tomcat</groupId> <groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId> <artifactId>tomcat-dbcp</artifactId>
<version>10.0.16</version> <version>10.0.16</version>
</dependency> </dependency>
-->
<!-- 动态数据源 --> <!-- 动态数据源 -->
<dependency> <dependency>

View File

@ -7,7 +7,7 @@ import com.baomidou.dynamic.datasource.provider.AbstractDataSourceProvider;
import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;
import org.springframework.beans.factory.annotation.Qualifier; // import org.springframework.beans.factory.annotation.Qualifier; // ShardingSphere 已禁用
import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
@ -28,14 +28,17 @@ public class DataSourceConfig {
private final DynamicDataSourceProperties properties; private final DynamicDataSourceProperties properties;
private final DefaultDataSourceCreator dataSourceCreator; private final DefaultDataSourceCreator dataSourceCreator;
private final DataSource shardingSphereDataSource; // ===== ShardingSphere 已禁用 =====
// private final DataSource shardingSphereDataSource;
public DataSourceConfig(DynamicDataSourceProperties properties, public DataSourceConfig(DynamicDataSourceProperties properties,
DefaultDataSourceCreator dataSourceCreator, DefaultDataSourceCreator dataSourceCreator
@Qualifier("shardingSphereDataSource") DataSource shardingSphereDataSource) { // ===== ShardingSphere 已禁用 =====
// @Qualifier("shardingSphereDataSource") DataSource shardingSphereDataSource
) {
this.properties = properties; this.properties = properties;
this.dataSourceCreator = dataSourceCreator; this.dataSourceCreator = dataSourceCreator;
this.shardingSphereDataSource = shardingSphereDataSource; // this.shardingSphereDataSource = shardingSphereDataSource;
} }
@Bean(name = "masterDataSource") @Bean(name = "masterDataSource")
@ -56,8 +59,9 @@ public class DataSourceConfig {
@Override @Override
public Map<String, DataSource> loadDataSources() { public Map<String, DataSource> loadDataSources() {
Map<String, DataSource> dataSourceMap = new HashMap<>(); Map<String, DataSource> dataSourceMap = new HashMap<>();
// ===== ShardingSphere 已禁用 =====
// 把 shardingSphereDataSource 加入多数据源,到时候使用的时候就可以 `@DS("shardingSphere")` // 把 shardingSphereDataSource 加入多数据源,到时候使用的时候就可以 `@DS("shardingSphere")`
dataSourceMap.put("shardingSphere", shardingSphereDataSource); // dataSourceMap.put("shardingSphere", shardingSphereDataSource);
return dataSourceMap; return dataSourceMap;
} }
}; };

View File

@ -1,5 +1,12 @@
package com.fastbee.framework.config.sharding; package com.fastbee.framework.config.sharding;
/**
* ===== ShardingSphere 已禁用 =====
* 如需启用分库分表,请取消以下注释并恢复 pom.xml 中的依赖
*/
/*
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.druid.util.StringUtils; import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@ -18,152 +25,80 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/**
* <p> @Title ShardingAlgorithmTool
* <p> @Description 按月分片算法工具
*/
@Slf4j @Slf4j
public class ShardingAlgorithmTool { public class ShardingAlgorithmTool {
/**
* 表分片符号,例:siot_device_log_202201 中,分片符号为 "_"
*/
private static final String TABLE_SPLIT_SYMBOL = "_"; private static final String TABLE_SPLIT_SYMBOL = "_";
/**
* 数据库配置
*/
private static final Environment ENV = SpringUtil.getApplicationContext().getEnvironment(); private static final Environment ENV = SpringUtil.getApplicationContext().getEnvironment();
private static final String DATASOURCE_URL = ENV.getProperty("spring.shardingsphere.datasource.ds0.url"); private static final String DATASOURCE_URL = ENV.getProperty("spring.shardingsphere.datasource.ds0.url");
private static final String DATASOURCE_USERNAME = ENV.getProperty("spring.shardingsphere.datasource.ds0.username"); private static final String DATASOURCE_USERNAME = ENV.getProperty("spring.shardingsphere.datasource.ds0.username");
private static final String DATASOURCE_PASSWORD = ENV.getProperty("spring.shardingsphere.datasource.ds0.password"); private static final String DATASOURCE_PASSWORD = ENV.getProperty("spring.shardingsphere.datasource.ds0.password");
/**
* 检查分表获取的表名是否存在,不存在则自动建表
*
* @param logicTable 逻辑表
* @param resultTableNames 真实表名,例:iot_device_log_202201
* @return 存在于数据库中的真实表名集合
*/
public static Set<String> getShardingTablesAndCreate(ShardingTableCacheEnum logicTable, Collection<String> resultTableNames) { public static Set<String> getShardingTablesAndCreate(ShardingTableCacheEnum logicTable, Collection<String> resultTableNames) {
return resultTableNames.stream().map(o -> getShardingTableAndCreate(logicTable, o)).collect(Collectors.toSet()); return resultTableNames.stream().map(o -> getShardingTableAndCreate(logicTable, o)).collect(Collectors.toSet());
} }
/**
* 检查分表获取的表名是否存在,不存在则自动建表
*
* @param logicTable 逻辑表
* @param resultTableName 真实表名,例:iot_device_log_202201
* @return 确认存在于数据库中的真实表名
*/
public static String getShardingTableAndCreate(ShardingTableCacheEnum logicTable, String resultTableName) { public static String getShardingTableAndCreate(ShardingTableCacheEnum logicTable, String resultTableName) {
// 缓存中有此表则返回,没有则判断创建
if (logicTable.resultTableNamesCache().contains(resultTableName)) { if (logicTable.resultTableNamesCache().contains(resultTableName)) {
return resultTableName; return resultTableName;
} else { } else {
// 未创建的表返回逻辑空表
boolean isSuccess = createShardingTable(logicTable, resultTableName); boolean isSuccess = createShardingTable(logicTable, resultTableName);
return isSuccess ? resultTableName : logicTable.logicTableName(); return isSuccess ? resultTableName : logicTable.logicTableName();
} }
} }
/**
* 重载全部缓存
*/
public static void tableNameCacheReloadAll() { public static void tableNameCacheReloadAll() {
Arrays.stream(ShardingTableCacheEnum.values()).forEach(ShardingAlgorithmTool::tableNameCacheReload); Arrays.stream(ShardingTableCacheEnum.values()).forEach(ShardingAlgorithmTool::tableNameCacheReload);
} }
/**
* 重载指定分表缓存
*
* @param logicTable 逻辑表
*/
public static void tableNameCacheReload(ShardingTableCacheEnum logicTable) { public static void tableNameCacheReload(ShardingTableCacheEnum logicTable) {
// 读取数据库中所有表名
List<String> tableNameList = getAllTableNameBySchema(logicTable); List<String> tableNameList = getAllTableNameBySchema(logicTable);
// 更新缓存、配置(原子操作)
logicTable.atomicUpdateCacheAndActualDataNodes(tableNameList); logicTable.atomicUpdateCacheAndActualDataNodes(tableNameList);
// 删除旧的缓存(如果存在)
logicTable.resultTableNamesCache().clear(); logicTable.resultTableNamesCache().clear();
// 写入新的缓存
logicTable.resultTableNamesCache().addAll(tableNameList); logicTable.resultTableNamesCache().addAll(tableNameList);
// 动态更新配置 actualDataNodes
actualDataNodesRefresh(logicTable.logicTableName(), tableNameList); actualDataNodesRefresh(logicTable.logicTableName(), tableNameList);
} }
/**
* 获取所有表名
*
* @param logicTable 逻辑表
* @return 表名集合
*/
public static List<String> getAllTableNameBySchema(ShardingTableCacheEnum logicTable) { public static List<String> getAllTableNameBySchema(ShardingTableCacheEnum logicTable) {
List<String> tableNames = new ArrayList<>(); List<String> tableNames = new ArrayList<>();
if (StringUtils.isEmpty(DATASOURCE_URL) || StringUtils.isEmpty(DATASOURCE_USERNAME) || StringUtils.isEmpty(DATASOURCE_PASSWORD)) { if (StringUtils.isEmpty(DATASOURCE_URL) || StringUtils.isEmpty(DATASOURCE_USERNAME) || StringUtils.isEmpty(DATASOURCE_PASSWORD)) {
log.error(">>>>>>>>>> 【ERROR】数据库连接配置有误,请稍后重试,URL:{}, username:{}, password:{}", DATASOURCE_URL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD); log.error(">>>>>>>>>> 【ERROR】数据库连接配置有误");
throw new IllegalArgumentException("数据库连接配置有误,请稍后重试"); throw new IllegalArgumentException("数据库连接配置有误");
} }
try (Connection conn = DriverManager.getConnection(DATASOURCE_URL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD); try (Connection conn = DriverManager.getConnection(DATASOURCE_URL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD);
Statement st = conn.createStatement()) { Statement st = conn.createStatement()) {
String logicTableName = logicTable.logicTableName(); String logicTableName = logicTable.logicTableName();
try (ResultSet rs = st.executeQuery("show TABLES like '" + logicTableName + TABLE_SPLIT_SYMBOL + "%'")) { try (ResultSet rs = st.executeQuery("show TABLES like '" + logicTableName + TABLE_SPLIT_SYMBOL + "%'")) {
log.info("查询数据库所有表:{}", "show TABLES like '" + logicTableName + TABLE_SPLIT_SYMBOL + "%'");
while (rs.next()) { while (rs.next()) {
String tableName = rs.getString(1); String tableName = rs.getString(1);
log.info("分表格式:{}", String.format("^(%s\\d{6})$", logicTableName + TABLE_SPLIT_SYMBOL));
// 匹配分表格式 例:^(t\_contract_\d{6})$
if (org.apache.commons.lang3.StringUtils.isNotBlank(tableName) && tableName.matches(String.format("^(%s\\d{6})$", logicTableName + TABLE_SPLIT_SYMBOL))) { if (org.apache.commons.lang3.StringUtils.isNotBlank(tableName) && tableName.matches(String.format("^(%s\\d{6})$", logicTableName + TABLE_SPLIT_SYMBOL))) {
tableNames.add(rs.getString(1)); tableNames.add(rs.getString(1));
} }
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
log.error(">>>>>>>>>> 【ERROR】数据库连接失败,请稍后重试,原因:{}", e.getMessage(), e); log.error(">>>>>>>>>> 【ERROR】数据库连接失败", e);
throw new IllegalArgumentException("数据库连接失败,请稍后重试"); throw new IllegalArgumentException("数据库连接失败");
} }
return tableNames; return tableNames;
} }
/**
* 动态更新配置 actualDataNodes
*
* @param logicTableName 逻辑表名
* @param tableNamesCache 真实表名集合
*/
public static void actualDataNodesRefresh(String logicTableName, List<String> tableNamesCache) { public static void actualDataNodesRefresh(String logicTableName, List<String> tableNamesCache) {
try { try {
if (CollectionUtils.isEmpty(tableNamesCache)) { if (CollectionUtils.isEmpty(tableNamesCache)) {
return; return;
} }
// 获取数据分片节点
String dbName = "ds0"; String dbName = "ds0";
log.info(">>>>>>>>>> 【INFO】更新分表配置,logicTableName:{},tableNamesCache:{}", logicTableName, tableNamesCache);
// generate actualDataNodes
String newActualDataNodes = tableNamesCache.stream().map(o -> String.format("%s.%s", dbName, o)).collect(Collectors.joining(",")); String newActualDataNodes = tableNamesCache.stream().map(o -> String.format("%s.%s", dbName, o)).collect(Collectors.joining(","));
ShardingSphereDataSource shardingSphereDataSource = SpringUtil.getBean(ShardingSphereDataSource.class); ShardingSphereDataSource shardingSphereDataSource = SpringUtil.getBean(ShardingSphereDataSource.class);
updateShardRuleActualDataNodes(shardingSphereDataSource, logicTableName, newActualDataNodes); updateShardRuleActualDataNodes(shardingSphereDataSource, logicTableName, newActualDataNodes);
} catch (Exception e) { } catch (Exception e) {
log.error("初始化 动态表单失败,原因:{}", e.getMessage(), e); log.error("初始化 动态表单失败", e);
} }
} }
// --------------------------------------------------------------------------------------------------------------
// 私有方法
// --------------------------------------------------------------------------------------------------------------
/**
* 刷新ActualDataNodes
*/
private static void updateShardRuleActualDataNodes(ShardingSphereDataSource dataSource, String logicTableName, String newActualDataNodes) { private static void updateShardRuleActualDataNodes(ShardingSphereDataSource dataSource, String logicTableName, String newActualDataNodes) {
// Context manager.
ContextManager contextManager = dataSource.getContextManager(); ContextManager contextManager = dataSource.getContextManager();
// Rule configuration.
String schemaName = "logic_db"; String schemaName = "logic_db";
Collection<RuleConfiguration> newRuleConfigList = new LinkedList<>(); Collection<RuleConfiguration> newRuleConfigList = new LinkedList<>();
Collection<RuleConfiguration> oldRuleConfigList = dataSource.getContextManager() Collection<RuleConfiguration> oldRuleConfigList = dataSource.getContextManager()
@ -174,12 +109,8 @@ public class ShardingAlgorithmTool {
for (RuleConfiguration oldRuleConfig : oldRuleConfigList) { for (RuleConfiguration oldRuleConfig : oldRuleConfigList) {
if (oldRuleConfig instanceof AlgorithmProvidedShardingRuleConfiguration) { if (oldRuleConfig instanceof AlgorithmProvidedShardingRuleConfiguration) {
// Algorithm provided sharding rule configuration
AlgorithmProvidedShardingRuleConfiguration oldAlgorithmConfig = (AlgorithmProvidedShardingRuleConfiguration) oldRuleConfig; AlgorithmProvidedShardingRuleConfiguration oldAlgorithmConfig = (AlgorithmProvidedShardingRuleConfiguration) oldRuleConfig;
AlgorithmProvidedShardingRuleConfiguration newAlgorithmConfig = new AlgorithmProvidedShardingRuleConfiguration(); AlgorithmProvidedShardingRuleConfiguration newAlgorithmConfig = new AlgorithmProvidedShardingRuleConfiguration();
// Sharding table rule configuration Collection
Collection<ShardingTableRuleConfiguration> newTableRuleConfigList = new LinkedList<>(); Collection<ShardingTableRuleConfiguration> newTableRuleConfigList = new LinkedList<>();
Collection<ShardingTableRuleConfiguration> oldTableRuleConfigList = oldAlgorithmConfig.getTables(); Collection<ShardingTableRuleConfiguration> oldTableRuleConfigList = oldAlgorithmConfig.getTables();
@ -189,7 +120,6 @@ public class ShardingAlgorithmTool {
newTableRuleConfig.setTableShardingStrategy(oldTableRuleConfig.getTableShardingStrategy()); newTableRuleConfig.setTableShardingStrategy(oldTableRuleConfig.getTableShardingStrategy());
newTableRuleConfig.setDatabaseShardingStrategy(oldTableRuleConfig.getDatabaseShardingStrategy()); newTableRuleConfig.setDatabaseShardingStrategy(oldTableRuleConfig.getDatabaseShardingStrategy());
newTableRuleConfig.setKeyGenerateStrategy(oldTableRuleConfig.getKeyGenerateStrategy()); newTableRuleConfig.setKeyGenerateStrategy(oldTableRuleConfig.getKeyGenerateStrategy());
newTableRuleConfigList.add(newTableRuleConfig); newTableRuleConfigList.add(newTableRuleConfig);
} else { } else {
newTableRuleConfigList.add(oldTableRuleConfig); newTableRuleConfigList.add(oldTableRuleConfig);
@ -209,48 +139,28 @@ public class ShardingAlgorithmTool {
newRuleConfigList.add(newAlgorithmConfig); newRuleConfigList.add(newAlgorithmConfig);
} }
} }
// update context
contextManager.alterRuleConfiguration(schemaName, newRuleConfigList); contextManager.alterRuleConfiguration(schemaName, newRuleConfigList);
} }
/**
* 创建分表
*
* @param logicTable 逻辑表
* @param resultTableName 真实表名,例:sys_user_behavior_202201
* @return 创建结果(true创建成功,false未创建)
*/
private static boolean createShardingTable(ShardingTableCacheEnum logicTable, String resultTableName) { private static boolean createShardingTable(ShardingTableCacheEnum logicTable, String resultTableName) {
// 根据日期判断,当前月份之后分表不提前创建
String month = resultTableName.replace(logicTable.logicTableName() + TABLE_SPLIT_SYMBOL, ""); String month = resultTableName.replace(logicTable.logicTableName() + TABLE_SPLIT_SYMBOL, "");
YearMonth shardingMonth = YearMonth.parse(month, DateTimeFormatter.ofPattern("yyyyMM")); YearMonth shardingMonth = YearMonth.parse(month, DateTimeFormatter.ofPattern("yyyyMM"));
if (shardingMonth.isAfter(YearMonth.now())) { if (shardingMonth.isAfter(YearMonth.now())) {
return false; return false;
} }
synchronized (logicTable.logicTableName().intern()) { synchronized (logicTable.logicTableName().intern()) {
// 缓存中有此表 返回
if (logicTable.resultTableNamesCache().contains(resultTableName)) { if (logicTable.resultTableNamesCache().contains(resultTableName)) {
return false; return false;
} }
// 缓存中无此表,则建表并添加缓存
executeSql(Collections.singletonList("CREATE TABLE IF NOT EXISTS `" + resultTableName + "` LIKE `" + logicTable.logicTableName() + "`;")); executeSql(Collections.singletonList("CREATE TABLE IF NOT EXISTS `" + resultTableName + "` LIKE `" + logicTable.logicTableName() + "`;"));
// 缓存重载
tableNameCacheReload(logicTable); tableNameCacheReload(logicTable);
} }
return true; return true;
} }
/**
* 执行SQL
*
* @param sqlList SQL集合
*/
private static void executeSql(List<String> sqlList) { private static void executeSql(List<String> sqlList) {
if (StringUtils.isEmpty(DATASOURCE_URL) || StringUtils.isEmpty(DATASOURCE_USERNAME) || StringUtils.isEmpty(DATASOURCE_PASSWORD)) { if (StringUtils.isEmpty(DATASOURCE_URL) || StringUtils.isEmpty(DATASOURCE_USERNAME) || StringUtils.isEmpty(DATASOURCE_PASSWORD)) {
log.error(">>>>>>>>>> 【ERROR】数据库连接配置有误,请稍后重试,URL:{}, username:{}, password:{}", DATASOURCE_URL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD); throw new IllegalArgumentException("数据库连接配置有误");
throw new IllegalArgumentException("数据库连接配置有误,请稍后重试");
} }
try (Connection conn = DriverManager.getConnection(DATASOURCE_URL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD)) { try (Connection conn = DriverManager.getConnection(DATASOURCE_URL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD)) {
try (Statement st = conn.createStatement()) { try (Statement st = conn.createStatement()) {
@ -260,12 +170,12 @@ public class ShardingAlgorithmTool {
} }
} catch (Exception e) { } catch (Exception e) {
conn.rollback(); conn.rollback();
log.error(">>>>>>>>>> 【ERROR】数据表创建执行失败,请稍后重试,原因:{}", e.getMessage(), e); throw new IllegalArgumentException("数据表创建执行失败");
throw new IllegalArgumentException("数据表创建执行失败,请稍后重试");
} }
} catch (SQLException e) { } catch (SQLException e) {
log.error(">>>>>>>>>> 【ERROR】数据库连接失败,请稍后重试,原因:{}", e.getMessage(), e); throw new IllegalArgumentException("数据库连接失败");
throw new IllegalArgumentException("数据库连接失败,请稍后重试");
} }
} }
} }
*/

View File

@ -1,14 +1,17 @@
package com.fastbee.framework.config.sharding; package com.fastbee.framework.config.sharding;
/**
* ===== ShardingSphere 已禁用 =====
* 如需启用分库分表,请取消以下注释并恢复 pom.xml 中的依赖
*/
/*
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** @Order(value = 1)
* <p> @Title ShardingTablesLoadRunner
* <p> @Description 项目启动后,读取已有分表,进行缓存
*/
@Order(value = 1) // 数字越小,越先执行
@Component @Component
public class ShardingTablesLoadRunner implements CommandLineRunner { public class ShardingTablesLoadRunner implements CommandLineRunner {
@ -18,3 +21,5 @@ public class ShardingTablesLoadRunner implements CommandLineRunner {
// ShardingAlgorithmTool.tableNameCacheReloadAll(); // ShardingAlgorithmTool.tableNameCacheReloadAll();
} }
} }
*/

View File

@ -1,5 +1,12 @@
package com.fastbee.framework.config.sharding; package com.fastbee.framework.config.sharding;
/**
* ===== ShardingSphere 已禁用 =====
* 如需启用分库分表,请取消以下注释并恢复 pom.xml 中的依赖
*/
/*
import com.fastbee.framework.config.sharding.enums.ShardingTableCacheEnum; import com.fastbee.framework.config.sharding.enums.ShardingTableCacheEnum;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -17,91 +24,44 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
/**
* <p> @Title TimeShardingAlgorithm
* <p> @Description 分片算法,按月分片
*/
@Slf4j @Slf4j
public class TimeShardingAlgorithm implements StandardShardingAlgorithm<Date> { public class TimeShardingAlgorithm implements StandardShardingAlgorithm<Date> {
/**
* Date类型的分片时间格式
*/
private static final SimpleDateFormat TABLE_SHARD_Date_FORMATTER = new SimpleDateFormat("yyyyMM"); private static final SimpleDateFormat TABLE_SHARD_Date_FORMATTER = new SimpleDateFormat("yyyyMM");
/**
* 分片时间格式
*/
private static final DateTimeFormatter TABLE_SHARD_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM"); private static final DateTimeFormatter TABLE_SHARD_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
/**
* 完整时间格式
*/
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss"); private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss");
/**
* 完整时间格式
*/
private static final SimpleDateFormat DATE_TIME_FORMATTER_SPILE = new SimpleDateFormat("yyyy-MM-dd"); private static final SimpleDateFormat DATE_TIME_FORMATTER_SPILE = new SimpleDateFormat("yyyy-MM-dd");
/**
* 表分片符号,例:t_user_202201 中,分片符号为 "_"
*/
private final String TABLE_SPLIT_SYMBOL = "_"; private final String TABLE_SPLIT_SYMBOL = "_";
/**
* 精准分片
*
* @param tableNames 对应分片库中所有分片表的集合
* @param preciseShardingValue 分片键值,其中 logicTableName 为逻辑表,columnName 分片键,value 为从 SQL 中解析出来的分片键的值
* @return 表名
*/
@Override @Override
public String doSharding(Collection<String> tableNames, PreciseShardingValue<Date> preciseShardingValue) { public String doSharding(Collection<String> tableNames, PreciseShardingValue<Date> preciseShardingValue) {
String logicTableName = preciseShardingValue.getLogicTableName(); String logicTableName = preciseShardingValue.getLogicTableName();
ShardingTableCacheEnum logicTable = ShardingTableCacheEnum.of(logicTableName); ShardingTableCacheEnum logicTable = ShardingTableCacheEnum.of(logicTableName);
createAllTable(logicTable, tableNames); createAllTable(logicTable, tableNames);
/// 打印分片信息
log.info(">>>>>>>>>> 【INFO】精确分片,节点配置表名:{},数据库缓存表名:{}", tableNames, logicTable.resultTableNamesCache()); log.info(">>>>>>>>>> 【INFO】精确分片,节点配置表名:{},数据库缓存表名:{}", tableNames, logicTable.resultTableNamesCache());
Date date = preciseShardingValue.getValue(); Date date = preciseShardingValue.getValue();
Instant instant = date.toInstant(); Instant instant = date.toInstant();
LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
String resultTableName = logicTableName + "_" + TABLE_SHARD_TIME_FORMATTER.format(localDateTime); String resultTableName = logicTableName + "_" + TABLE_SHARD_TIME_FORMATTER.format(localDateTime);
// 检查分表获取的表名是否存在,不存在则自动建表
if (!tableNames.contains(resultTableName)) { if (!tableNames.contains(resultTableName)) {
tableNames.add(resultTableName); tableNames.add(resultTableName);
} }
return ShardingAlgorithmTool.getShardingTableAndCreate(logicTable, resultTableName); return ShardingAlgorithmTool.getShardingTableAndCreate(logicTable, resultTableName);
} }
/**
* 范围分片
*
* @param tableNames 对应分片库中所有分片表的集合
* @param rangeShardingValue 分片范围
* @return 表名集合
*/
@Override @Override
public Collection<String> doSharding(Collection<String> tableNames, RangeShardingValue<Date> rangeShardingValue) { public Collection<String> doSharding(Collection<String> tableNames, RangeShardingValue<Date> rangeShardingValue) {
log.info("开始分表查询开始:{}", System.currentTimeMillis()); log.info("开始分表查询开始:{}", System.currentTimeMillis());
String logicTableName = rangeShardingValue.getLogicTableName(); String logicTableName = rangeShardingValue.getLogicTableName();
ShardingTableCacheEnum logicTable = ShardingTableCacheEnum.of(logicTableName); ShardingTableCacheEnum logicTable = ShardingTableCacheEnum.of(logicTableName);
createAllTable(logicTable, tableNames); createAllTable(logicTable, tableNames);
/// 打印分片信息
log.info(">>>>>>>>>> 【INFO】范围分片,节点配置表名:{},数据库缓存表名:{}", tableNames, logicTable.resultTableNamesCache()); log.info(">>>>>>>>>> 【INFO】范围分片,节点配置表名:{},数据库缓存表名:{}", tableNames, logicTable.resultTableNamesCache());
// between and 的起始值
Range<Date> valueRange = rangeShardingValue.getValueRange(); Range<Date> valueRange = rangeShardingValue.getValueRange();
boolean hasLowerBound = valueRange.hasLowerBound(); boolean hasLowerBound = valueRange.hasLowerBound();
boolean hasUpperBound = valueRange.hasUpperBound(); boolean hasUpperBound = valueRange.hasUpperBound();
// 获取最大值和最小值
Set<String> tableNameCache = logicTable.resultTableNamesCache(); Set<String> tableNameCache = logicTable.resultTableNamesCache();
String min = hasLowerBound ? String.valueOf(valueRange.lowerEndpoint()) : getLowerEndpoint(tableNameCache); String min = hasLowerBound ? String.valueOf(valueRange.lowerEndpoint()) : getLowerEndpoint(tableNameCache);
String max = hasUpperBound ? String.valueOf(valueRange.upperEndpoint()) : getUpperEndpoint(tableNameCache); String max = hasUpperBound ? String.valueOf(valueRange.upperEndpoint()) : getUpperEndpoint(tableNameCache);
// 循环计算分表范围
Set<String> resultTableNames = new LinkedHashSet<>(); Set<String> resultTableNames = new LinkedHashSet<>();
try { try {
Date minDate = DATE_TIME_FORMATTER_SPILE.parse(min); Date minDate = DATE_TIME_FORMATTER_SPILE.parse(min);
@ -110,8 +70,8 @@ public class TimeShardingAlgorithm implements StandardShardingAlgorithm<Date> {
while (minDate.before(maxDate) || minDate.equals(maxDate)) { while (minDate.before(maxDate) || minDate.equals(maxDate)) {
String tableName = logicTableName + TABLE_SPLIT_SYMBOL + TABLE_SHARD_Date_FORMATTER.format(minDate); String tableName = logicTableName + TABLE_SPLIT_SYMBOL + TABLE_SHARD_Date_FORMATTER.format(minDate);
resultTableNames.add(tableName); resultTableNames.add(tableName);
calendar.setTime(minDate); // 设置Calendar的时间为Date对象的时间 calendar.setTime(minDate);
calendar.add(Calendar.DAY_OF_MONTH, 1); // 给日期加一天 calendar.add(Calendar.DAY_OF_MONTH, 1);
minDate = calendar.getTime(); minDate = calendar.getTime();
} }
log.info("开始分表查询结束:{}", System.currentTimeMillis()); log.info("开始分表查询结束:{}", System.currentTimeMillis());
@ -121,27 +81,12 @@ public class TimeShardingAlgorithm implements StandardShardingAlgorithm<Date> {
} }
} }
@Override
public void init() {}
@Override @Override
public void init() { public String getType() { return null; }
}
@Override
public String getType() {
return null;
}
// --------------------------------------------------------------------------------------------------------------
// 私有方法
// --------------------------------------------------------------------------------------------------------------
/**
* 获取 最小分片值
*
* @param tableNames 表名集合
* @return 最小分片值
*/
private String getLowerEndpoint(Collection<String> tableNames) { private String getLowerEndpoint(Collection<String> tableNames) {
Optional<LocalDateTime> optional = tableNames.stream() Optional<LocalDateTime> optional = tableNames.stream()
.map(o -> LocalDateTime.parse(o.replace(TABLE_SPLIT_SYMBOL, "") + "01 00:00:00", DATE_TIME_FORMATTER)) .map(o -> LocalDateTime.parse(o.replace(TABLE_SPLIT_SYMBOL, "") + "01 00:00:00", DATE_TIME_FORMATTER))
@ -156,12 +101,6 @@ public class TimeShardingAlgorithm implements StandardShardingAlgorithm<Date> {
} }
} }
/**
* 获取 最大分片值
*
* @param tableNames 表名集合
* @return 最大分片值
*/
private String getUpperEndpoint(Collection<String> tableNames) { private String getUpperEndpoint(Collection<String> tableNames) {
Optional<LocalDateTime> optional = tableNames.stream() Optional<LocalDateTime> optional = tableNames.stream()
.map(o -> LocalDateTime.parse(o.replace(TABLE_SPLIT_SYMBOL, "") + "01 00:00:00", DATE_TIME_FORMATTER)) .map(o -> LocalDateTime.parse(o.replace(TABLE_SPLIT_SYMBOL, "") + "01 00:00:00", DATE_TIME_FORMATTER))
@ -176,20 +115,13 @@ public class TimeShardingAlgorithm implements StandardShardingAlgorithm<Date> {
} }
} }
/**
* 根据分片规则获取的表,创建所有的表
*
* @param logicTable
* @param tableNames
*/
private void createAllTable(ShardingTableCacheEnum logicTable, Collection<String> tableNames) { private void createAllTable(ShardingTableCacheEnum logicTable, Collection<String> tableNames) {
if (!CollectionUtils.isEmpty(logicTable.resultTableNamesCache())) { if (!CollectionUtils.isEmpty(logicTable.resultTableNamesCache())) {
//如果缓存中有表了,则证明已经创建了表,无需再创建
return; return;
} }
//根据分片规则创建表
ShardingAlgorithmTool.getShardingTablesAndCreate(logicTable, tableNames); ShardingAlgorithmTool.getShardingTablesAndCreate(logicTable, tableNames);
//刷新缓存
ShardingAlgorithmTool.tableNameCacheReload(logicTable); ShardingAlgorithmTool.tableNameCacheReload(logicTable);
} }
} }
*/

View File

@ -1,21 +1,20 @@
package com.fastbee.framework.config.sharding.enums; package com.fastbee.framework.config.sharding.enums;
/**
* ===== ShardingSphere 已禁用 =====
* 如需启用分库分表,请取消以下注释并恢复 pom.xml 中的依赖
*/
/*
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import java.util.*; import java.util.*;
import static com.fastbee.framework.config.sharding.ShardingAlgorithmTool.actualDataNodesRefresh; import static com.fastbee.framework.config.sharding.ShardingAlgorithmTool.actualDataNodesRefresh;
/**
* <p> @Title ShardingTableCacheEnum
* <p> @Description 分片表缓存枚举
*/
public enum ShardingTableCacheEnum { public enum ShardingTableCacheEnum {
/**
* 用户埋点表
*/
DEVICE_LOG("iot_device_log", new HashSet<>()); DEVICE_LOG("iot_device_log", new HashSet<>());
private static Map<String, ShardingTableCacheEnum> valueMap = new HashMap<>(); private static Map<String, ShardingTableCacheEnum> valueMap = new HashMap<>();
@ -24,13 +23,7 @@ public enum ShardingTableCacheEnum {
Arrays.stream(ShardingTableCacheEnum.values()).forEach(o -> valueMap.put(o.logicTableName, o)); Arrays.stream(ShardingTableCacheEnum.values()).forEach(o -> valueMap.put(o.logicTableName, o));
} }
/**
* 逻辑表名
*/
private final String logicTableName; private final String logicTableName;
/**
* 实际表名
*/
private final Set<String> resultTableNamesCache; private final Set<String> resultTableNamesCache;
ShardingTableCacheEnum(String logicTableName, Set<String> resultTableNamesCache) { ShardingTableCacheEnum(String logicTableName, Set<String> resultTableNamesCache) {
@ -54,21 +47,13 @@ public enum ShardingTableCacheEnum {
return resultTableNamesCache; return resultTableNamesCache;
} }
/**
* 更新缓存、配置(原子操作)
*
* @param tableNameList
*/
public void atomicUpdateCacheAndActualDataNodes(List<String> tableNameList) { public void atomicUpdateCacheAndActualDataNodes(List<String> tableNameList) {
if (CollectionUtils.isEmpty(tableNameList)) { if (CollectionUtils.isEmpty(tableNameList)) {
return; return;
} }
synchronized (resultTableNamesCache) { synchronized (resultTableNamesCache) {
// 删除缓存
resultTableNamesCache.clear(); resultTableNamesCache.clear();
// 写入新的缓存
resultTableNamesCache.addAll(tableNameList); resultTableNamesCache.addAll(tableNameList);
// 动态更新配置 actualDataNodes
actualDataNodesRefresh(logicTableName, tableNameList); actualDataNodesRefresh(logicTableName, tableNameList);
} }
} }
@ -81,3 +66,5 @@ public enum ShardingTableCacheEnum {
'}'; '}';
} }
} }
*/

View File

@ -47,7 +47,7 @@
<lock4j.version>2.2.7</lock4j.version> <lock4j.version>2.2.7</lock4j.version>
<zxing.version>3.3.3</zxing.version> <zxing.version>3.3.3</zxing.version>
<druid.version>1.2.23</druid.version> <druid.version>1.2.23</druid.version>
<shardingsphere.version>5.1.1</shardingsphere.version> <!-- <shardingsphere.version>5.1.1</shardingsphere.version> --> <!-- ShardingSphere 已禁用 -->
<dynamic-datasource.version>4.3.1</dynamic-datasource.version> <dynamic-datasource.version>4.3.1</dynamic-datasource.version>
<p6spy.version>3.9.1</p6spy.version> <p6spy.version>3.9.1</p6spy.version>
<tdengine.version>3.3.2</tdengine.version> <tdengine.version>3.3.2</tdengine.version>
@ -78,11 +78,14 @@
<version>${p6spy.version}</version> <version>${p6spy.version}</version>
</dependency> </dependency>
<!-- ===== ShardingSphere 已禁用 ===== -->
<!--
<dependency> <dependency>
<groupId>org.apache.shardingsphere</groupId> <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId> <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>${shardingsphere.version}</version> <version>${shardingsphere.version}</version>
</dependency> </dependency>
-->
<!-- 解析客户端操作系统、浏览器等 --> <!-- 解析客户端操作系统、浏览器等 -->
<dependency> <dependency>