Search in sources :

Example 1 with OkPacket

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

the class UnLockTablesHandler method okResponse.

@Override
public void okResponse(byte[] data, BackendConnection conn) {
    boolean executeResponse = conn.syncAndExecute();
    if (executeResponse) {
        boolean isEndPack = decrementCountBy(1);
        session.releaseConnection(conn);
        if (isEndPack) {
            if (this.isFail() || session.closed()) {
                tryErrorFinished(true);
                return;
            }
            OkPacket ok = new OkPacket();
            ok.read(data);
            lock.lock();
            try {
                ok.setPacketId(++packetId);
                ok.setServerStatus(session.getSource().isAutocommit() ? 2 : 1);
            } finally {
                lock.unlock();
            }
            ok.write(session.getSource());
        }
    }
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 2 with OkPacket

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

the class LockTablesHandler method okResponse.

@Override
public void okResponse(byte[] data, BackendConnection conn) {
    boolean executeResponse = conn.syncAndExecute();
    if (executeResponse) {
        if (clearIfSessionClosed(session)) {
            return;
        }
        boolean isEndPack = decrementCountBy(1);
        if (isEndPack) {
            if (this.isFail() || session.closed()) {
                tryErrorFinished(true);
                return;
            }
            OkPacket ok = new OkPacket();
            ok.read(data);
            lock.lock();
            try {
                ok.setPacketId(++packetId);
                ok.setServerStatus(session.getSource().isAutocommit() ? 2 : 1);
            } finally {
                lock.unlock();
            }
            ok.write(session.getSource());
        }
    }
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 3 with OkPacket

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

the class KillConnection method response.

public static void response(String stmt, int offset, ManagerConnection mc) {
    int count = 0;
    List<FrontendConnection> list = getList(stmt, offset, mc);
    if (list != null) {
        for (FrontendConnection c : list) {
            StringBuilder s = new StringBuilder();
            LOGGER.info(s.append(c).append("killed by manager").toString());
            c.killAndClose("kill by manager");
            count++;
        }
    }
    OkPacket packet = new OkPacket();
    packet.setPacketId(1);
    packet.setAffectedRows(count);
    packet.setServerStatus(2);
    packet.write(mc);
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 4 with OkPacket

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

the class ReloadConfig method writeOKResult.

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

Example 5 with OkPacket

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

the class ReloadMetaData method execute.

public static void execute(ManagerConnection c) {
    String msg = "data host has no write_host";
    if (!DbleServer.getInstance().getConfig().isDataHostWithoutWR()) {
        DbleServer.getInstance().setMetaChanging(true);
        DbleServer.getInstance().reloadMetaData(DbleServer.getInstance().getConfig());
        DbleServer.getInstance().setMetaChanging(false);
        msg = "reload metadata success";
    }
    LOGGER.info(msg);
    OkPacket ok = new OkPacket();
    ok.setPacketId(1);
    ok.setAffectedRows(1);
    ok.setServerStatus(2);
    ok.setMessage(msg.getBytes());
    ok.write(c);
}
Also used : OkPacket(com.actiontech.dble.net.mysql.OkPacket)

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