You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/08/29 13:43:37 UTC
[shardingsphere] branch master updated: Use transaction rule
instead of props (#12090)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 3a1c54d Use transaction rule instead of props (#12090)
3a1c54d is described below
commit 3a1c54d096f525c23835412a5a4068b16d28db82
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Aug 29 21:43:02 2021 +0800
Use transaction rule instead of props (#12090)
* Add transaction configuration
* Use transaction rule to process default transaction type
* Use transaction rule to process default transaction type
* Use transaction rule to process xa-transaction-manager-type
---
.../test-engine/performance-test-sysbench.cn.md | 4 --
.../test-engine/performance-test-sysbench.en.md | 4 --
.../shardingsphere-proxy/_index.en.md | 5 --
.../shardingsphere-jdbc/configuration/props.cn.md | 1 -
.../shardingsphere-jdbc/configuration/props.en.md | 1 -
.../usage/transaction/bitronix.cn.md | 6 ++-
.../usage/transaction/bitronix.en.md | 6 ++-
.../usage/transaction/narayana.cn.md | 6 ++-
.../usage/transaction/narayana.en.md | 6 ++-
.../shardingsphere-proxy/configuration/props.cn.md | 2 -
.../shardingsphere-proxy/configuration/props.en.md | 2 -
.../shardingsphere-proxy/usage/transaction.cn.md | 12 +++--
.../shardingsphere-proxy/usage/transaction.en.md | 12 +++--
.../shardingsphere-proxy/sharding/conf/server.yaml | 4 --
.../META-INF/sharding-databases-tables.yaml | 6 ++-
.../META-INF/sharding-databases-tables.yaml | 6 ++-
.../src/main/resources/conf/server.yaml | 4 --
.../src/main/resources/conf/server.yaml | 4 --
.../src/main/resources/conf/server.yaml | 5 --
.../properties/ConfigurationPropertyKey.java | 40 ---------------
.../properties/ConfigurationPropertiesTest.java | 3 --
.../manager/cluster/ClusterContextManager.java | 12 ++++-
.../cluster/ClusterContextManagerBuilder.java | 13 ++++-
.../memory/MemoryContextManagerBuilder.java | 17 +++++--
.../StandaloneContextManagerBuilder.java | 13 ++++-
.../jdbc/datasource/JDBCBackendDataSource.java | 15 ++++--
.../src/main/resources/conf/server.yaml | 11 ++--
.../netty/FrontendChannelInboundHandler.java | 16 ++++--
.../test/resources/docker/proxy/conf/server.yaml | 1 -
.../test/resources/docker/proxy/conf/server.yaml | 1 -
.../resources/docker/db/h2/proxy/conf/server.yaml | 1 -
.../docker/db/mysql/proxy/conf/server.yaml | 1 -
.../docker/db/postgresql/proxy/conf/server.yaml | 1 -
.../h2/proxy/conf/server.yaml | 1 -
.../mysql/proxy/conf/server.yaml | 1 -
.../postgresql/proxy/conf/server.yaml | 1 -
.../h2/proxy/conf/server.yaml | 1 -
.../mysql/proxy/conf/server.yaml | 1 -
.../postgresql/proxy/conf/server.yaml | 1 -
.../docker/encrypt/h2/proxy/conf/server.yaml | 1 -
.../docker/encrypt/mysql/proxy/conf/server.yaml | 1 -
.../encrypt/postgresql/proxy/conf/server.yaml | 1 -
.../readwrite_splitting/h2/proxy/conf/server.yaml | 1 -
.../mysql/proxy/conf/server.yaml | 1 -
.../postgresql/proxy/conf/server.yaml | 1 -
.../sharding_governance/h2/proxy/conf/server.yaml | 1 -
.../mysql/proxy/conf/server.yaml | 1 -
.../postgresql/proxy/conf/server.yaml | 1 -
.../resources/docker/tbl/h2/proxy/conf/server.yaml | 1 -
.../docker/tbl/mysql/proxy/conf/server.yaml | 1 -
.../docker/tbl/postgresql/proxy/conf/server.yaml | 1 -
.../config/TransactionRuleConfiguration.java | 37 ++++++++++++++
.../transaction/constant/TransactionOrder.java | 33 ++++++++++++
.../transaction/rule/TransactionRule.java | 43 ++++++++++++++++
.../rule/builder/TransactionRuleBuilder.java | 48 ++++++++++++++++++
.../config/YamlTransactionRuleConfiguration.java | 42 +++++++++++++++
.../TransactionRuleConfigurationYamlSwapper.java | 59 ++++++++++++++++++++++
...here.infra.rule.builder.scope.GlobalRuleBuilder | 16 +-----
...aml.config.swapper.YamlRuleConfigurationSwapper | 16 +-----
59 files changed, 380 insertions(+), 173 deletions(-)
diff --git a/docs/document/content/features/test-engine/performance-test-sysbench.cn.md b/docs/document/content/features/test-engine/performance-test-sysbench.cn.md
index 0ae7165..4b73494 100644
--- a/docs/document/content/features/test-engine/performance-test-sysbench.cn.md
+++ b/docs/document/content/features/test-engine/performance-test-sysbench.cn.md
@@ -311,10 +311,6 @@ props:
max-connections-size-per-query: 10
executor-size: 128 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- # LOCAL: Proxy will run with LOCAL transaction.
- # XA: Proxy will run with XA transaction.
- # BASE: Proxy will run with B.A.S.E transaction.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/docs/document/content/features/test-engine/performance-test-sysbench.en.md b/docs/document/content/features/test-engine/performance-test-sysbench.en.md
index c77b771..35464de 100644
--- a/docs/document/content/features/test-engine/performance-test-sysbench.en.md
+++ b/docs/document/content/features/test-engine/performance-test-sysbench.en.md
@@ -311,10 +311,6 @@ props:
max-connections-size-per-query: 10
executor-size: 128 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- # LOCAL: Proxy will run with LOCAL transaction.
- # XA: Proxy will run with XA transaction.
- # BASE: Proxy will run with B.A.S.E transaction.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/docs/document/content/others/api-change-history/shardingsphere-proxy/_index.en.md b/docs/document/content/others/api-change-history/shardingsphere-proxy/_index.en.md
index 3f0b7a9..75298e4 100644
--- a/docs/document/content/others/api-change-history/shardingsphere-proxy/_index.en.md
+++ b/docs/document/content/others/api-change-history/shardingsphere-proxy/_index.en.md
@@ -23,11 +23,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- # LOCAL: Proxy will run with LOCAL transaction.
- # XA: Proxy will run with XA transaction.
- # BASE: Proxy will run with B.A.S.E transaction.
- proxy-transaction-type: LOCAL
- xa-transaction-manager-type: Atomikos
proxy-opentracing-enabled: false
proxy-hint-enabled: false
query-with-cipher-column: true
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.cn.md
index befbd3a..894e894 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.cn.md
@@ -17,5 +17,4 @@ Apache ShardingSphere 提供属性配置的方式配置系统级配置。
| executor-size (?) | int | 用于设置任务处理线程池的大小。每个 ShardingSphereDataSource 使用一个独立的线程池,同一个 JVM 的不同数据源不共享线程池。 | infinite |
| max-connections-size-per-query (?) | int | 一次查询请求在每个数据库实例中所能使用的最大连接数。 | 1 |
| check-table-metadata-enabled (?) | boolean | 在程序启动和更新时,是否检查分片元数据的结构一致性。 | false |
-| xa-transaction-manager-type (?) | String | XA 事务管理器类型。例如:Atomikos,Narayana,Bitronix | Atomikos |
| check-duplicate-table-enabled (?) | boolean | 在程序启动和更新时,是否检查重复表。 | false |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.en.md
index 1bfb1c3..34232fe 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/props.en.md
@@ -17,5 +17,4 @@ Apache ShardingSphere provides the way of property configuration to configure sy
| executor-size (?) | int | The max thread size of worker group to execute SQL. One ShardingSphereDataSource will use a independent thread pool, it does not share thread pool even different data source in same JVM. | infinite |
| max-connections-size-per-query (?) | int | Max opened connection size for each query. | 1 |
| check-table-metadata-enabled (?) | boolean | Whether validate table meta data consistency when application startup or updated. | false |
-| xa-transaction-manager-type (?) | String | XA Transaction manager type. Include: Atomikos, Narayana and Bitronix. | Atomikos |
| check-duplicate-table-enabled (?) | boolean | Whether validate duplicate table when application startup or updated. | false |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.cn.md
index 5332c70..482e13f 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.cn.md
@@ -45,8 +45,10 @@ weight = 6
Yaml:
```yaml
-props:
- xa-transaction-manager-type: Bitronix
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Bitronix
```
SpringBoot:
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.en.md
index 44a2921..1ca9b1c 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/bitronix.en.md
@@ -44,8 +44,10 @@ Please refer to [Bitronix official documentation](https://github.com/bitronix/bt
Yaml:
```yaml
-props:
- xa-transaction-manager-type: Bitronix
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Bitronix
```
SpringBoot:
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.cn.md
index 0333903..611282b 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.cn.md
@@ -63,8 +63,10 @@ weight = 5
Yaml:
```yaml
-props:
- xa-transaction-manager-type: Narayana
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Narayana
```
SpringBoot:
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.en.md
index 8f42e27..ce822e4 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/usage/transaction/narayana.en.md
@@ -63,8 +63,10 @@ Please refer to [Narayana official documentation](https://narayana.io/documentat
Yaml:
```yaml
-props:
- xa-transaction-manager-type: Narayana
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Narayana
```
SpringBoot:
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.cn.md
index 13021a2..7ed6efd 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.cn.md
@@ -18,8 +18,6 @@ Apache ShardingSphere 提供属性配置的方式配置系统级配置。
| max-connections-size-per-query (?) | int | 一次查询请求在每个数据库实例中所能使用的最大连接数。 | 1 |
| check-table-metadata-enabled (?) | boolean | 在程序启动和更新时,是否检查分片元数据的结构一致性。 | false |
| proxy-frontend-flush-threshold (?) | int | 在 ShardingSphere-Proxy 中设置传输数据条数的 IO 刷新阈值。 | 128 |
-| proxy-transaction-type (?) | String | ShardingSphere-Proxy 中使用的默认事务类型。包括:LOCAL、XA 和 BASE。 | LOCAL |
| proxy-opentracing-enabled (?) | boolean | 是否允许在 ShardingSphere-Proxy 中使用 OpenTracing。 | false |
| proxy-hint-enabled (?) | boolean | 是否允许在 ShardingSphere-Proxy 中使用 Hint。使用 Hint 会将 Proxy 的线程处理模型由 IO 多路复用变更为每个请求一个独立的线程,会降低 Proxy 的吞吐量。 | false |
-| xa-transaction-manager-type (?) | String | XA 事务管理器类型。例如:Atomikos,Narayana,Bitronix。 | Atomikos |
| check-duplicate-table-enabled (?) | boolean | 在程序启动和更新时,是否检查重复表。 | false |
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.en.md b/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.en.md
index 0a4bfe4..a3da4ff 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/configuration/props.en.md
@@ -18,8 +18,6 @@ Apache ShardingSphere provides the way of property configuration to configure sy
| max-connections-size-per-query (?) | int | Max opened connection size for each query. | 1 |
| check-table-metadata-enabled (?) | boolean | Whether validate table meta data consistency when application startup or updated. | false |
| proxy-frontend-flush-threshold (?) | int | Flush threshold for every records from databases for ShardingSphere-Proxy. | 128 |
-| proxy-transaction-type (?) | String | Default transaction type of ShardingSphere-Proxy. Include: LOCAL, XA and BASE. | LOCAL |
| proxy-opentracing-enabled (?) | boolean | Whether enable opentracing for ShardingSphere-Proxy. | false |
| proxy-hint-enabled (?) | boolean | Whether enable hint for ShardingSphere-Proxy. Using Hint will switch proxy thread mode from IO multiplexing to per connection per thread, which will reduce system throughput. | false |
-| xa-transaction-manager-type (?) | String | XA Transaction manager type. Include: Atomikos, Narayana and Bitronix. | Atomikos |
| check-duplicate-table-enabled (?) | boolean | Whether validate duplicate table when application startup or updated. | false |
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.cn.md
index 3894a63..d67b0d0 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.cn.md
@@ -52,8 +52,10 @@ ShardingSphere-Proxy 接入的分布式事务 API 同 ShardingSphere-JDBC 保持
2. 在 `conf/server.yaml` 中加入如下配置:
```yaml
-props:
- xa-transaction-manager-type: Narayana
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Narayana
```
3. 新增 `jbossts-properties.xml` 文件来定制化 Narayana 配置项,它的加载路径顺序:`user.dir (pwd)` > `user.home` > `java.home` > `classpath`。
@@ -84,8 +86,10 @@ props:
2. 在 `conf/server.yaml` 中加入如下配置:
```yaml
-props:
- xa-transaction-manager-type: Bitronix
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Bitronix
```
3. Bitronix 配置详情请参见[Bitronix官方文档](https://github.com/bitronix/btm/wiki)。
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.en.md b/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.en.md
index dff4d77..4ba0d5a 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/usage/transaction.en.md
@@ -44,8 +44,10 @@ Default XA transaction manager of ShardingSphere is Atomikos. Users can customiz
2. Configure `xa-transaction-manager-type` in `conf/server.yaml`:
```yaml
-props:
- xa-transaction-manager-type: Narayana
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Narayana
```
3. Add `jbossts-properties.xml` to customize Narayana configuration.
@@ -77,8 +79,10 @@ Please refer to [Narayana official documentation](https://narayana.io/documentat
2. Configure `xa-transaction-manager-type` in `conf/server.yaml`:
```yaml
-props:
- xa-transaction-manager-type: Bitronix
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Bitronix
```
3. Please refer to [Bitronix official documentation](https://github.com/bitronix/btm/wiki) for more details.
diff --git a/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml b/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml
index acd7076..e6010dc 100644
--- a/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml
+++ b/examples/docker/shardingsphere-proxy/sharding/conf/server.yaml
@@ -41,9 +41,5 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- # LOCAL: Proxy will run with LOCAL transaction.
- # XA: Proxy will run with XA transaction.
- # BASE: Proxy will run with B.A.S.E transaction.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
sql-show: false
diff --git a/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-bitronix-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-bitronix-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
index 43c4e38..3358d14 100644
--- a/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-bitronix-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
+++ b/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-bitronix-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
@@ -67,6 +67,10 @@ rules:
props:
worker-id: 123
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Bitronix
+
props:
sql-show: false
- xa-transaction-manager-type: Bitronix
diff --git a/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-narayana-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-narayana-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
index 4f7f32e..5e9279f 100644
--- a/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-narayana-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
+++ b/examples/shardingsphere-jdbc-example/transaction-example/transaction-2pc-xa-narayana-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-tables.yaml
@@ -67,6 +67,10 @@ rules:
props:
worker-id: 123
+- !TRANSACTION
+ defaultType: XA
+ props:
+ xa-transaction-manager-type: Narayana
+
props:
sql-show: false
- xa-transaction-manager-type: Narayana
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml
index d45f245..ae0bae8 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-boot-mybatis-example/src/main/resources/conf/server.yaml
@@ -47,10 +47,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- # LOCAL: Proxy will run with LOCAL transaction.
- # XA: Proxy will run with XA transaction.
- # BASE: Proxy will run with B.A.S.E transaction.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml
index 8b62db5..b57bef8 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-hint-example/src/main/resources/conf/server.yaml
@@ -46,10 +46,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- # LOCAL: Proxy will run with LOCAL transaction.
- # XA: Proxy will run with XA transaction.
- # BASE: Proxy will run with B.A.S.E transaction.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: true
sql-show: true
diff --git a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/server.yaml b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/server.yaml
index 425020c..40751fc 100644
--- a/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/server.yaml
+++ b/shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/conf/server.yaml
@@ -50,11 +50,6 @@
# max-connections-size-per-query: 1
# executor-size: 16 # Infinite by default.
# proxy-frontend-flush-threshold: 128 # The default value is 128.
-# # LOCAL: Proxy will run with LOCAL transaction.
-# # XA: Proxy will run with XA transaction.
-# # BASE: Proxy will run with B.A.S.E transaction.
-# proxy-transaction-type: LOCAL
-# xa-transaction-manager-type: Atomikos
# proxy-opentracing-enabled: false
# proxy-hint-enabled: false
# sql-show: false
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
index 5fda3e6..9c78330 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
@@ -64,46 +64,6 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
PROXY_FRONTEND_FLUSH_THRESHOLD("proxy-frontend-flush-threshold", String.valueOf(128), int.class),
/**
- * Transaction type of proxy.
- *
- * <p>
- * LOCAL:
- * ShardingSphere-Proxy will run with LOCAL transaction.
- * </p>
- *
- * <p>
- * XA:
- * ShardingSphere-Proxy will run with XA transaction.
- * </p>
- *
- * <p>
- * BASE:
- * ShardingSphere-Proxy will run with BASE transaction.
- * </p>
- */
- PROXY_TRANSACTION_TYPE("proxy-transaction-type", "LOCAL", String.class),
-
- /**
- * XA transaction manager type of proxy.
- *
- * <p>
- * Atomikos:
- * ShardingSphere-Proxy will run with XA transaction with Atomikos.
- * </p>
- *
- * <p>
- * Narayana:
- * ShardingSphere-Proxy will run with XA transaction with Narayana.
- * </p>
- *
- * <p>
- * Bitronix:
- * ShardingSphere-Proxy will run with XA transaction with Bitronix.
- * </p>
- */
- XA_TRANSACTION_MANAGER_TYPE("xa-transaction-manager-type", "Atomikos", String.class),
-
- /**
* Whether enable opentracing for ShardingSphere-Proxy.
*/
PROXY_OPENTRACING_ENABLED("proxy-opentracing-enabled", String.valueOf(Boolean.FALSE), boolean.class),
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
index d9bf94a..baa77cb 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertiesTest.java
@@ -36,7 +36,6 @@ public final class ConfigurationPropertiesTest {
props.setProperty(ConfigurationPropertyKey.EXECUTOR_SIZE.getKey(), "20");
props.setProperty(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY.getKey(), "20");
props.setProperty(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD.getKey(), "20");
- props.setProperty(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE.getKey(), "XA");
props.setProperty(ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey(), Boolean.TRUE.toString());
props.setProperty(ConfigurationPropertyKey.CHECK_TABLE_METADATA_ENABLED.getKey(), Boolean.TRUE.toString());
ConfigurationProperties actual = new ConfigurationProperties(props);
@@ -45,7 +44,6 @@ public final class ConfigurationPropertiesTest {
assertThat(actual.getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), is(20));
assertThat(actual.getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY), is(20));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD), is(20));
- assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE), is("XA"));
assertTrue(actual.getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED));
assertTrue(actual.getValue(ConfigurationPropertyKey.CHECK_TABLE_METADATA_ENABLED));
}
@@ -58,7 +56,6 @@ public final class ConfigurationPropertiesTest {
assertThat(actual.getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), is(0));
assertThat(actual.getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY), is(1));
assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD), is(128));
- assertThat(actual.getValue(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE), is("LOCAL"));
assertFalse(actual.getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED));
assertFalse(actual.getValue(ConfigurationPropertyKey.CHECK_TABLE_METADATA_ENABLED));
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java
index b6b96a8..322d32c 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManager.java
@@ -62,7 +62,10 @@ import org.apache.shardingsphere.mode.metadata.MetaDataContextsBuilder;
import org.apache.shardingsphere.mode.persist.PersistService;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
+import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -74,6 +77,7 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.Properties;
import java.util.stream.Collectors;
/**
@@ -440,10 +444,16 @@ public final class ClusterContextManager implements ContextManager {
private ShardingSphereTransactionManagerEngine createNewEngine(final DatabaseType databaseType, final Map<String, DataSource> dataSources) {
ShardingSphereTransactionManagerEngine result = new ShardingSphereTransactionManagerEngine();
- result.init(databaseType, dataSources, metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE));
+ result.init(databaseType, dataSources, getTransactionRule().getProps().getProperty("xa-transaction-manager-type"));
return result;
}
+ private TransactionRule getTransactionRule() {
+ Optional<TransactionRule> transactionRule = metaDataContexts.getGlobalRuleMetaData().getRules().stream().filter(
+ each -> each instanceof TransactionRule).map(each -> (TransactionRule) each).findFirst();
+ return transactionRule.orElseGet(() -> new TransactionRule(new TransactionRuleConfiguration(TransactionType.LOCAL.name(), new Properties())));
+ }
+
private void renewContexts(final Map<String, ShardingSphereTransactionManagerEngine> engines) {
transactionContexts = new TransactionContexts(engines);
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index b6dbc2d..fd442f3 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConverter;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
@@ -34,7 +33,10 @@ import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositor
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
+import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -43,6 +45,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
@@ -181,7 +184,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
private TransactionContexts createTransactionContexts(final MetaDataContexts metaDataContexts) {
Map<String, ShardingSphereTransactionManagerEngine> engines = new HashMap<>(metaDataContexts.getAllSchemaNames().size(), 1);
- String xaTransactionMangerType = metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
+ String xaTransactionMangerType = getTransactionRule(metaDataContexts).getProps().getProperty("xa-transaction-manager-type");
for (String each : metaDataContexts.getAllSchemaNames()) {
ShardingSphereTransactionManagerEngine engine = new ShardingSphereTransactionManagerEngine();
ShardingSphereResource resource = metaDataContexts.getMetaData(each).getResource();
@@ -191,6 +194,12 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
return new TransactionContexts(engines);
}
+ private TransactionRule getTransactionRule(final MetaDataContexts metaDataContexts) {
+ Optional<TransactionRule> transactionRule = metaDataContexts.getGlobalRuleMetaData().getRules().stream().filter(
+ each -> each instanceof TransactionRule).map(each -> (TransactionRule) each).findFirst();
+ return transactionRule.orElseGet(() -> new TransactionRule(new TransactionRuleConfiguration(TransactionType.LOCAL.name(), new Properties())));
+ }
+
@Override
public String getType() {
return "Cluster";
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
index f1c23d0..d36a9a2 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
@@ -18,21 +18,24 @@
package org.apache.shardingsphere.mode.manager.memory;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.mode.metadata.MetaDataContextsBuilder;
-import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
-import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
+import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.Properties;
/**
@@ -53,7 +56,7 @@ public final class MemoryContextManagerBuilder implements ContextManagerBuilder
private TransactionContexts createTransactionContexts(final MetaDataContexts metaDataContexts) {
Map<String, ShardingSphereTransactionManagerEngine> engines = new HashMap<>(metaDataContexts.getAllSchemaNames().size(), 1);
- String xaTransactionMangerType = metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
+ String xaTransactionMangerType = getTransactionRule(metaDataContexts).getProps().getProperty("xa-transaction-manager-type");
for (String each : metaDataContexts.getAllSchemaNames()) {
ShardingSphereTransactionManagerEngine engine = new ShardingSphereTransactionManagerEngine();
ShardingSphereResource resource = metaDataContexts.getMetaData(each).getResource();
@@ -63,6 +66,12 @@ public final class MemoryContextManagerBuilder implements ContextManagerBuilder
return new TransactionContexts(engines);
}
+ private TransactionRule getTransactionRule(final MetaDataContexts metaDataContexts) {
+ Optional<TransactionRule> transactionRule = metaDataContexts.getGlobalRuleMetaData().getRules().stream().filter(
+ each -> each instanceof TransactionRule).map(each -> (TransactionRule) each).findFirst();
+ return transactionRule.orElseGet(() -> new TransactionRule(new TransactionRuleConfiguration(TransactionType.LOCAL.name(), new Properties())));
+ }
+
@Override
public String getType() {
return "Memory";
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index b7d6d74..94370af 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration
import org.apache.shardingsphere.infra.config.datasource.DataSourceConverter;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
@@ -34,7 +33,10 @@ import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRep
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
+import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -43,6 +45,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
@@ -173,7 +176,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
private TransactionContexts createTransactionContexts(final MetaDataContexts metaDataContexts) {
Map<String, ShardingSphereTransactionManagerEngine> engines = new HashMap<>(metaDataContexts.getAllSchemaNames().size(), 1);
- String xaTransactionMangerType = metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
+ String xaTransactionMangerType = getTransactionRule(metaDataContexts).getProps().getProperty("xa-transaction-manager-type");
for (String each : metaDataContexts.getAllSchemaNames()) {
ShardingSphereTransactionManagerEngine engine = new ShardingSphereTransactionManagerEngine();
ShardingSphereResource resource = metaDataContexts.getMetaData(each).getResource();
@@ -183,6 +186,12 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
return new TransactionContexts(engines);
}
+ private TransactionRule getTransactionRule(final MetaDataContexts metaDataContexts) {
+ Optional<TransactionRule> transactionRule = metaDataContexts.getGlobalRuleMetaData().getRules().stream().filter(
+ each -> each instanceof TransactionRule).map(each -> (TransactionRule) each).findFirst();
+ return transactionRule.orElseGet(() -> new TransactionRule(new TransactionRuleConfiguration(TransactionType.LOCAL.name(), new Properties())));
+ }
+
@Override
public String getType() {
return "Standalone";
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
index 04b2081..66cbaa7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSource.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource;
import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.proxy.backend.communication.BackendDataSource;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
import org.apache.shardingsphere.transaction.spi.ShardingSphereTransactionManager;
import javax.sql.DataSource;
@@ -31,6 +32,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
+import java.util.Properties;
/**
* Backend data source of JDBC.
@@ -60,9 +63,7 @@ public final class JDBCBackendDataSource implements BackendDataSource {
* @throws SQLException SQL exception
*/
public List<Connection> getConnections(final String schemaName, final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
- TransactionType transactionType = TransactionType.valueOf(
- ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE));
- return getConnections(schemaName, dataSourceName, connectionSize, connectionMode, transactionType);
+ return getConnections(schemaName, dataSourceName, connectionSize, connectionMode, getTransactionRule().getDefaultType());
}
/**
@@ -118,4 +119,10 @@ public final class JDBCBackendDataSource implements BackendDataSource {
private boolean isInTransaction(final ShardingSphereTransactionManager transactionManager) {
return null != transactionManager && transactionManager.isInTransaction();
}
+
+ private TransactionRule getTransactionRule() {
+ Optional<TransactionRule> transactionRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().getRules().stream().filter(
+ each -> each instanceof TransactionRule).map(each -> (TransactionRule) each).findFirst();
+ return transactionRule.orElseGet(() -> new TransactionRule(new TransactionRuleConfiguration(TransactionType.LOCAL.name(), new Properties())));
+ }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
index 4e7e69a..067225c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
@@ -45,16 +45,15 @@
# - sharding@:sharding
# provider:
# type: NATIVE
-#
+# - !TRANSACTION
+# defaultType: XA
+# props:
+# xa-transaction-manager-type: Atomikos
+
#props:
# max-connections-size-per-query: 1
# executor-size: 16 # Infinite by default.
# proxy-frontend-flush-threshold: 128 # The default value is 128.
-# # LOCAL: Proxy will run with LOCAL transaction.
-# # XA: Proxy will run with XA transaction.
-# # BASE: Proxy will run with B.A.S.E transaction.
-# proxy-transaction-type: LOCAL
-# xa-transaction-manager-type: Atomikos
# proxy-opentracing-enabled: false
# proxy-hint-enabled: false
# sql-show: false
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
index 475968f..f11f14b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
@@ -22,7 +22,6 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
-import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -31,7 +30,12 @@ import org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecuto
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.ProxyStateContext;
import org.apache.shardingsphere.readwritesplitting.route.impl.PrimaryVisitedManager;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+
+import java.util.Optional;
+import java.util.Properties;
/**
* Frontend channel inbound handler.
@@ -47,9 +51,13 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
public FrontendChannelInboundHandler(final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine) {
this.databaseProtocolFrontendEngine = databaseProtocolFrontendEngine;
- TransactionType transactionType = TransactionType.valueOf(
- ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.PROXY_TRANSACTION_TYPE));
- backendConnection = new BackendConnection(transactionType);
+ backendConnection = new BackendConnection(getTransactionRule().getDefaultType());
+ }
+
+ private TransactionRule getTransactionRule() {
+ Optional<TransactionRule> transactionRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().getRules().stream().filter(
+ each -> each instanceof TransactionRule).map(each -> (TransactionRule) each).findFirst();
+ return transactionRule.orElseGet(() -> new TransactionRule(new TransactionRuleConfiguration(TransactionType.LOCAL.name(), new Properties())));
}
@Override
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
index 0e749cd..67bddc3 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
@@ -26,7 +26,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: true
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml
index 0e749cd..67bddc3 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml
@@ -26,7 +26,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: true
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/h2/proxy/conf/server.yaml
index 89d333f..b37e394 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/mysql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/postgresql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/db/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/h2/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/mysql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/postgresql/proxy/conf/server.yaml
index 34f9c41..825eae5 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/h2/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/mysql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/postgresql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/dbtbl_with_readwrite_splitting_and_encrypt/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/h2/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/mysql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/postgresql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/encrypt/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/h2/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/mysql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/postgresql/proxy/conf/server.yaml
index 89d333f..b37e394 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/readwrite_splitting/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/h2/proxy/conf/server.yaml
index 8fb608b..09ed243 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/mysql/proxy/conf/server.yaml
index 8fb608b..09ed243 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/postgresql/proxy/conf/server.yaml
index 8fb608b..09ed243 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/sharding_governance/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/h2/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/h2/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/h2/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/h2/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/mysql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/mysql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/mysql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/mysql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/postgresql/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/postgresql/proxy/conf/server.yaml
index 47d31b9..687271a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/postgresql/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/docker/tbl/postgresql/proxy/conf/server.yaml
@@ -39,7 +39,6 @@ props:
max-connections-size-per-query: 1
executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
proxy-opentracing-enabled: false
proxy-hint-enabled: false
sql-show: false
diff --git a/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
new file mode 100644
index 0000000..0843ad6
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
@@ -0,0 +1,37 @@
+/*
+ * 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.transaction.config;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
+
+import java.util.Properties;
+
+/**
+ * Transaction rule configuration.
+ *
+ */
+@RequiredArgsConstructor
+@Getter
+public final class TransactionRuleConfiguration implements GlobalRuleConfiguration {
+
+ private final String defaultType;
+
+ private final Properties props;
+}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/constant/TransactionOrder.java b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/constant/TransactionOrder.java
new file mode 100644
index 0000000..014f7a9
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/constant/TransactionOrder.java
@@ -0,0 +1,33 @@
+/*
+ * 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.transaction.constant;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Transaction order.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class TransactionOrder {
+
+ /**
+ * Transaction order.
+ */
+ public static final int ORDER = 600;
+}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
new file mode 100644
index 0000000..42b82ea
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
@@ -0,0 +1,43 @@
+/*
+ * 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.transaction.rule;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.rule.identifier.level.KernelRule;
+import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.core.TransactionType;
+
+import java.util.Properties;
+
+/**
+ * Transaction rule.
+ *
+ */
+@Getter
+public final class TransactionRule implements KernelRule, GlobalRule {
+
+ private final TransactionType defaultType;
+
+ private final Properties props;
+
+ public TransactionRule(final TransactionRuleConfiguration ruleConfig) {
+ defaultType = TransactionType.valueOf(ruleConfig.getDefaultType());
+ props = ruleConfig.getProps();
+ }
+}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java
new file mode 100644
index 0000000..925ec61
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/TransactionRuleBuilder.java
@@ -0,0 +1,48 @@
+/*
+ * 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.transaction.rule.builder;
+
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.rule.builder.level.KernelRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.constant.TransactionOrder;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+
+import java.util.Map;
+
+/**
+ * Authority rule builder.
+ */
+public final class TransactionRuleBuilder implements KernelRuleBuilder, GlobalRuleBuilder<TransactionRuleConfiguration> {
+
+ @Override
+ public TransactionRule build(final TransactionRuleConfiguration ruleConfig, final Map<String, ShardingSphereMetaData> mataDataMap) {
+ return new TransactionRule(ruleConfig);
+ }
+
+ @Override
+ public int getOrder() {
+ return TransactionOrder.ORDER;
+ }
+
+ @Override
+ public Class<TransactionRuleConfiguration> getTypeClass() {
+ return TransactionRuleConfiguration.class;
+ }
+}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
new file mode 100644
index 0000000..134d6f5
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * 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.transaction.yaml.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+
+import java.util.Properties;
+
+/**
+ * Transaction rule configuration for YAML.
+ */
+@Getter
+@Setter
+public final class YamlTransactionRuleConfiguration implements YamlRuleConfiguration {
+
+ private String defaultType;
+
+ private Properties props = new Properties();
+
+ @Override
+ public Class<TransactionRuleConfiguration> getRuleConfigurationType() {
+ return TransactionRuleConfiguration.class;
+ }
+}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java
new file mode 100644
index 0000000..7fbc6fc
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java
@@ -0,0 +1,59 @@
+/*
+ * 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.transaction.yaml.swapper;
+
+import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.constant.TransactionOrder;
+import org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
+
+import java.util.Properties;
+
+/**
+ * Transaction rule configuration YAML swapper.
+ */
+public final class TransactionRuleConfigurationYamlSwapper implements YamlRuleConfigurationSwapper<YamlTransactionRuleConfiguration, TransactionRuleConfiguration> {
+
+ @Override
+ public YamlTransactionRuleConfiguration swapToYamlConfiguration(final TransactionRuleConfiguration data) {
+ YamlTransactionRuleConfiguration result = new YamlTransactionRuleConfiguration();
+ result.setDefaultType(data.getDefaultType());
+ result.setProps(null == data.getProps() ? new Properties() : data.getProps());
+ return result;
+ }
+
+ @Override
+ public TransactionRuleConfiguration swapToObject(final YamlTransactionRuleConfiguration yamlConfig) {
+ return new TransactionRuleConfiguration(yamlConfig.getDefaultType(), yamlConfig.getProps());
+ }
+
+ @Override
+ public Class<TransactionRuleConfiguration> getTypeClass() {
+ return TransactionRuleConfiguration.class;
+ }
+
+ @Override
+ public String getRuleTagName() {
+ return "TRANSACTION";
+ }
+
+ @Override
+ public int getOrder() {
+ return TransactionOrder.ORDER;
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
similarity index 69%
copy from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml
copy to shardingsphere-transaction/shardingsphere-transaction-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
index 0e749cd..df76f4a 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-opentelemetry/src/test/resources/docker/proxy/conf/server.yaml
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
@@ -15,18 +15,4 @@
# limitations under the License.
#
-rules:
- - !AUTHORITY
- users:
- - root@:root
- provider:
- type: NATIVE
-
-props:
- max-connections-size-per-query: 1
- executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
- proxy-opentracing-enabled: false
- proxy-hint-enabled: false
- sql-show: true
+org.apache.shardingsphere.transaction.rule.builder.TransactionRuleBuilder
diff --git a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
similarity index 69%
copy from shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
copy to shardingsphere-transaction/shardingsphere-transaction-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
index 0e749cd..c72d9ef 100644
--- a/shardingsphere-test/shardingsphere-integration-agent-test/shardingsphere-integration-agent-test-plugins/shardingsphere-integration-agent-test-metrics/src/test/resources/docker/proxy/conf/server.yaml
+++ b/shardingsphere-transaction/shardingsphere-transaction-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
@@ -15,18 +15,4 @@
# limitations under the License.
#
-rules:
- - !AUTHORITY
- users:
- - root@:root
- provider:
- type: NATIVE
-
-props:
- max-connections-size-per-query: 1
- executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- proxy-transaction-type: LOCAL
- proxy-opentracing-enabled: false
- proxy-hint-enabled: false
- sql-show: true
+org.apache.shardingsphere.transaction.yaml.swapper.TransactionRuleConfigurationYamlSwapper