Search in sources :

Example 6 with OkPacket

use of com.actiontech.dble.net.mysql.OkPacket in project dble by actiontech.

the class SwitchDataSource method response.

public static void response(String stmt, ManagerConnection c) {
    int count = 0;
    Pair<String[], Integer> pair = ManagerParseSwitch.getPair(stmt);
    Map<String, PhysicalDBPool> dns = DbleServer.getInstance().getConfig().getDataHosts();
    Integer idx = pair.getValue();
    for (String key : pair.getKey()) {
        PhysicalDBPool dn = dns.get(key);
        if (dn != null) {
            int m = dn.getActiveIndex();
            int n = (idx == null) ? dn.next(m) : idx;
            if (dn.switchSource(n, false, "MANAGER")) {
                ++count;
            }
        // TODO:ELSE?
        }
    }
    OkPacket packet = new OkPacket();
    packet.setPacketId(1);
    packet.setAffectedRows(count);
    packet.setServerStatus(2);
    packet.write(c);
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool)

Example 7 with OkPacket

use of com.actiontech.dble.net.mysql.OkPacket in project dble by actiontech.

the class KillHandler method getOkPacket.

private static OkPacket getOkPacket() {
    OkPacket packet = new OkPacket();
    packet.setPacketId(1);
    packet.setAffectedRows(0);
    packet.setServerStatus(2);
    return packet;
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 8 with OkPacket

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

Example 9 with OkPacket

use of com.actiontech.dble.net.mysql.OkPacket in project dble by actiontech.

the class ReloadQueryCf method execute.

public static void execute(ManagerConnection c, String cf) {
    if (cf == null) {
        cf = "NULL";
    }
    QueryConditionAnalyzer.getInstance().setCf(cf);
    LOGGER.info(String.valueOf(c) + "Reset show  @@sql.condition=" + cf + " success by manager");
    OkPacket ok = new OkPacket();
    ok.setPacketId(1);
    ok.setAffectedRows(1);
    ok.setServerStatus(2);
    ok.setMessage("Reset show  @@sql.condition success".getBytes());
    ok.write(c);
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 10 with OkPacket

use of com.actiontech.dble.net.mysql.OkPacket in project dble by actiontech.

the class ReloadSqlSlowTime method execute.

public static void execute(ManagerConnection c, long time) {
    Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
    for (UserStat userStat : statMap.values()) {
        userStat.setSlowTime(time);
    }
    LOGGER.info(String.valueOf(c) + "Reset show  @@sql.slow=" + time + " time success by manager");
    OkPacket ok = new OkPacket();
    ok.setPacketId(1);
    ok.setAffectedRows(1);
    ok.setServerStatus(2);
    ok.setMessage("Reset show  @@sql.slow time success".getBytes());
    ok.write(c);
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket) UserStat(com.actiontech.dble.statistic.stat.UserStat)

Aggregations

OkPacket (com.actiontech.dble.net.mysql.OkPacket)14 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)2 UserStat (com.actiontech.dble.statistic.stat.UserStat)2 BackendConnection (com.actiontech.dble.backend.BackendConnection)1 FrontendConnection (com.actiontech.dble.net.FrontendConnection)1 ErrorPacket (com.actiontech.dble.net.mysql.ErrorPacket)1 HeartbeatPacket (com.actiontech.dble.net.mysql.HeartbeatPacket)1 RouteResultsetNode (com.actiontech.dble.route.RouteResultsetNode)1 Map (java.util.Map)1