Search in sources :

Example 11 with OkPacket

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

the class ReloadUserStat method execute.

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

Example 12 with OkPacket

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

the class RollbackConfig method writeOKResult.

private static void writeOKResult(ManagerConnection c) {
    LOGGER.info(String.valueOf(c) + "Rollback config success by manager");
    OkPacket ok = new OkPacket();
    ok.setPacketId(1);
    ok.setAffectedRows(1);
    ok.setServerStatus(2);
    ok.setMessage("Rollback config success".getBytes());
    ok.write(c);
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 13 with OkPacket

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

the class StopHeartbeat method execute.

public static void execute(String stmt, ManagerConnection c) {
    int count = 0;
    Pair<String[], Integer> keys = ManagerParseStop.getPair(stmt);
    if (keys.getKey() != null && keys.getValue() != null) {
        long time = keys.getValue() * 1000L;
        Map<String, PhysicalDBPool> dns = DbleServer.getInstance().getConfig().getDataHosts();
        for (String key : keys.getKey()) {
            PhysicalDBPool dn = dns.get(key);
            if (dn != null) {
                dn.getSource().setHeartbeatRecoveryTime(TimeUtil.currentTimeMillis() + time);
                ++count;
                StringBuilder s = new StringBuilder();
                s.append(dn.getHostName()).append(" stop heartbeat '");
                LOGGER.info(s.append(FormatUtil.formatTime(time, 3)).append("' by manager.").toString());
            }
        }
    }
    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 14 with OkPacket

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

the class UnLockTablesHandler method execute.

public void execute() {
    Map<RouteResultsetNode, BackendConnection> lockedCons = session.getTargetMap();
    this.reset(lockedCons.size());
    // if client just send an unlock tables, theres is no lock tables statement, just send back OK
    if (lockedCons.size() == 0) {
        LOGGER.info("find no locked backend connection!" + session.getSource());
        OkPacket ok = new OkPacket();
        ok.setPacketId(++packetId);
        // the size of unlock table's response OK packet is 7
        ok.setPacketLength(7);
        ok.setServerStatus(session.getSource().isAutocommit() ? 2 : 1);
        ok.write(session.getSource());
        return;
    }
    for (Map.Entry<RouteResultsetNode, BackendConnection> entry : lockedCons.entrySet()) {
        RouteResultsetNode dataNode = entry.getKey();
        RouteResultsetNode node = new RouteResultsetNode(dataNode.getName(), ServerParse.UNLOCK, srcStatement);
        BackendConnection conn = lockedCons.get(dataNode);
        if (clearIfSessionClosed(session)) {
            return;
        }
        conn.setResponseHandler(this);
        conn.setSession(session);
        try {
            conn.execute(node, session.getSource(), autocommit);
        } catch (Exception e) {
            connectionError(e, conn);
        }
    }
}
Also used : BackendConnection(com.actiontech.dble.backend.BackendConnection) OkPacket(com.actiontech.dble.net.mysql.OkPacket) RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode) Map(java.util.Map)

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