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");
}
});
}
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();
}
});
}
Aggregations