Search in sources :

Example 1 with RollbackReleaseHandler

use of com.alibaba.cobar.mysql.nio.handler.RollbackReleaseHandler in project cobar by alibaba.

the class NonBlockingSession method clearConnections.

private void clearConnections(boolean pessimisticRelease) {
    for (RouteResultsetNode node : target.keySet()) {
        MySQLConnection c = target.remove(node);
        if (c == null || c.isClosedOrQuit()) {
            continue;
        }
        // 如果通道正在运行中,则关闭当前通道。
        if (c.isRunning() || (pessimisticRelease && source.isClosed())) {
            c.close();
            continue;
        }
        // 非事务中的通道,直接释放资源。
        if (c.isAutocommit()) {
            c.release();
            continue;
        }
        c.setResponseHandler(new RollbackReleaseHandler());
        c.rollback();
    }
}
Also used : RouteResultsetNode(com.alibaba.cobar.route.RouteResultsetNode) MySQLConnection(com.alibaba.cobar.mysql.nio.MySQLConnection) RollbackReleaseHandler(com.alibaba.cobar.mysql.nio.handler.RollbackReleaseHandler)

Aggregations

MySQLConnection (com.alibaba.cobar.mysql.nio.MySQLConnection)1 RollbackReleaseHandler (com.alibaba.cobar.mysql.nio.handler.RollbackReleaseHandler)1 RouteResultsetNode (com.alibaba.cobar.route.RouteResultsetNode)1