Search in sources :

Example 1 with ErrorPacket

use of com.alibaba.cobar.net.mysql.ErrorPacket in project cobar by alibaba.

the class SingleNodeHandler method connectionError.

@Override
public void connectionError(Throwable e, MySQLConnection conn) {
    if (!session.closeConnection(route)) {
        conn.close();
    }
    endRunning();
    ErrorPacket err = new ErrorPacket();
    err.packetId = ++packetId;
    err.errno = ErrorCode.ER_YES;
    err.message = StringUtil.encode(e.getMessage(), session.getSource().getCharset());
    ServerConnection source = session.getSource();
    source.write(err.write(buffer, source));
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket) ServerConnection(com.alibaba.cobar.server.ServerConnection)

Example 2 with ErrorPacket

use of com.alibaba.cobar.net.mysql.ErrorPacket in project cobar by alibaba.

the class MultiNodeHandler method backendConnError.

protected void backendConnError(MySQLConnection conn, String errMsg) {
    ErrorPacket err = new ErrorPacket();
    // ERROR_PACKET
    err.packetId = 1;
    err.errno = ErrorCode.ER_YES;
    err.message = StringUtil.encode(errMsg, session.getSource().getCharset());
    backendConnError(conn, err);
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket)

Example 3 with ErrorPacket

use of com.alibaba.cobar.net.mysql.ErrorPacket in project cobar by alibaba.

the class SingleNodeExecutor method handleError.

/**
 * 执行异常处理
 */
private void handleError(int errno, String message, BlockingSession ss) {
    endRunning();
    // 清理
    ss.clear();
    ServerConnection sc = ss.getSource();
    sc.setTxInterrupt();
    // 通知
    ErrorPacket err = new ErrorPacket();
    // ERROR_PACKET
    err.packetId = ++packetId;
    err.errno = errno;
    err.message = StringUtil.encode(message, sc.getCharset());
    err.write(sc);
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket) ServerConnection(com.alibaba.cobar.server.ServerConnection)

Example 4 with ErrorPacket

use of com.alibaba.cobar.net.mysql.ErrorPacket in project cobar by alibaba.

the class KillConnectionHandler method errorResponse.

@Override
public void errorResponse(byte[] data, MySQLConnection conn) {
    ErrorPacket err = new ErrorPacket();
    err.read(data);
    String msg = null;
    try {
        msg = new String(err.message, conn.getCharset());
    } catch (UnsupportedEncodingException e) {
        msg = new String(err.message);
    }
    LOGGER.warn("kill backend connection " + killee + " failed: " + msg);
    conn.release();
    killee.close();
    finished();
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 5 with ErrorPacket

use of com.alibaba.cobar.net.mysql.ErrorPacket in project cobar by alibaba.

the class RollbackNodeHandler method errorResponse.

@Override
public void errorResponse(byte[] data, MySQLConnection conn) {
    ErrorPacket err = new ErrorPacket();
    err.read(data);
    backendConnError(conn, err);
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket)

Aggregations

ErrorPacket (com.alibaba.cobar.net.mysql.ErrorPacket)26 ErrorPacketException (com.alibaba.cobar.exception.ErrorPacketException)6 UnknownPacketException (com.alibaba.cobar.exception.UnknownPacketException)6 BinaryPacket (com.alibaba.cobar.net.mysql.BinaryPacket)6 CommandPacket (com.alibaba.cobar.net.mysql.CommandPacket)4 HandshakePacket (com.alibaba.cobar.net.mysql.HandshakePacket)4 ServerConnection (com.alibaba.cobar.server.ServerConnection)4 HeartbeatException (com.alibaba.cobar.exception.HeartbeatException)2 UnknownCharsetException (com.alibaba.cobar.exception.UnknownCharsetException)1 UnknownDataNodeException (com.alibaba.cobar.exception.UnknownDataNodeException)1 HeartbeatPacket (com.alibaba.cobar.net.mysql.HeartbeatPacket)1 OkPacket (com.alibaba.cobar.net.mysql.OkPacket)1 Reply323Packet (com.alibaba.cobar.net.mysql.Reply323Packet)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1