You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2023/06/15 02:59:52 UTC
[shardingsphere] branch master updated: CONVERT YAML CONFIGURATION Add transactionalReadQueryStrategy (#26355)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 65f8118f909 CONVERT YAML CONFIGURATION Add transactionalReadQueryStrategy (#26355)
65f8118f909 is described below
commit 65f8118f909be8c1cfdb1a423fd0dceec6d514b9
Author: yx9o <ya...@163.com>
AuthorDate: Thu Jun 15 10:59:44 2023 +0800
CONVERT YAML CONFIGURATION Add transactionalReadQueryStrategy (#26355)
* CONVERT YAML CONFIGURATION Add transactionalReadQueryStrategy
* Update
* Update
---
.../handler/update/AlterReadwriteSplittingRuleStatementUpdater.java | 4 ++--
.../handler/distsql/ral/common/constant/DistSQLScriptConstants.java | 4 +++-
.../distsql/ral/queryable/ConvertYamlConfigurationExecutor.java | 3 ++-
.../src/test/resources/conf/convert/config-readwrite-splitting.yaml | 1 +
proxy/backend/core/src/test/resources/expected/convert-mix.yaml | 2 ++
.../core/src/test/resources/expected/convert-readwrite-splitting.yaml | 1 +
6 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
index 003edaaa9e4..67623670690 100644
--- a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
+++ b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdater.java
@@ -52,8 +52,8 @@ public final class AlterReadwriteSplittingRuleStatementUpdater implements RuleDe
}
@Override
- public ReadwriteSplittingRuleConfiguration buildToBeDroppedRuleConfiguration(
- final ReadwriteSplittingRuleConfiguration currentRuleConfig, final ReadwriteSplittingRuleConfiguration toBeAlteredRuleConfig) {
+ public ReadwriteSplittingRuleConfiguration buildToBeDroppedRuleConfiguration(final ReadwriteSplittingRuleConfiguration currentRuleConfig,
+ final ReadwriteSplittingRuleConfiguration toBeAlteredRuleConfig) {
Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = new LinkedList<>();
List<String> toBeAlteredDataSourceNames = toBeAlteredRuleConfig.getDataSources().stream().map(ReadwriteSplittingDataSourceRuleConfiguration::getName).collect(Collectors.toList());
for (ReadwriteSplittingDataSourceRuleConfiguration each : currentRuleConfig.getDataSources()) {
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
index bed8b0819c8..114d53edb9e 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/constant/DistSQLScriptConstants.java
@@ -133,7 +133,9 @@ public final class DistSQLScriptConstants {
+ System.lineSeparator()
+ "WRITE_STORAGE_UNIT=%s,"
+ System.lineSeparator()
- + "READ_STORAGE_UNITS(%s)%s"
+ + "READ_STORAGE_UNITS(%s),"
+ + System.lineSeparator()
+ + "TRANSACTIONAL_READ_QUERY_STRATEGY='%s'%s"
+ System.lineSeparator()
+ ")";
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java
index e997a73523f..974a1c5a253 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutor.java
@@ -409,9 +409,10 @@ public final class ConvertYamlConfigurationExecutor implements QueryableRALExecu
private void appendStaticReadWriteSplittingRule(final Map<String, AlgorithmConfiguration> loadBalancers,
final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig, final StringBuilder stringBuilder) {
String readDataSourceNames = getReadDataSourceNames(dataSourceRuleConfig.getReadDataSourceNames());
+ String transactionalReadQueryStrategy = dataSourceRuleConfig.getTransactionalReadQueryStrategy().name();
String loadBalancerType = getLoadBalancerType(loadBalancers.get(dataSourceRuleConfig.getLoadBalancerName()));
stringBuilder.append(String.format(DistSQLScriptConstants.READWRITE_SPLITTING_FOR_STATIC,
- dataSourceRuleConfig.getName(), dataSourceRuleConfig.getWriteDataSourceName(), readDataSourceNames, loadBalancerType));
+ dataSourceRuleConfig.getName(), dataSourceRuleConfig.getWriteDataSourceName(), readDataSourceNames, transactionalReadQueryStrategy, loadBalancerType));
}
private String getLoadBalancerType(final AlgorithmConfiguration algorithmConfig) {
diff --git a/proxy/backend/core/src/test/resources/conf/convert/config-readwrite-splitting.yaml b/proxy/backend/core/src/test/resources/conf/convert/config-readwrite-splitting.yaml
index 7c92e052eb2..9a67bc70387 100644
--- a/proxy/backend/core/src/test/resources/conf/convert/config-readwrite-splitting.yaml
+++ b/proxy/backend/core/src/test/resources/conf/convert/config-readwrite-splitting.yaml
@@ -50,6 +50,7 @@ rules:
- !READWRITE_SPLITTING
dataSources:
readwrite_ds:
+ transactionalReadQueryStrategy: PRIMARY
writeDataSourceName: write_ds_0
readDataSourceNames:
- read_ds_0
diff --git a/proxy/backend/core/src/test/resources/expected/convert-mix.yaml b/proxy/backend/core/src/test/resources/expected/convert-mix.yaml
index 360977d1386..4d8fece6d3b 100644
--- a/proxy/backend/core/src/test/resources/expected/convert-mix.yaml
+++ b/proxy/backend/core/src/test/resources/expected/convert-mix.yaml
@@ -52,10 +52,12 @@ PROPERTIES('minPoolSize'='1', 'connectionTimeoutMilliseconds'='30000', 'maxLifet
CREATE READWRITE_SPLITTING RULE readwrite_ds_0 (
WRITE_STORAGE_UNIT=ds_0,
READ_STORAGE_UNITS(ds_1,ds_2),
+TRANSACTIONAL_READ_QUERY_STRATEGY='DYNAMIC',
TYPE(NAME='random')
), readwrite_ds_1 (
WRITE_STORAGE_UNIT=ds_3,
READ_STORAGE_UNITS(ds_4,ds_5),
+TRANSACTIONAL_READ_QUERY_STRATEGY='DYNAMIC',
TYPE(NAME='random')
);
diff --git a/proxy/backend/core/src/test/resources/expected/convert-readwrite-splitting.yaml b/proxy/backend/core/src/test/resources/expected/convert-readwrite-splitting.yaml
index d2ff40bb39d..b7235762466 100644
--- a/proxy/backend/core/src/test/resources/expected/convert-readwrite-splitting.yaml
+++ b/proxy/backend/core/src/test/resources/expected/convert-readwrite-splitting.yaml
@@ -37,5 +37,6 @@ PROPERTIES('minPoolSize'='1', 'connectionTimeoutMilliseconds'='30000', 'maxLifet
CREATE READWRITE_SPLITTING RULE readwrite_ds (
WRITE_STORAGE_UNIT=write_ds_0,
READ_STORAGE_UNITS(read_ds_0,read_ds_1),
+TRANSACTIONAL_READ_QUERY_STRATEGY='PRIMARY',
TYPE(NAME='random')
);