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 5d61103  Add properties to transaction rule configuration, add DistSQL 
syntax: ALTER TRANSACTION RULE. (#14779)
5d61103 is described below

commit 5d611030f4573a0bee1c1c83e930f5acc88b002d
Author: Raigor <[email protected]>
AuthorDate: Fri Jan 14 18:54:44 2022 +0800

    Add properties to transaction rule configuration, add DistSQL syntax: ALTER 
TRANSACTION RULE. (#14779)
---
 .../src/main/antlr4/imports}/BaseRule.g4           | 16 ++----
 .../src/main/antlr4/imports/Keyword.g4             | 32 ++++++-----
 .../src/main/antlr4/imports/RALStatement.g4        | 26 ++++++++-
 .../src/main/antlr4/imports/RDLStatement.g4        | 12 +---
 .../parser/autogen/CommonDistSQLStatement.g4       |  1 +
 .../core/common/CommonDistSQLStatementVisitor.java | 66 +++++++++++++++-------
 .../parser/segment/TransactionProviderSegment.java | 15 ++---
 .../alter/AlterTransactionRuleStatement.java       | 12 ++--
 .../src/main/antlr4/imports/scaling/BaseRule.g4    |  2 +-
 .../config/TransactionRuleConfiguration.java       |  4 ++
 .../transaction/rule/TransactionRule.java          |  7 ++-
 ...DefaultTransactionRuleConfigurationBuilder.java |  4 +-
 .../config/YamlTransactionRuleConfiguration.java   |  4 ++
 .../TransactionRuleConfigurationYamlSwapper.java   |  3 +-
 .../transaction/ConnectionTransactionTest.java     | 39 ++++++++-----
 ...ShardingSphereTransactionManagerEngineTest.java |  3 +-
 .../context/TransactionContextsBuilderTest.java    |  3 +-
 ...eataATShardingSphereTransactionManagerTest.java | 66 +++++++++++-----------
 .../xa/XAShardingSphereTransactionManagerTest.java |  3 +-
 .../alter/AlterStatementExecutorFactory.java       | 10 +++-
 .../excutor/AlterTransactionRuleExecutor.java      | 65 +++++++++++++++++++++
 .../show/ShowTransactionRuleExecutorTest.java      |  3 +-
 22 files changed, 270 insertions(+), 126 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/BaseRule.g4
similarity index 80%
copy from 
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
copy to 
shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/BaseRule.g4
index 75436e0..5092673 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/BaseRule.g4
@@ -19,18 +19,14 @@ grammar BaseRule;
 
 import Symbol, Keyword, Literals;
 
-algorithmDefinition
-    : TYPE LP NAME EQ algorithmName (COMMA PROPERTIES LP algorithmProperties? 
RP)? RP
+propertiesDefinition
+    : COMMA PROPERTIES LP properties? RP
     ;
 
-algorithmName
-    : IDENTIFIER
+properties
+    : property (COMMA property)*
     ;
 
-algorithmProperties
-    : algorithmProperty (COMMA algorithmProperty)*
-    ;
-
-algorithmProperty
+property
     : key=(IDENTIFIER | STRING) EQ value=(INT | IDENTIFIER | STRING)
-    ;  
+    ;
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
index f56037f..f18f026 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
@@ -150,11 +150,11 @@ TABLES
 LIST
     : L I S T
     ;
-    
+
 TABLE
     : T A B L E
     ;
-    
+
 TRANSACTION
     : T R A N S A C T I O N
     ;
@@ -162,19 +162,19 @@ TRANSACTION
 RULES
     : R U L E S
     ;
-    
+
 RULE
     : R U L E
     ;
-    
+
 REFRESH
     : R E F R E S H
     ;
-    
+
 METADATA
     : M E T A D A T A
     ;
-    
+
 SQL_PARSER
     : S Q L UL_ P A R S E R
     ;
@@ -182,35 +182,39 @@ SQL_PARSER
 AUTHORITY
     : A U T H O R I T Y
     ;
-    
+
 TRUE
     : T R U E
     ;
-    
+
 FALSE
     : F A L S E
     ;
-    
+
 SQL_COMMENT_PARSE_ENABLE
     : S Q L UL_ C O M M E N T UL_ P A R S E UL_ E N A B L E
     ;
-    
+
 PARSE_TREE_CACHE
     : P A R S E UL_ T R E E UL_ C A C H E
     ;
-    
+
 SQL_STATEMENT_CACHE
     : S Q L UL_ S T A T E M E N T UL_ C A C H E
     ;
-    
+
 INITIAL_CAPACITY
     : I N I T I A L UL_ C A P A C I T Y
     ;
-    
+
 MAXIMUM_SIZE
     : M A X I M U M UL_ S I Z E
     ;
-    
+
 CONCURRENCY_LEVEL
     : C O N C U R R E N C Y UL_ L E V E L
     ;
+
+TYPE
+    : T Y P E
+    ;
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
index 061b359..c3b04d4 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
@@ -17,7 +17,7 @@
 
 grammar RALStatement;
 
-import Keyword, Literals, Symbol;
+import Keyword, Literals, Symbol, BaseRule;
 
 setVariable
     : SET VARIABLE variableName EQ variableValue
@@ -63,6 +63,10 @@ showTransactionRule
     : SHOW TRANSACTION RULE
     ;
 
+alterTransactionRule
+    : ALTER TRANSACTION RULE transactionRuleDefinition
+    ;
+
 showSQLParserRule
     : SHOW SQL_PARSER RULE
     ;
@@ -71,8 +75,24 @@ alterSQLParserRule
     : ALTER SQL_PARSER RULE sqlParserRuleDefinition
     ;
 
+transactionRuleDefinition
+    : LP DEFAULT EQ defaultType COMMA providerDefinition
+    ;
+
+providerDefinition
+    : TYPE LP NAME EQ providerName propertiesDefinition? RP
+    ;
+
+defaultType
+    : IDENTIFIER
+    ;
+
+providerName
+    : IDENTIFIER
+    ;
+
 sqlParserRuleDefinition
-    : (SQL_COMMENT_PARSE_ENABLE EQ sqlCommentParseEnable) (COMMA? 
PARSE_TREE_CACHE LP parseTreeCache RP)? (COMMA? SQL_STATEMENT_CACHE LP 
sqlStatementCache RP)?
+    : SQL_COMMENT_PARSE_ENABLE EQ sqlCommentParseEnable (COMMA 
PARSE_TREE_CACHE LP parseTreeCache RP)? (COMMA SQL_STATEMENT_CACHE LP 
sqlStatementCache RP)?
     ;
 
 variableName
@@ -124,7 +144,7 @@ sqlStatementCache
     ;
 
 cacheOption
-    : (INITIAL_CAPACITY EQ initialCapacity)? (COMMA? MAXIMUM_SIZE EQ 
maximumSize)? (COMMA? CONCURRENCY_LEVEL EQ concurrencyLevel)? 
+    : (INITIAL_CAPACITY EQ initialCapacity)? (COMMA MAXIMUM_SIZE EQ 
maximumSize)? (COMMA CONCURRENCY_LEVEL EQ concurrencyLevel)? 
     ;
 
 initialCapacity
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RDLStatement.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RDLStatement.g4
index 6782cf4..0b70951 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RDLStatement.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RDLStatement.g4
@@ -17,7 +17,7 @@
 
 grammar RDLStatement;
 
-import Keyword, Literals, Symbol;
+import Keyword, Literals, Symbol, BaseRule;
 
 addResource
     : ADD RESOURCE dataSource (COMMA dataSource)*
@@ -44,7 +44,7 @@ dropDefaultSingleTableRule
     ;
 
 dataSource
-    : dataSourceName LP (simpleSource | urlSource) COMMA USER EQ user (COMMA 
PASSWORD EQ password+)? (COMMA PROPERTIES LP poolProperties? RP)? RP
+    : dataSourceName LP (simpleSource | urlSource) COMMA USER EQ user (COMMA 
PASSWORD EQ password+)? propertiesDefinition? RP
     ;
 
 dataSourceName
@@ -91,14 +91,6 @@ password
     | DOT | SEMI | QUESTION | SQ | COLON | VERTICALBAR                    
     ;
 
-poolProperties
-    : poolProperty (COMMA poolProperty)*
-    ;
-
-poolProperty
-    : key=(IDENTIFIER | STRING) EQ value=(INT | IDENTIFIER | STRING)
-    ;
-
 ignoreSingleTables
     : IGNORE SINGLE TABLES
     ;
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
index 39ef51f..53c8e01 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
@@ -42,5 +42,6 @@ execute
     | alterSQLParserRule
     | showAuthorityRule
     | showTransactionRule
+    | alterTransactionRule
     ) SEMI?
     ;
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
index ca00fd7..d942299 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementPa
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AlterDefaultSingleTableRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AlterResourceContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AlterSQLParserRuleContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AlterTransactionRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.CacheOptionContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ClearHintContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.CreateDefaultSingleTableRuleContext;
@@ -34,8 +35,9 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementPa
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.InstanceDefinationContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.InstanceIdContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PasswordContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PoolPropertiesContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PoolPropertyContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PropertiesDefinitionContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PropertyContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ProviderDefinitionContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.RefreshTableMetadataContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.SchemaNameContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.SetVariableContext;
@@ -50,9 +52,13 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementPa
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowTransactionRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowVariableContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.SqlParserRuleDefinitionContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.TransactionRuleDefinitionContext;
 import org.apache.shardingsphere.distsql.parser.segment.CacheOptionSegment;
 import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
+import 
org.apache.shardingsphere.distsql.parser.segment.TransactionProviderSegment;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterSQLParserRuleStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterTransactionRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetInstanceStatusStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetVariableStatement;
@@ -61,9 +67,9 @@ import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAu
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowInstanceStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowSQLParserRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTableMetadataStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTransactionRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVariableStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.alter.AlterResourceStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterSQLParserRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.AddResourceStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.AlterDefaultSingleTableRuleStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.CreateDefaultSingleTableRuleStatement;
@@ -72,7 +78,6 @@ import 
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceS
 import 
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowSingleTableRulesStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowSingleTableStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowTransactionRuleStatement;
 import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
 import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
@@ -119,9 +124,9 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
             port = ctx.simpleSource().port().getText();
             dbName = ctx.simpleSource().dbName().getText();
         }
-        return new DataSourceSegment(getIdentifierValue(ctx.dataSourceName()), 
url, hostname, port, dbName,
-                ctx.user().getText(), null == ctx.password() ? "" : 
getPassword(ctx.password()),
-                null == ctx.poolProperties() ? new Properties() : 
getPoolProperties(ctx.poolProperties()));
+        String password = null == ctx.password() ? "" : 
getPassword(ctx.password());
+        Properties properties = getProperties(ctx.propertiesDefinition());
+        return new DataSourceSegment(getIdentifierValue(ctx.dataSourceName()), 
url, hostname, port, dbName, ctx.user().getText(), password, properties);
     }
     
     private String getPassword(final List<PasswordContext> passwordContexts) {
@@ -171,9 +176,13 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
         return new DropDefaultSingleTableRuleStatement();
     }
     
-    private Properties getPoolProperties(final PoolPropertiesContext ctx) {
+    private Properties getProperties(final PropertiesDefinitionContext ctx) {
         Properties result = new Properties();
-        for (PoolPropertyContext each : ctx.poolProperty()) {
+        if (null == ctx || null == ctx.properties()) {
+            return result;
+        }
+        List<PropertyContext> properties = ctx.properties().property();
+        for (PropertyContext each : properties) {
             result.setProperty(new 
IdentifierValue(each.key.getText()).getValue(), new 
IdentifierValue(each.value.getText()).getValue());
         }
         return result;
@@ -212,16 +221,6 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
     }
     
     @Override
-    public ASTNode visitShowSQLParserRule(final ShowSQLParserRuleContext ctx) {
-        return new ShowSQLParserRuleStatement();
-    }
-    
-    @Override
-    public ASTNode visitShowAuthorityRule(final ShowAuthorityRuleContext ctx) {
-        return new ShowAuthorityRuleStatement();
-    }
-    
-    @Override
     public ASTNode visitShowVariable(final ShowVariableContext ctx) {
         return new 
ShowVariableStatement(getIdentifierValue(ctx.variableName()).toUpperCase());
     }
@@ -252,11 +251,40 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
     }
     
     @Override
+    public ASTNode visitShowAuthorityRule(final ShowAuthorityRuleContext ctx) {
+        return new ShowAuthorityRuleStatement();
+    }
+    
+    @Override
     public ASTNode visitShowTransactionRule(final ShowTransactionRuleContext 
ctx) {
         return new ShowTransactionRuleStatement();
     }
     
     @Override
+    public ASTNode visitAlterTransactionRule(final AlterTransactionRuleContext 
ctx) {
+        return visit(ctx.transactionRuleDefinition());
+    }
+    
+    @Override
+    public ASTNode visitTransactionRuleDefinition(final 
TransactionRuleDefinitionContext ctx) {
+        String defaultType = getIdentifierValue(ctx.defaultType());
+        TransactionProviderSegment provider = (TransactionProviderSegment) 
visit(ctx.providerDefinition());
+        return new AlterTransactionRuleStatement(defaultType, provider);
+    }
+
+    @Override
+    public ASTNode visitProviderDefinition(final ProviderDefinitionContext 
ctx) {
+        String providerType = getIdentifierValue(ctx.providerName());
+        Properties props = getProperties(ctx.propertiesDefinition());
+        return new TransactionProviderSegment(providerType, props);
+    }
+
+    @Override
+    public ASTNode visitShowSQLParserRule(final ShowSQLParserRuleContext ctx) {
+        return new ShowSQLParserRuleStatement();
+    }
+    
+    @Override
     public ASTNode visitAlterSQLParserRule(final AlterSQLParserRuleContext 
ctx) {
         return super.visit(ctx.sqlParserRuleDefinition());
     }
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
 
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/TransactionProviderSegment.java
similarity index 76%
copy from 
shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
copy to 
shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/TransactionProviderSegment.java
index e86c595..a6a45d3 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/segment/TransactionProviderSegment.java
@@ -15,21 +15,22 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.transaction.config;
+package org.apache.shardingsphere.distsql.parser.segment;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
+import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+
+import java.util.Properties;
 
 /**
- * Transaction rule configuration.
- * 
+ * Transaction provider segment.
  */
 @RequiredArgsConstructor
 @Getter
-public final class TransactionRuleConfiguration implements 
GlobalRuleConfiguration {
-    
-    private final String defaultType;
+public final class TransactionProviderSegment implements ASTNode {
     
     private final String providerType;
+    
+    private final Properties props;
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
 
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/alter/AlterTransactionRuleStatement.java
similarity index 69%
copy from 
shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
copy to 
shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/alter/AlterTransactionRuleStatement.java
index e86c595..d0dfff8 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/alter/AlterTransactionRuleStatement.java
@@ -15,21 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.transaction.config;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common.alter;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
+import 
org.apache.shardingsphere.distsql.parser.segment.TransactionProviderSegment;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.AlterDistSQLStatement;
 
 /**
- * Transaction rule configuration.
- * 
+ * Alter Transaction rule statement.
  */
 @RequiredArgsConstructor
 @Getter
-public final class TransactionRuleConfiguration implements 
GlobalRuleConfiguration {
+public final class AlterTransactionRuleStatement extends AlterDistSQLStatement 
{
     
     private final String defaultType;
     
-    private final String providerType;
+    private final TransactionProviderSegment provider;
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
index 75436e0..3efe5b6 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/scaling/BaseRule.g4
@@ -33,4 +33,4 @@ algorithmProperties
 
 algorithmProperty
     : key=(IDENTIFIER | STRING) EQ value=(INT | IDENTIFIER | STRING)
-    ;  
+    ;
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
index e86c595..bce2fa6 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-api/src/main/java/org/apache/shardingsphere/transaction/config/TransactionRuleConfiguration.java
@@ -21,6 +21,8 @@ import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
 
+import java.util.Properties;
+
 /**
  * Transaction rule configuration.
  * 
@@ -32,4 +34,6 @@ public final class TransactionRuleConfiguration implements 
GlobalRuleConfigurati
     private final String defaultType;
     
     private final String providerType;
+    
+    private final Properties props;
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
index 9aafd60..509efd2 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/TransactionRule.java
@@ -22,6 +22,8 @@ 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.
  */
@@ -32,9 +34,12 @@ public final class TransactionRule implements GlobalRule {
     
     private final String providerType;
     
+    private final Properties props; 
+    
     public TransactionRule(final TransactionRuleConfiguration ruleConfig) {
-        defaultType = TransactionType.valueOf(ruleConfig.getDefaultType());
+        defaultType = 
TransactionType.valueOf(ruleConfig.getDefaultType().toUpperCase());
         providerType = ruleConfig.getProviderType();
+        props = ruleConfig.getProps();
     }
     
     @Override
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/DefaultTransactionRuleConfigurationBuilder.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/DefaultTransactionRuleConfigurationBuilder.java
index 05c280b..c1f45c3 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/DefaultTransactionRuleConfigurationBuilder.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/rule/builder/DefaultTransactionRuleConfigurationBuilder.java
@@ -22,6 +22,8 @@ import 
org.apache.shardingsphere.transaction.constant.TransactionOrder;
 import 
org.apache.shardingsphere.infra.rule.builder.global.DefaultGlobalRuleConfigurationBuilder;
 import org.apache.shardingsphere.transaction.core.TransactionType;
 
+import java.util.Properties;
+
 /**
  * Default transaction rule configuration builder.
  */
@@ -29,7 +31,7 @@ public final class DefaultTransactionRuleConfigurationBuilder 
implements Default
     
     @Override
     public TransactionRuleConfiguration build() {
-        return new TransactionRuleConfiguration(TransactionType.LOCAL.name(), 
null);
+        return new TransactionRuleConfiguration(TransactionType.LOCAL.name(), 
null, new Properties());
     }
     
     @Override
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
index 64eb325..fb69a90 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
@@ -22,6 +22,8 @@ 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.
  */
@@ -33,6 +35,8 @@ public final class YamlTransactionRuleConfiguration 
implements YamlRuleConfigura
     
     private String providerType;
     
+    private Properties props;
+    
     @Override
     public Class<TransactionRuleConfiguration> getRuleConfigurationType() {
         return TransactionRuleConfiguration.class;
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java
index a83028e..50c68d4 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationYamlSwapper.java
@@ -32,12 +32,13 @@ public final class TransactionRuleConfigurationYamlSwapper 
implements YamlRuleCo
         YamlTransactionRuleConfiguration result = new 
YamlTransactionRuleConfiguration();
         result.setDefaultType(data.getDefaultType());
         result.setProviderType(data.getProviderType());
+        result.setProps(data.getProps());
         return result;
     }
     
     @Override
     public TransactionRuleConfiguration swapToObject(final 
YamlTransactionRuleConfiguration yamlConfig) {
-        return new TransactionRuleConfiguration(yamlConfig.getDefaultType(), 
yamlConfig.getProviderType());
+        return new TransactionRuleConfiguration(yamlConfig.getDefaultType(), 
yamlConfig.getProviderType(), yamlConfig.getProps());
     }
     
     @Override
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java
index 05b44b8..4a86be3 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
 
 import java.util.Collections;
 import java.util.Map;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
@@ -34,47 +35,59 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 public final class ConnectionTransactionTest {
-
+    
     private ConnectionTransaction connectionTransaction;
-
+    
     @Test
-    public void assertDistributedTransactionOperationTypeCommit() throws 
Exception {
+    public void assertDistributedTransactionOperationTypeCommit() {
         Map<String, ShardingSphereTransactionManagerEngine> actualEngines = 
Collections.singletonMap(DefaultSchema.LOGIC_NAME, new 
ShardingSphereTransactionManagerEngine());
         TransactionContexts transactionContexts = new 
TransactionContexts(actualEngines);
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getXATransactionRule(), 
transactionContexts);
         DistributedTransactionOperationType operationType = 
connectionTransaction.getDistributedTransactionOperationType(true);
         assertThat(operationType, 
is(DistributedTransactionOperationType.COMMIT));
     }
-
+    
     @Test
     public void assertDistributedTransactionOperationTypeIgnore() {
         Map<String, ShardingSphereTransactionManagerEngine> actualEngines = 
Collections.singletonMap(DefaultSchema.LOGIC_NAME, new 
ShardingSphereTransactionManagerEngine());
         TransactionContexts transactionContexts = new 
TransactionContexts(actualEngines);
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getXATransactionRule(), 
transactionContexts);
         DistributedTransactionOperationType operationType = 
connectionTransaction.getDistributedTransactionOperationType(false);
         assertThat(operationType, 
is(DistributedTransactionOperationType.IGNORE));
     }
-
+    
     @Test
     public void assertIsLocalTransaction() {
         Map<String, ShardingSphereTransactionManagerEngine> actualEngines = 
Collections.singletonMap(DefaultSchema.LOGIC_NAME, new 
ShardingSphereTransactionManagerEngine());
         TransactionContexts transactionContexts = new 
TransactionContexts(actualEngines);
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("LOCAL", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getLocalTransactionRule(), 
transactionContexts);
         assertTrue(connectionTransaction.isLocalTransaction());
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getXATransactionRule(), 
transactionContexts);
         assertFalse(connectionTransaction.isLocalTransaction());
     }
-
+    
     @Test
     public void assertIsHoldTransaction() {
         Map<String, ShardingSphereTransactionManagerEngine> actualEngines = 
Collections.singletonMap(DefaultSchema.LOGIC_NAME, new 
ShardingSphereTransactionManagerEngine());
         TransactionContexts transactionContexts = new 
TransactionContexts(actualEngines);
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("LOCAL", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getLocalTransactionRule(), 
transactionContexts);
         assertTrue(connectionTransaction.isHoldTransaction(false));
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getXATransactionRule(), 
transactionContexts);
         assertTrue(connectionTransaction.isInTransaction());
         assertTrue(connectionTransaction.isHoldTransaction(true));
-        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, new TransactionRule(new 
TransactionRuleConfiguration("LOCAL", "Atomikos")), transactionContexts);
+        connectionTransaction = new 
ConnectionTransaction(DefaultSchema.LOGIC_NAME, getLocalTransactionRule(), 
transactionContexts);
         assertFalse(connectionTransaction.isHoldTransaction(true));
     }
+    
+    private TransactionRule getLocalTransactionRule() {
+        return new TransactionRule(getTransactionRuleConfiguration("LOCAL", 
null));
+    }
+    
+    private TransactionRule getXATransactionRule() {
+        return new TransactionRule(getTransactionRuleConfiguration("XA", 
"Atomikos"));
+    }
+    
+    private TransactionRuleConfiguration getTransactionRuleConfiguration(final 
String defaultType, final String providerType) {
+        return new TransactionRuleConfiguration(defaultType, providerType, new 
Properties());
+    }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
index 943d30a..7bc2031 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
@@ -25,6 +25,7 @@ import 
org.apache.shardingsphere.transaction.rule.TransactionRule;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
@@ -45,7 +46,7 @@ public final class ShardingSphereTransactionManagerEngineTest 
{
         Runnable caller = mock(Runnable.class);
         ShardingSphereTransactionManagerFixture transactionManager = 
(ShardingSphereTransactionManagerFixture) 
transactionManagerEngine.getTransactionManager(TransactionType.XA);
         transactionManager.setCaller(caller);
-        TransactionRule transactionRule = new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos"));
+        TransactionRule transactionRule = new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos", new Properties()));
         
transactionManagerEngine.init(DatabaseTypeRegistry.getActualDatabaseType("H2"), 
Collections.emptyMap(), transactionRule);
         verify(caller).run();
     }
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/context/TransactionContextsBuilderTest.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/context/TransactionContextsBuilderTest.java
index e979f18..009884e 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/context/TransactionContextsBuilderTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/context/TransactionContextsBuilderTest.java
@@ -33,6 +33,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertNotNull;
@@ -58,7 +59,7 @@ public final class TransactionContextsBuilderTest {
         
when(metaData.getResource().getDataSources()).thenReturn(createDataSourceMap());
         metaDataMap.put(DefaultSchema.LOGIC_NAME, metaData);
         Collection<ShardingSphereRule> globalRules = new LinkedList<>();
-        globalRules.add(new TransactionRule(new 
TransactionRuleConfiguration(TransactionType.LOCAL.name(), null)));
+        globalRules.add(new TransactionRule(new 
TransactionRuleConfiguration(TransactionType.LOCAL.name(), null, new 
Properties())));
         TransactionContexts transactionContexts = new 
TransactionContextsBuilder(metaDataMap, globalRules).build();
         Map<String, ShardingSphereTransactionManagerEngine> engines = 
transactionContexts.getEngines();
         assertThat(engines.size(), is(1));
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/bas
 [...]
index 775f239..0adca23 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java
@@ -17,23 +17,19 @@
 
 package org.apache.shardingsphere.transaction.base.seata.at;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.Field;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.sql.DataSource;
-
+import io.seata.core.context.RootContext;
+import io.seata.core.protocol.MergeResultMessage;
+import io.seata.core.protocol.MergedWarpMessage;
+import io.seata.core.protocol.RegisterRMRequest;
+import io.seata.core.protocol.RegisterRMResponse;
+import io.seata.core.protocol.RegisterTMRequest;
+import io.seata.core.protocol.RegisterTMResponse;
+import io.seata.core.rpc.netty.RmNettyRemotingClient;
+import io.seata.core.rpc.netty.TmNettyRemotingClient;
+import io.seata.rm.datasource.ConnectionProxy;
+import io.seata.rm.datasource.DataSourceProxy;
+import io.seata.tm.api.GlobalTransactionContext;
+import lombok.SneakyThrows;
 import org.apache.commons.dbcp2.BasicDataSource;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.executor.kernel.model.ExecutorDataMap;
@@ -50,19 +46,22 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 
-import io.seata.core.context.RootContext;
-import io.seata.core.protocol.MergedWarpMessage;
-import io.seata.core.protocol.MergeResultMessage;
-import io.seata.core.protocol.RegisterRMRequest;
-import io.seata.core.protocol.RegisterRMResponse;
-import io.seata.core.protocol.RegisterTMRequest;
-import io.seata.core.protocol.RegisterTMResponse;
-import io.seata.core.rpc.netty.RmNettyRemotingClient;
-import io.seata.core.rpc.netty.TmNettyRemotingClient;
-import io.seata.rm.datasource.ConnectionProxy;
-import io.seata.rm.datasource.DataSourceProxy;
-import io.seata.tm.api.GlobalTransactionContext;
-import lombok.SneakyThrows;
+import javax.sql.DataSource;
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Queue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 @RunWith(MockitoJUnitRunner.class)
 public final class SeataATShardingSphereTransactionManagerTest {
@@ -86,7 +85,7 @@ public final class 
SeataATShardingSphereTransactionManagerTest {
             }
         }
     }
-
+    
     @AfterClass
     public static void after() {
         MOCK_SEATA_SERVER.shutdown();
@@ -94,7 +93,8 @@ public final class 
SeataATShardingSphereTransactionManagerTest {
     
     @Before
     public void setUp() {
-        
seataTransactionManager.init(DatabaseTypeRegistry.getActualDatabaseType("MySQL"),
 getResourceDataSources(), new TransactionRule(new 
TransactionRuleConfiguration("BASE", "Seata")));
+        TransactionRuleConfiguration transactionRuleConfiguration = new 
TransactionRuleConfiguration("BASE", "Seata", new Properties());
+        
seataTransactionManager.init(DatabaseTypeRegistry.getActualDatabaseType("MySQL"),
 getResourceDataSources(), new TransactionRule(transactionRuleConfiguration));
     }
     
     @After
@@ -140,7 +140,7 @@ public final class 
SeataATShardingSphereTransactionManagerTest {
         assertTrue(seataTransactionManager.isInTransaction());
         assertResult();
     }
-
+    
     @Test
     public void assertBeginTimeout() {
         seataTransactionManager.begin(30);
diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManag
 [...]
index 9be061c..23bad5c 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java
@@ -42,6 +42,7 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
@@ -57,7 +58,7 @@ public final class XAShardingSphereTransactionManagerTest {
     @Before
     public void setUp() {
         Collection<ResourceDataSource> resourceDataSources = 
createResourceDataSources(DatabaseTypeRegistry.getActualDatabaseType("H2"));
-        TransactionRule transactionRule = new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos"));
+        TransactionRule transactionRule = new TransactionRule(new 
TransactionRuleConfiguration("XA", "Atomikos", new Properties()));
         
xaTransactionManager.init(DatabaseTypeRegistry.getActualDatabaseType("H2"), 
resourceDataSources, transactionRule);
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.java
index 13f00a6..1ca4015 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/AlterStatementExecutorFactory.java
@@ -17,11 +17,12 @@
 
 package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter;
 
-import com.mchange.v1.db.sql.UnsupportedTypeException;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.AlterDistSQLStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterSQLParserRuleStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterTransactionRuleStatement;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterSQLParserRuleExecutor;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.excutor.AlterTransactionRuleExecutor;
 
 import java.sql.SQLException;
 
@@ -33,15 +34,18 @@ public final class AlterStatementExecutorFactory {
     /**
      * Alter statement executor instance.
      *
-     * @param sqlStatement alter distsql statement
+     * @param sqlStatement alter dist SQL statement
      * @param connectionSession connection session
      * @return alter command executor
      * @throws SQLException SQL exception
      */
     public static AlterStatementExecutor newInstance(final 
AlterDistSQLStatement sqlStatement, final ConnectionSession connectionSession) 
throws SQLException {
+        if (sqlStatement instanceof AlterTransactionRuleStatement) {
+            return new 
AlterTransactionRuleExecutor((AlterTransactionRuleStatement) sqlStatement);
+        }
         if (sqlStatement instanceof AlterSQLParserRuleStatement) {
             return new 
AlterSQLParserRuleExecutor((AlterSQLParserRuleStatement) sqlStatement);
         }
-        throw new 
UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
+        throw new 
UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTransactionRuleExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTransactionRuleExecutor.java
new file mode 100644
index 0000000..76079c5
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/alter/excutor/AlterTransactionRuleExecutor.java
@@ -0,0 +1,65 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.alter.excutor;
+
+import lombok.AllArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.alter.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import 
org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.alter.AlterStatementExecutor;
+import 
org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+
+import java.util.Collection;
+import java.util.Optional;
+
+/**
+ * Alter transaction rule statement executor.
+ */
+@AllArgsConstructor
+public final class AlterTransactionRuleExecutor implements 
AlterStatementExecutor {
+    
+    private final AlterTransactionRuleStatement sqlStatement;
+    
+    @Override
+    public ResponseHeader execute() {
+        updateTransactionRule();
+        return new UpdateResponseHeader(sqlStatement);
+    }
+    
+    private void updateTransactionRule() {
+        MetaDataContexts metaDataContexts = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts();
+        ShardingSphereRuleMetaData globalRuleMetaData = 
metaDataContexts.getGlobalRuleMetaData();
+        Collection<RuleConfiguration> globalRuleConfigurations = 
globalRuleMetaData.getConfigurations();
+        globalRuleConfigurations.removeIf(each -> each instanceof 
TransactionRuleConfiguration);
+        TransactionRuleConfiguration toBeAlteredRuleConfig = 
buildTransactionRuleConfiguration();
+        globalRuleConfigurations.add(toBeAlteredRuleConfig);
+        Optional<MetaDataPersistService> metaDataPersistService = 
metaDataContexts.getMetaDataPersistService();
+        if (metaDataPersistService.isPresent() && null != 
metaDataPersistService.get().getGlobalRuleService()) {
+            
metaDataPersistService.get().getGlobalRuleService().persist(globalRuleConfigurations,
 true);
+        }
+    }
+    
+    private TransactionRuleConfiguration buildTransactionRuleConfiguration() {
+        return new TransactionRuleConfiguration(sqlStatement.getDefaultType(), 
sqlStatement.getProvider().getProviderType(), 
sqlStatement.getProvider().getProps());
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java
index 57a7923..ccd4707 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/show/ShowTransactionRuleExecutorTest.java
@@ -31,6 +31,7 @@ import org.mockito.junit.MockitoJUnitRunner;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
@@ -72,7 +73,7 @@ public final class ShowTransactionRuleExecutorTest {
     }
     
     private ShardingSphereRuleMetaData getGlobalRuleMetaData(final String 
defaultType, final String providerType) {
-        RuleConfiguration transactionRuleConfiguration = new 
TransactionRuleConfiguration(defaultType, providerType);
+        RuleConfiguration transactionRuleConfiguration = new 
TransactionRuleConfiguration(defaultType, providerType, new Properties());
         return new 
ShardingSphereRuleMetaData(Collections.singleton(transactionRuleConfiguration), 
Collections.emptyList());
     }
 }

Reply via email to