You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/10/22 12:04:32 UTC

[GitHub] [shardingsphere] zhfeng commented on a change in pull request #13187: support XA transaction for proxy #12771

zhfeng commented on a change in pull request #13187:
URL: https://github.com/apache/shardingsphere/pull/13187#discussion_r734479989



##########
File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactory.java
##########
@@ -60,6 +76,35 @@ public static TextProtocolBackendHandler newInstance(final SQLStatementContext<?
             }
             return new TransactionBackendHandler(tclStatement, TransactionOperationType.BEGIN, backendConnection);
         }
+        if (tclStatement instanceof CommitStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.COMMIT, backendConnection);
+        }
+        if (tclStatement instanceof RollbackStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.ROLLBACK, backendConnection);
+        }
+        return null;
+    }
+
+    private static TextProtocolBackendHandler xAHandler(final TCLStatement tclStatement, final BackendConnection backendConnection) {
+        if (tclStatement instanceof MySQLXABeginStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.BEGIN, backendConnection);
+        }
+        if (tclStatement instanceof MySQLXAEndStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.SKIP, backendConnection);
+        }
+        if (tclStatement instanceof MySQLXAPrepareStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.SKIP, backendConnection);
+        }
+        if (tclStatement instanceof MySQLXACommitStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.COMMIT, backendConnection);
+        }
+        if (tclStatement instanceof MySQLXARollbackStatement) {
+            return new TransactionBackendHandler(tclStatement, TransactionOperationType.ROLLBACK, backendConnection);
+        }
+        return null;
+    }

Review comment:
       I'd like to suggest that move all of these XA Stattement handler to ```XABackendHandlerFactory``` class.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org