Search in sources :

Example 1 with HeartbeatPacket

use of com.actiontech.dble.net.mysql.HeartbeatPacket 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)

Aggregations

ErrorPacket (com.actiontech.dble.net.mysql.ErrorPacket)1 HeartbeatPacket (com.actiontech.dble.net.mysql.HeartbeatPacket)1 OkPacket (com.actiontech.dble.net.mysql.OkPacket)1