Search in sources :

Example 1 with AllJobFinishedListener

use of io.mycat.sqlengine.AllJobFinishedListener in project Mycat-Server by MyCATApache.

the class ShareRowOutPutDataHandler method processSQL.

public void processSQL(String sql, EngineCtx ctx) {
    String ssql = joinParser.getSql();
    getRoute(ssql);
    RouteResultsetNode[] nodes = rrs.getNodes();
    if (nodes == null || nodes.length == 0 || nodes[0].getName() == null || nodes[0].getName().equals("")) {
        ctx.getSession().getSource().writeErrMessage(ErrorCode.ER_NO_DB_ERROR, "No dataNode found ,please check tables defined in schema:" + ctx.getSession().getSource().getSchema());
        return;
    }
    this.ctx = ctx;
    String[] dataNodes = getDataNodes();
    maxjob = dataNodes.length;
    ShareDBJoinHandler joinHandler = new ShareDBJoinHandler(this, joinParser.getJoinLkey());
    ctx.executeNativeSQLSequnceJob(dataNodes, ssql, joinHandler);
    EngineCtx.LOGGER.info("Catlet exec:" + getDataNode(getDataNodes()) + " sql:" + ssql);
    ctx.setAllJobFinishedListener(new AllJobFinishedListener() {

        @Override
        public void onAllJobFinished(EngineCtx ctx) {
            if (!jointTableIsData) {
                ctx.writeHeader(fields);
            }
            ctx.writeEof();
            EngineCtx.LOGGER.info("发送数据OK");
        }
    });
}
Also used : RouteResultsetNode(io.mycat.route.RouteResultsetNode) AllJobFinishedListener(io.mycat.sqlengine.AllJobFinishedListener) EngineCtx(io.mycat.sqlengine.EngineCtx)

Example 2 with AllJobFinishedListener

use of io.mycat.sqlengine.AllJobFinishedListener in project Mycat-Server by MyCATApache.

the class MyRowOutPutDataHandler method processSQL.

public void processSQL(String sql, EngineCtx ctx) {
    DirectDBJoinHandler joinHandler = new DirectDBJoinHandler(ctx);
    String[] dataNodes = { "dn1", "dn2", "dn3" };
    ctx.executeNativeSQLSequnceJob(dataNodes, sql, joinHandler);
    ctx.setAllJobFinishedListener(new AllJobFinishedListener() {

        @Override
        public void onAllJobFinished(EngineCtx ctx) {
            ctx.writeEof();
        }
    });
}
Also used : AllJobFinishedListener(io.mycat.sqlengine.AllJobFinishedListener) EngineCtx(io.mycat.sqlengine.EngineCtx)

Aggregations

AllJobFinishedListener (io.mycat.sqlengine.AllJobFinishedListener)2 EngineCtx (io.mycat.sqlengine.EngineCtx)2 RouteResultsetNode (io.mycat.route.RouteResultsetNode)1