Search in sources :

Example 1 with MultiNodeQueryHandler

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

the class NonBlockingSession method execute.

@Override
public void execute(RouteResultset rrs, int type) {
    if (LOGGER.isDebugEnabled()) {
        StringBuilder s = new StringBuilder();
        LOGGER.debug(s.append(source).append(rrs).toString());
    }
    // 检查路由结果是否为空
    RouteResultsetNode[] nodes = rrs.getNodes();
    if (nodes == null || nodes.length == 0) {
        source.writeErrMessage(ErrorCode.ER_NO_DB_ERROR, "No dataNode selected");
        return;
    }
    if (nodes.length == 1) {
        singleNodeHandler = new SingleNodeHandler(nodes[0], this);
    // singleNodeHandler.execute();
    } else {
        boolean autocommit = source.isAutocommit();
        if (autocommit && isModifySQL(type)) {
            autocommit = false;
        }
        multiNodeHandler = new MultiNodeQueryHandler(nodes, autocommit, this);
    // multiNodeHandler.execute();
    }
}
Also used : SingleNodeHandler(com.alibaba.cobar.mysql.nio.handler.SingleNodeHandler) MultiNodeQueryHandler(com.alibaba.cobar.mysql.nio.handler.MultiNodeQueryHandler) RouteResultsetNode(com.alibaba.cobar.route.RouteResultsetNode)

Aggregations

MultiNodeQueryHandler (com.alibaba.cobar.mysql.nio.handler.MultiNodeQueryHandler)1 SingleNodeHandler (com.alibaba.cobar.mysql.nio.handler.SingleNodeHandler)1 RouteResultsetNode (com.alibaba.cobar.route.RouteResultsetNode)1