Search in sources :

Example 16 with ErrorPacket

use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.

the class SingleNodeHandler method executeException.

private void executeException(BackendConnection c, Exception e) {
    ErrorPacket err = new ErrorPacket();
    err.packetId = ++packetId;
    err.errno = ErrorCode.ERR_FOUND_EXCEPION;
    err.message = StringUtil.encode(e.toString(), session.getSource().getCharset());
    this.backConnectionErr(err, c);
}
Also used : ErrorPacket(io.mycat.net.mysql.ErrorPacket)

Example 17 with ErrorPacket

use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.

the class SingleNodeHandler method connectionError.

@Override
public void connectionError(Throwable e, BackendConnection conn) {
    endRunning();
    ErrorPacket err = new ErrorPacket();
    err.packetId = ++packetId;
    err.errno = ErrorCode.ER_NEW_ABORTING_CONNECTION;
    err.message = StringUtil.encode(e.getMessage(), session.getSource().getCharset());
    ServerConnection source = session.getSource();
    source.write(err.write(allocBuffer(), source, true));
}
Also used : ErrorPacket(io.mycat.net.mysql.ErrorPacket) ServerConnection(io.mycat.server.ServerConnection)

Example 18 with ErrorPacket

use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.

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(io.mycat.net.mysql.ErrorPacket)

Example 19 with ErrorPacket

use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.

the class SequenceVal 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.message);
    LOGGER.warn("errorResponse " + err.errno + " " + errMsg);
    IncrSequenceMySQLHandler.latestErrors.put(seqVal.seqName, errMsg);
    conn.release();
}
Also used : ErrorPacket(io.mycat.net.mysql.ErrorPacket)

Example 20 with ErrorPacket

use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.

the class Heartbeat method response.

public static void response(ServerConnection c, byte[] data) {
    HeartbeatPacket hp = new HeartbeatPacket();
    hp.read(data);
    if (MycatServer.getInstance().isOnline()) {
        OkPacket ok = new OkPacket();
        ok.packetId = 1;
        ok.affectedRows = hp.id;
        ok.serverStatus = 2;
        ok.write(c);
        if (HEARTBEAT.isInfoEnabled()) {
            HEARTBEAT.info(responseMessage("OK", c, hp.id));
        }
    } else {
        ErrorPacket error = new ErrorPacket();
        error.packetId = 1;
        error.errno = ErrorCode.ER_SERVER_SHUTDOWN;
        error.message = String.valueOf(hp.id).getBytes();
        error.write(c);
        if (HEARTBEAT.isInfoEnabled()) {
            HEARTBEAT.info(responseMessage("ERROR", c, hp.id));
        }
    }
}
Also used : OkPacket(io.mycat.net.mysql.OkPacket) ErrorPacket(io.mycat.net.mysql.ErrorPacket) HeartbeatPacket(io.mycat.net.mysql.HeartbeatPacket)

Aggregations

ErrorPacket (io.mycat.net.mysql.ErrorPacket)21 IOException (java.io.IOException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HandshakePacket (io.mycat.net.mysql.HandshakePacket)2 ConnectionException (io.mycat.net.ConnectionException)1 AuthPacket (io.mycat.net.mysql.AuthPacket)1 BinaryPacket (io.mycat.net.mysql.BinaryPacket)1 HeartbeatPacket (io.mycat.net.mysql.HeartbeatPacket)1 OkPacket (io.mycat.net.mysql.OkPacket)1 Reply323Packet (io.mycat.net.mysql.Reply323Packet)1 ServerConnection (io.mycat.server.ServerConnection)1 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Socket (java.net.Socket)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1