Search in sources :

Example 1 with HeartbeatPacket

use of io.mycat.net.mysql.HeartbeatPacket 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)1 HeartbeatPacket (io.mycat.net.mysql.HeartbeatPacket)1 OkPacket (io.mycat.net.mysql.OkPacket)1