use of com.actiontech.dble.backend.mysql.nio.handler.transaction.xa.XAAutoCommitNodesHandler in project dble by actiontech.
the class MultiNodeQueryHandler method handleEndPacket.
protected void handleEndPacket(byte[] data, AutoTxOperation txOperation, BackendConnection conn) {
ServerConnection source = session.getSource();
if (source.isAutocommit() && !source.isTxStart() && conn.isModifiedSQLExecuted()) {
if (nodeCount < 0) {
return;
}
// Implicit Distributed Transaction,send commit or rollback automatically
if (txOperation == AutoTxOperation.COMMIT) {
if (!conn.isDDL()) {
session.checkBackupStatus();
}
if (session.getXaState() == null) {
NormalAutoCommitNodesHandler autoHandler = new NormalAutoCommitNodesHandler(session, data);
autoHandler.commit();
} else {
XAAutoCommitNodesHandler autoHandler = new XAAutoCommitNodesHandler(session, data, rrs.getNodes());
autoHandler.commit();
}
} else {
if (session.getXaState() == null) {
NormalAutoRollbackNodesHandler autoHandler = new NormalAutoRollbackNodesHandler(session, data, rrs.getNodes(), errConnection);
autoHandler.rollback();
} else {
XAAutoRollbackNodesHandler autoHandler = new XAAutoRollbackNodesHandler(session, data, rrs.getNodes(), errConnection);
autoHandler.rollback();
}
}
} else {
boolean inTransaction = !source.isAutocommit() || source.isTxStart();
if (!inTransaction) {
session.releaseConnection(conn);
}
// Explicit Distributed Transaction
if (inTransaction && (AutoTxOperation.ROLLBACK == txOperation)) {
source.setTxInterrupt("ROLLBACK");
}
if (nodeCount == 0) {
session.setResponseTime();
session.getSource().write(data);
}
}
}
Aggregations