Search in sources :

Example 11 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class TransformSQLJob method run.

@Override
public void run() {
    try {
        if (ds == null) {
            RouteResultsetNode node = new RouteResultsetNode(databaseName, ServerParse.SELECT, sql);
            // create new connection
            PhysicalDBNode dn = DbleServer.getInstance().getConfig().getDataNodes().get(node.getName());
            dn.getConnection(dn.getDatabase(), false, true, node, this, node);
        } else {
            ds.getConnection(databaseName, true, this, null);
        }
    } catch (Exception e) {
        LOGGER.info("can't get connection for sql ,error:" + e);
        ErrorPacket errPacket = new ErrorPacket();
        errPacket.setPacketId(0);
        errPacket.setErrNo(ErrorCode.ER_YES);
        errPacket.setMessage(StringUtil.encode(e.toString(), StandardCharsets.UTF_8.toString()));
        writeError(errPacket.toBytes());
    }
}
Also used : PhysicalDBNode(com.actiontech.dble.backend.datasource.PhysicalDBNode) ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode)

Example 12 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class TransformSQLJob method connectionClose.

@Override
public void connectionClose(BackendConnection conn, String reason) {
    ErrorPacket errPacket = new ErrorPacket();
    errPacket.setPacketId(0);
    errPacket.setErrNo(ErrorCode.ER_YES);
    errPacket.setMessage(StringUtil.encode(reason, StandardCharsets.UTF_8.toString()));
    writeError(errPacket.toBytes());
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Example 13 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class TransformSQLJob method connectionAcquired.

@Override
public void connectionAcquired(BackendConnection conn) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("con query sql:" + sql + " to con:" + conn);
    }
    conn.setResponseHandler(this);
    connection = conn;
    try {
        conn.query(sql);
    } catch (Exception e) {
        // (UnsupportedEncodingException e) {
        ErrorPacket errPacket = new ErrorPacket();
        errPacket.setPacketId(0);
        errPacket.setErrNo(ErrorCode.ER_YES);
        errPacket.setMessage(StringUtil.encode(e.toString(), StandardCharsets.UTF_8.toString()));
        writeError(errPacket.toBytes());
    }
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Example 14 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class Heartbeat method response.

public static void response(ServerConnection c, byte[] data) {
    HeartbeatPacket hp = new HeartbeatPacket();
    hp.read(data);
    if (DbleServer.getInstance().isOnline()) {
        OkPacket ok = new OkPacket();
        ok.setPacketId(1);
        ok.setAffectedRows(hp.getId());
        ok.setServerStatus(2);
        ok.write(c);
        if (HEARTBEAT.isInfoEnabled()) {
            HEARTBEAT.info(responseMessage("OK", c, hp.getId()));
        }
    } else {
        ErrorPacket error = new ErrorPacket();
        error.setPacketId(1);
        error.setErrNo(ErrorCode.ER_SERVER_SHUTDOWN);
        error.setMessage(String.valueOf(hp.getId()).getBytes());
        error.write(c);
        if (HEARTBEAT.isInfoEnabled()) {
            HEARTBEAT.info(responseMessage("ERROR", c, hp.getId()));
        }
    }
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket) ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) HeartbeatPacket(com.actiontech.dble.net.mysql.HeartbeatPacket)

Example 15 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class FetchMySQLSequenceHandler method errorResponse.

@Override
public void errorResponse(byte[] data, BackendConnection conn) {
    SequenceVal seqVal = ((SequenceVal) conn.getAttachment());
    seqVal.dbfinished = true;
    ErrorPacket err = new ErrorPacket();
    err.read(data);
    String errMsg = new String(err.getMessage());
    LOGGER.info("errorResponse " + err.getErrNo() + " " + errMsg);
    IncrSequenceMySQLHandler.LATEST_ERRORS.put(seqVal.seqName, errMsg);
    conn.release();
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Aggregations

ErrorPacket (com.actiontech.dble.net.mysql.ErrorPacket)33 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)3 QueryNode (com.actiontech.dble.plan.node.QueryNode)3 ViewMeta (com.actiontech.dble.meta.ViewMeta)2 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)2 PlanNode (com.actiontech.dble.plan.node.PlanNode)2 MySQLPlanNodeVisitor (com.actiontech.dble.plan.visitor.MySQLPlanNodeVisitor)2 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)2 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)1 DMLResponseHandler (com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler)1 AllAnySubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.AllAnySubQueryHandler)1 InSubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.InSubQueryHandler)1 SingleRowSubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.SingleRowSubQueryHandler)1 SubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.SubQueryHandler)1 CallBackHandler (com.actiontech.dble.backend.mysql.nio.handler.util.CallBackHandler)1 CoordinatorLogEntry (com.actiontech.dble.backend.mysql.xa.CoordinatorLogEntry)1 TxState (com.actiontech.dble.backend.mysql.xa.TxState)1 HeartbeatPacket (com.actiontech.dble.net.mysql.HeartbeatPacket)1 OkPacket (com.actiontech.dble.net.mysql.OkPacket)1 ItemAllAnySubQuery (com.actiontech.dble.plan.common.item.subquery.ItemAllAnySubQuery)1