From b582708b9c0b595675823c53a90e67212fa9c853 Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Mon, 29 May 2023 09:05:17 +0800 Subject: [PATCH] =?UTF-8?q?dataSourcePoolSize=E6=94=B9=E4=B8=BAdataSourceM?= =?UTF-8?q?ergePoolSize=20=E4=BC=98=E5=8C=96=E8=81=9A=E5=90=88=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E7=BA=BF=E7=A8=8B=E6=B1=A0=E5=8D=95=E4=B8=AAconnectio?= =?UTF-8?q?n=E8=8E=B7=E5=8F=96=E4=BA=92=E4=B8=8D=E5=BD=B1=E5=93=8D=200.9.1?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- samples/pom.xml | 2 +- samples/springbootdemo/pom.xml | 2 +- sql-core/pom.xml | 2 +- .../core/configuration/EasyQueryOption.java | 17 ++++--- .../configuration/EasyQueryOptionBuilder.java | 12 ++--- .../configuration/ShardingDataSource.java | 14 +++--- .../datasource/DefaultDataSourceManager.java | 4 +- .../datasource/DefaultDataSourceUnit.java | 46 ++++++++----------- .../DefaultReplicaDataSourceManager.java | 2 +- .../easy/query/core/util/EasyDynamicUtil.java | 2 +- sql-h2/pom.xml | 2 +- sql-mssql/pom.xml | 2 +- sql-mysql/pom.xml | 2 +- sql-pgsql/pom.xml | 2 +- sql-springboot-starter/pom.xml | 2 +- .../EasyQueryStarterAutoConfiguration.java | 3 +- .../sql/starter/con/SpringDataSourceUnit.java | 4 +- .../con/SpringDataSourceUnitFactory.java | 4 +- .../starter/config/EasyQueryProperties.java | 10 ++-- sql-test/pom.xml | 2 +- .../java/com/easy/query/test/BaseTest.java | 5 +- 22 files changed, 68 insertions(+), 75 deletions(-) diff --git a/pom.xml b/pom.xml index 548b73210..f7a50b908 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.easy-query easy-query-all pom - 0.9.9 + 0.9.10 easy-query java object query distributed connector https://github.com/xuejmnet/easy-query diff --git a/samples/pom.xml b/samples/pom.xml index d9624046d..52675cc59 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -5,7 +5,7 @@ easy-query-all com.easy-query - 0.9.9 + 0.9.10 4.0.0 diff --git a/samples/springbootdemo/pom.xml b/samples/springbootdemo/pom.xml index 6e03c80a6..dc444d180 100644 --- a/samples/springbootdemo/pom.xml +++ b/samples/springbootdemo/pom.xml @@ -45,7 +45,7 @@ com.easy-query sql-springboot-starter - 0.9.9 + 0.9.10 compile diff --git a/sql-core/pom.xml b/sql-core/pom.xml index b0a9ec9ef..9e72dd100 100644 --- a/sql-core/pom.xml +++ b/sql-core/pom.xml @@ -5,7 +5,7 @@ easy-query-all com.easy-query - 0.9.9 + 0.9.10 4.0.0 diff --git a/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOption.java b/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOption.java index fee2c8547..b1ca537ec 100644 --- a/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOption.java +++ b/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOption.java @@ -25,7 +25,7 @@ public class EasyQueryOption { private final EasyQueryReplicaOption replicaOption; private final EasyQueryShardingOption shardingOption; private final String defaultDataSourceName; - private final int defaultDataSourcePoolSize; + private final int defaultDataSourceMergePoolSize; /** * 默认查询是否查询large column默认true */ @@ -46,7 +46,7 @@ public class EasyQueryOption { public EasyQueryOption(boolean deleteThrowError, SQLExecuteStrategyEnum insertStrategy, SQLExecuteStrategyEnum updateStrategy, ConnectionModeEnum connectionMode, int maxShardingQueryLimit, int executorMaximumPoolSize, int executorCorePoolSize, boolean throwIfNotMatchRoute, long shardingExecuteTimeoutMillis, - EasyQueryShardingOption shardingOption, EasyQueryReplicaOption replicaOption, String defaultDataSourceName, int defaultDataSourcePoolSize, boolean queryLargeColumn, int maxShardingRouteCount, int executorQueueSize, long multiConnWaitTimeoutMillis, + EasyQueryShardingOption shardingOption, EasyQueryReplicaOption replicaOption, String defaultDataSourceName, int defaultDataSourceMergePoolSize, boolean queryLargeColumn, int maxShardingRouteCount, int executorQueueSize, long multiConnWaitTimeoutMillis, boolean warningBusy) { if (executorMaximumPoolSize > 0) { @@ -62,16 +62,19 @@ public EasyQueryOption(boolean deleteThrowError, SQLExecuteStrategyEnum insertSt if (executorQueueSize < maxShardingQueryLimit) { throw new IllegalArgumentException("Invalid arguments: executorQueueSize < maxShardingQueryLimit"); } - if((executorMaximumPoolSize+executorQueueSize) < maxShardingQueryLimit){ + if ((executorMaximumPoolSize + executorQueueSize) < maxShardingQueryLimit) { throw new IllegalArgumentException("Invalid arguments: (executorMaximumPoolSize+executorQueueSize) < maxShardingQueryLimit"); } } if (shardingExecuteTimeoutMillis <= 0) { throw new IllegalArgumentException("shardingExecuteTimeoutMillis less than zero:" + shardingExecuteTimeoutMillis); } - if(multiConnWaitTimeoutMillis <= 0){ + if (multiConnWaitTimeoutMillis <= 0) { throw new IllegalArgumentException("multiConnWaitTimeoutMillis <= 0"); } + if (defaultDataSourceMergePoolSize > 0 && defaultDataSourceMergePoolSize < maxShardingQueryLimit) { + throw new IllegalArgumentException("invalid arguments: defaultDataSourceMergePoolSize > 0 && defaultDataSourceMergePoolSize < maxShardingQueryLimit."); + } this.deleteThrowError = deleteThrowError; this.insertStrategy = SQLExecuteStrategyEnum.getDefaultStrategy(insertStrategy, SQLExecuteStrategyEnum.ONLY_NOT_NULL_COLUMNS); this.updateStrategy = SQLExecuteStrategyEnum.getDefaultStrategy(updateStrategy, SQLExecuteStrategyEnum.ALL_COLUMNS); @@ -84,7 +87,7 @@ public EasyQueryOption(boolean deleteThrowError, SQLExecuteStrategyEnum insertSt this.shardingOption = shardingOption; this.replicaOption = replicaOption; this.defaultDataSourceName = defaultDataSourceName; - this.defaultDataSourcePoolSize = defaultDataSourcePoolSize; + this.defaultDataSourceMergePoolSize = defaultDataSourceMergePoolSize; this.queryLargeColumn = queryLargeColumn; this.maxShardingRouteCount = maxShardingRouteCount; this.executorQueueSize = executorQueueSize; @@ -152,8 +155,8 @@ public int getExecutorQueueSize() { return executorQueueSize; } - public int getDefaultDataSourcePoolSize() { - return defaultDataSourcePoolSize; + public int getDefaultDataSourceMergePoolSize() { + return defaultDataSourceMergePoolSize; } public long getMultiConnWaitTimeoutMillis() { diff --git a/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOptionBuilder.java b/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOptionBuilder.java index fe3ed8c82..4c7169d14 100644 --- a/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOptionBuilder.java +++ b/sql-core/src/main/java/com/easy/query/core/configuration/EasyQueryOptionBuilder.java @@ -23,7 +23,7 @@ public class EasyQueryOptionBuilder { private EasyQueryReplicaOption replicaOption; private EasyQueryShardingOption shardingOption; private String defaultDataSourceName; - private int defaultDataSourcePoolSize; + private int defaultDataSourceMergePoolSize; private boolean queryLargeColumn; private int maxShardingRouteCount; private int executorQueueSize; @@ -39,7 +39,7 @@ public EasyQueryOptionBuilder() { this.updateStrategy = SQLExecuteStrategyEnum.ALL_COLUMNS; this.connectionMode = ConnectionModeEnum.SYSTEM_AUTO; this.maxShardingQueryLimit = 5; - this.defaultDataSourcePoolSize = 0; + this.defaultDataSourceMergePoolSize = 0; this.executorMaximumPoolSize = 0; this.executorCorePoolSize = Math.min(Runtime.getRuntime().availableProcessors(), 4); this.throwIfRouteNotMatch = true; @@ -118,10 +118,10 @@ public void setExecutorQueueSize(int executorQueueSize) { /** * 如果当前没有分表操作建议设置为0 - * @param defaultDataSourcePoolSize + * @param defaultDataSourceMergePoolSize */ - public void setDefaultDataSourcePoolSize(int defaultDataSourcePoolSize) { - this.defaultDataSourcePoolSize = defaultDataSourcePoolSize; + public void setDefaultDataSourceMergePoolSize(int defaultDataSourceMergePoolSize) { + this.defaultDataSourceMergePoolSize = defaultDataSourceMergePoolSize; } public void setMultiConnWaitTimeoutMillis(long multiConnWaitTimeoutMillis) { @@ -149,7 +149,7 @@ public EasyQueryOption build() { this.shardingOption, this.replicaOption, this.defaultDataSourceName, - this.defaultDataSourcePoolSize, + this.defaultDataSourceMergePoolSize, this.queryLargeColumn, this.maxShardingRouteCount, this.executorQueueSize, diff --git a/sql-core/src/main/java/com/easy/query/core/configuration/ShardingDataSource.java b/sql-core/src/main/java/com/easy/query/core/configuration/ShardingDataSource.java index 49e083fc7..83c02ee32 100644 --- a/sql-core/src/main/java/com/easy/query/core/configuration/ShardingDataSource.java +++ b/sql-core/src/main/java/com/easy/query/core/configuration/ShardingDataSource.java @@ -14,18 +14,18 @@ public final class ShardingDataSource { private final String dataSourceName; private final DataSource dataSource; - private final int dataSourcePoolSize; + private final int dataSourceMergePoolSize; - public ShardingDataSource(String dataSourceName, DataSource dataSource, int dataSourcePoolSize) { + public ShardingDataSource(String dataSourceName, DataSource dataSource, int dataSourceMergePoolSize) { if (EasyStringUtil.isBlank(dataSourceName)) { throw new IllegalArgumentException("dataSourceName is empty"); } - if (dataSourcePoolSize <= 0) { - throw new IllegalArgumentException("dataSourcePoolSize <= 0"); + if (dataSourceMergePoolSize <= 0) { + throw new IllegalArgumentException("dataSourceMergePoolSize <= 0"); } this.dataSourceName = dataSourceName; this.dataSource = dataSource; - this.dataSourcePoolSize = dataSourcePoolSize; + this.dataSourceMergePoolSize = dataSourceMergePoolSize; } public String getDataSourceName() { @@ -36,8 +36,8 @@ public DataSource getDataSource() { return dataSource; } - public int getDataSourcePoolSize() { - return dataSourcePoolSize; + public int getDataSourceMergePoolSize() { + return dataSourceMergePoolSize; } @Override diff --git a/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceManager.java b/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceManager.java index 329110138..8e4653c09 100644 --- a/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceManager.java +++ b/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceManager.java @@ -28,7 +28,7 @@ public DefaultDataSourceManager(EasyQueryOption easyQueryOption, DataSource defa this.defaultDataSourceName = easyQueryOption.getDefaultDataSourceName(); this.defaultDataSource = defaultDataSource; this.dataSourceUnitFactory = dataSourceUnitFactory; - this.dataSourceMap.putIfAbsent(defaultDataSourceName, dataSourceUnitFactory.createDataSourceUnit(defaultDataSourceName,defaultDataSource,easyQueryOption.getDefaultDataSourcePoolSize())); + this.dataSourceMap.putIfAbsent(defaultDataSourceName, dataSourceUnitFactory.createDataSourceUnit(defaultDataSourceName,defaultDataSource,easyQueryOption.getDefaultDataSourceMergePoolSize())); initShardingConfig(easyQueryOption); } @@ -39,7 +39,7 @@ private void initShardingConfig(EasyQueryOption easyQueryOption) { Set shardingDataSources = shardingOption.getShardingDataSources(); if (shardingDataSources != null) { for (ShardingDataSource shardingDataSource : shardingDataSources) { - this.dataSourceMap.putIfAbsent(shardingDataSource.getDataSourceName(), dataSourceUnitFactory.createDataSourceUnit(shardingDataSource.getDataSourceName(),shardingDataSource.getDataSource(),shardingDataSource.getDataSourcePoolSize())); + this.dataSourceMap.putIfAbsent(shardingDataSource.getDataSourceName(), dataSourceUnitFactory.createDataSourceUnit(shardingDataSource.getDataSourceName(),shardingDataSource.getDataSource(),shardingDataSource.getDataSourceMergePoolSize())); } } } diff --git a/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceUnit.java b/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceUnit.java index f9c249c27..d373ee9df 100644 --- a/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceUnit.java +++ b/sql-core/src/main/java/com/easy/query/core/datasource/DefaultDataSourceUnit.java @@ -30,11 +30,11 @@ public class DefaultDataSourceUnit implements DataSourceUnit { protected final Semaphore semaphore; private final boolean warningBusy; - public DefaultDataSourceUnit(String dataSourceName, DataSource dataSource, int dataSourcePool, boolean warningBusy) { + public DefaultDataSourceUnit(String dataSourceName, DataSource dataSource, int mergePoolSize, boolean warningBusy) { this.dataSourceName = dataSourceName; this.dataSource = dataSource; - this.semaphore = dataSourcePool <= 0 ? null : new Semaphore(dataSourcePool, true); + this.semaphore = mergePoolSize <= 0 ? null : new Semaphore(mergePoolSize, true); this.warningBusy = warningBusy; } @@ -50,25 +50,27 @@ public DataSource getDataSource() { @Override public List getConnections(int count, long timeout, TimeUnit unit) throws SQLException { - if (semaphore == null) { - if (count > 1) { - throw new EasyQueryInvalidOperationException("sharding table should set dataSourceName:[" + dataSourceName + "] dataSourcePool,current value <= 0."); - } + if (count <= 1) { Connection connection = getConnection(); return Collections.singletonList(connection); } - return tryGetConnection(count, timeout, unit, () -> getConnections(count)); + + if (semaphore == null) { + throw new EasyQueryInvalidOperationException("sharding table should set dataSourceName:[" + dataSourceName + "] dataSourcePool,current value <= 0."); + } + return getMergeConnections(count, timeout, unit); } @Override public Connection getConnection(long timeout, TimeUnit unit) throws SQLException { - if (semaphore == null) { - return getConnection(); - } - return tryGetConnection(1, timeout, unit, this::getConnection); + return getConnection(); + } + + protected Connection getConnection() throws SQLException { + return dataSource.getConnection(); } - protected TR tryGetConnection(int count, long timeout, TimeUnit unit, SQLSupplier supplier) throws SQLException { + protected List getMergeConnections(int count, long timeout, TimeUnit unit) throws SQLException { SemaphoreReleaseOnlyOnce semaphoreReleaseOnlyOnce = tryAcquire(count, timeout, unit); @@ -76,25 +78,17 @@ protected TR tryGetConnection(int count, long timeout, TimeUnit unit, SQLSu throw new EasyQuerySQLException("dataSourceName:" + dataSourceName + " get connections:" + 1 + " busy."); } try { - return supplier.get(); + ArrayList result = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + Connection connection = getConnection(); + result.add(connection); + } + return result; } finally { semaphoreReleaseOnlyOnce.release(); } } - protected Connection getConnection() throws SQLException { - return dataSource.getConnection(); - } - - protected List getConnections(int count) throws SQLException { - ArrayList result = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - Connection connection = getConnection(); - result.add(connection); - } - return result; - } - protected SemaphoreReleaseOnlyOnce tryAcquire(int count, long timeout, TimeUnit unit) { try { diff --git a/sql-core/src/main/java/com/easy/query/core/datasource/replica/DefaultReplicaDataSourceManager.java b/sql-core/src/main/java/com/easy/query/core/datasource/replica/DefaultReplicaDataSourceManager.java index cd0d11fdf..e0734b125 100644 --- a/sql-core/src/main/java/com/easy/query/core/datasource/replica/DefaultReplicaDataSourceManager.java +++ b/sql-core/src/main/java/com/easy/query/core/datasource/replica/DefaultReplicaDataSourceManager.java @@ -51,7 +51,7 @@ private void initReplicaConnector(EasyQueryReplicaOption replicaOption) { ArrayList replicaNodes = new ArrayList<>(entries.size()); for (Map.Entry replicaKv : entries) { ShardingDataSource shardingDataSource = replicaKv.getValue(); - replicaNodes.add(new ReplicaNode(replicaKv.getKey(), dataSourceUnitFactory.createDataSourceUnit(shardingDataSource.getDataSourceName(),shardingDataSource.getDataSource(),shardingDataSource.getDataSourcePoolSize()))); + replicaNodes.add(new ReplicaNode(replicaKv.getKey(), dataSourceUnitFactory.createDataSourceUnit(shardingDataSource.getDataSourceName(),shardingDataSource.getDataSource(),shardingDataSource.getDataSourceMergePoolSize()))); } ReplicaConnector replicaConnector = Objects.equals(ReplicaUseStrategyEnum.Loop, replicaOption.getReplicaUseStrategy()) ? new LoopReplicaConnector(dataSource, replicaNodes) : new RandomReplicaConnector(dataSource, replicaNodes); replicaDataSource.put(dataSource, replicaConnector); diff --git a/sql-core/src/main/java/com/easy/query/core/util/EasyDynamicUtil.java b/sql-core/src/main/java/com/easy/query/core/util/EasyDynamicUtil.java index df4061073..4909d892e 100644 --- a/sql-core/src/main/java/com/easy/query/core/util/EasyDynamicUtil.java +++ b/sql-core/src/main/java/com/easy/query/core/util/EasyDynamicUtil.java @@ -26,7 +26,7 @@ private EasyDynamicUtil(){} public static void addDataSource(QueryRuntimeContext runtimeContext, ShardingDataSource shardingDataSource){ String dataSourceName = shardingDataSource.getDataSourceName(); DataSource dataSource = shardingDataSource.getDataSource(); - int dataSourcePoolSize = shardingDataSource.getDataSourcePoolSize(); + int dataSourcePoolSize = shardingDataSource.getDataSourceMergePoolSize(); EasyQueryDataSource easyQueryDataSource = runtimeContext.getEasyQueryDataSource(); easyQueryDataSource.addDataSource(dataSourceName,dataSource,dataSourcePoolSize); } diff --git a/sql-h2/pom.xml b/sql-h2/pom.xml index c7bd2e88c..a981a7435 100644 --- a/sql-h2/pom.xml +++ b/sql-h2/pom.xml @@ -6,7 +6,7 @@ com.easy-query easy-query-all - 0.9.9 + 0.9.10 sql-h2 diff --git a/sql-mssql/pom.xml b/sql-mssql/pom.xml index 8c216c638..14ce9c376 100644 --- a/sql-mssql/pom.xml +++ b/sql-mssql/pom.xml @@ -6,7 +6,7 @@ com.easy-query easy-query-all - 0.9.9 + 0.9.10 sql-mssql diff --git a/sql-mysql/pom.xml b/sql-mysql/pom.xml index a6830ba5a..ed2b368eb 100644 --- a/sql-mysql/pom.xml +++ b/sql-mysql/pom.xml @@ -5,7 +5,7 @@ easy-query-all com.easy-query - 0.9.9 + 0.9.10 4.0.0 diff --git a/sql-pgsql/pom.xml b/sql-pgsql/pom.xml index d6035ffcf..37f5c14bf 100644 --- a/sql-pgsql/pom.xml +++ b/sql-pgsql/pom.xml @@ -6,7 +6,7 @@ com.easy-query easy-query-all - 0.9.9 + 0.9.10 sql-pgsql diff --git a/sql-springboot-starter/pom.xml b/sql-springboot-starter/pom.xml index 76ee2f199..f4d665b1e 100644 --- a/sql-springboot-starter/pom.xml +++ b/sql-springboot-starter/pom.xml @@ -5,7 +5,7 @@ easy-query-all com.easy-query - 0.9.9 + 0.9.10 4.0.0 diff --git a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/EasyQueryStarterAutoConfiguration.java b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/EasyQueryStarterAutoConfiguration.java index ef6dabb63..981c23f33 100644 --- a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/EasyQueryStarterAutoConfiguration.java +++ b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/EasyQueryStarterAutoConfiguration.java @@ -1,6 +1,5 @@ package com.easy.query.sql.starter; -import com.easy.query.core.basic.jdbc.con.EasyConnectionFactory; import com.easy.query.core.basic.jdbc.con.ConnectionManager; import com.easy.query.core.basic.plugin.conversion.ValueConverter; import com.easy.query.core.basic.plugin.encryption.EncryptionStrategy; @@ -157,7 +156,7 @@ public EasyQuery easyQuery(DatabaseConfiguration databaseConfiguration, StarterC builder.setMaxShardingRouteCount(easyQueryProperties.getMaxShardingRouteCount()); builder.setExecutorQueueSize(easyQueryProperties.getExecutorQueueSize()); builder.setDefaultDataSourceName(easyQueryProperties.getDefaultDataSourceName()); - builder.setDefaultDataSourcePoolSize(easyQueryProperties.getDefaultDataSourcePoolSize()); + builder.setDefaultDataSourceMergePoolSize(easyQueryProperties.getDefaultDataSourceMergePoolSize()); builder.setMultiConnWaitTimeoutMillis(easyQueryProperties.getMultiConnWaitTimeoutMillis()); builder.setWarningBusy(easyQueryProperties.isWarningBusy()); }) diff --git a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnit.java b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnit.java index c78c9fbd4..2706954f8 100644 --- a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnit.java +++ b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnit.java @@ -14,8 +14,8 @@ * @author xuejiaming */ public class SpringDataSourceUnit extends DefaultDataSourceUnit { - public SpringDataSourceUnit(String dataSourceName, DataSource dataSource, int dataSourcePool, boolean warningBusy) { - super(dataSourceName,dataSource,dataSourcePool,warningBusy); + public SpringDataSourceUnit(String dataSourceName, DataSource dataSource, int mergePoolSize, boolean warningBusy) { + super(dataSourceName,dataSource,mergePoolSize,warningBusy); } @Override diff --git a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnitFactory.java b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnitFactory.java index 87c675b1b..bf4ce7056 100644 --- a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnitFactory.java +++ b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/con/SpringDataSourceUnitFactory.java @@ -20,7 +20,7 @@ public SpringDataSourceUnitFactory(EasyQueryOption easyQueryOption){ this.easyQueryOption = easyQueryOption; } @Override - public DataSourceUnit createDataSourceUnit(String dataSourceName, DataSource dataSource, int dataSourcePool) { - return new SpringDataSourceUnit(dataSourceName,dataSource,dataSourcePool,easyQueryOption.isWarningBusy()); + public DataSourceUnit createDataSourceUnit(String dataSourceName, DataSource dataSource, int mergePoolSize) { + return new SpringDataSourceUnit(dataSourceName,dataSource,mergePoolSize,easyQueryOption.isWarningBusy()); } } diff --git a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/config/EasyQueryProperties.java b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/config/EasyQueryProperties.java index 22d0a104e..63b47ac36 100644 --- a/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/config/EasyQueryProperties.java +++ b/sql-springboot-starter/src/main/java/com/easy/query/sql/starter/config/EasyQueryProperties.java @@ -72,7 +72,7 @@ public class EasyQueryProperties { * 如果当前没有分表操作建议设置为0 * 当小于maxShardingQueryLimit后启动会抛出警告 */ - private int defaultDataSourcePoolSize = 0; + private int defaultDataSourceMergePoolSize = 0; /** * 默认5秒分表聚合多链接获取分表插入更新删除同理多个线程间等待获取时间单位毫秒(ms) */ @@ -219,12 +219,12 @@ public void setDefaultDataSourceName(String defaultDataSourceName) { this.defaultDataSourceName = defaultDataSourceName; } - public int getDefaultDataSourcePoolSize() { - return defaultDataSourcePoolSize; + public int getDefaultDataSourceMergePoolSize() { + return defaultDataSourceMergePoolSize; } - public void setDefaultDataSourcePoolSize(int defaultDataSourcePoolSize) { - this.defaultDataSourcePoolSize = defaultDataSourcePoolSize; + public void setDefaultDataSourceMergePoolSize(int defaultDataSourceMergePoolSize) { + this.defaultDataSourceMergePoolSize = defaultDataSourceMergePoolSize; } public long getMultiConnWaitTimeoutMillis() { diff --git a/sql-test/pom.xml b/sql-test/pom.xml index 89917a930..5577e1e55 100644 --- a/sql-test/pom.xml +++ b/sql-test/pom.xml @@ -5,7 +5,7 @@ easy-query-all com.easy-query - 0.9.9 + 0.9.10 4.0.0 diff --git a/sql-test/src/main/java/com/easy/query/test/BaseTest.java b/sql-test/src/main/java/com/easy/query/test/BaseTest.java index 2b39ee566..1f90b1485 100644 --- a/sql-test/src/main/java/com/easy/query/test/BaseTest.java +++ b/sql-test/src/main/java/com/easy/query/test/BaseTest.java @@ -1,13 +1,11 @@ package com.easy.query.test; -import com.easy.query.core.basic.plugin.conversion.DefaultValueConverter; import com.easy.query.core.configuration.ShardingDataSource; import com.easy.query.core.context.QueryRuntimeContext; import com.easy.query.core.bootstrapper.EasyQueryBootstrapper; import com.easy.query.core.api.client.EasyQuery; import com.easy.query.core.configuration.QueryConfiguration; import com.easy.query.core.configuration.EasyQueryShardingOption; -import com.easy.query.core.enums.SQLExecuteStrategyEnum; import com.easy.query.core.logging.LogFactory; import com.easy.query.core.sharding.route.manager.DataSourceRouteManager; import com.easy.query.core.sharding.route.manager.TableRouteManager; @@ -42,7 +40,6 @@ import com.easy.query.test.sharding.TopicShardingTimeTableRule; import com.zaxxer.hikari.HikariDataSource; -import javax.sql.DataSource; import java.math.BigDecimal; import java.time.Duration; import java.time.LocalDateTime; @@ -123,7 +120,7 @@ public static void initEasyQuery() { op.setDefaultDataSourceName("ds2020"); op.setThrowIfRouteNotMatch(false); op.setMaxShardingRouteCount(512); - op.setDefaultDataSourcePoolSize(20); + op.setDefaultDataSourceMergePoolSize(20); }) .useDatabaseConfigure(new MySQLDatabaseConfiguration()) .build();