Search in sources :

Example 16 with ErrorPacket

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

the class CobarDetectorHandler method handleErrorPacket.

/**
 * ERROR数据包处理
 */
private void handleErrorPacket(byte[] data) {
    ErrorPacket err = new ErrorPacket();
    err.read(data);
    switch(err.errno) {
        case ErrorCode.ER_SERVER_SHUTDOWN:
            source.getHeartbeat().setResult(CobarHeartbeat.OFF_STATUS, source, false, err.message);
            break;
        default:
            throw new HeartbeatException(new String(err.message));
    }
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket) HeartbeatException(com.alibaba.cobar.exception.HeartbeatException)

Example 17 with ErrorPacket

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

the class FrontendConnection method writeErrMessage.

public void writeErrMessage(byte id, int errno, String msg) {
    ErrorPacket err = new ErrorPacket();
    err.packetId = id;
    err.errno = errno;
    err.message = encodeString(msg, charset);
    err.write(this);
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket)

Example 18 with ErrorPacket

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

the class SingleNodeHandler method executeException.

private void executeException(MySQLConnection c) {
    c.setRunning(false);
    endRunning();
    session.clearConnections();
    ErrorPacket err = new ErrorPacket();
    err.packetId = ++packetId;
    err.errno = ErrorCode.ER_YES;
    err.message = StringUtil.encode("unknown backend charset: " + c.getCharset(), 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 19 with ErrorPacket

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

the class MultiNodeExecutor method notifyFailure.

/**
 * 通知,执行异常
 *
 * @throws nothing never throws any exception
 */
private void notifyFailure(BlockingSession ss) {
    try {
        // 清理
        ss.clear();
        ServerConnection sc = ss.getSource();
        sc.setTxInterrupt();
        // 通知
        ErrorPacket err = new ErrorPacket();
        // ERROR_PACKET
        err.packetId = ++packetId;
        err.errno = errno;
        err.message = StringUtil.encode(errMessage, sc.getCharset());
        sc.write(err.write(buffer, sc));
    } catch (Exception e) {
        LOGGER.warn("exception happens in failure notification: " + ss.getSource(), e);
    }
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket) ServerConnection(com.alibaba.cobar.server.ServerConnection) UnknownDataNodeException(com.alibaba.cobar.exception.UnknownDataNodeException) IOException(java.io.IOException)

Example 20 with ErrorPacket

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

the class CommitNodeHandler 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