Search in sources :

Example 11 with OkPacket

use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.

the class JDBCConnection method executeddl.

private void executeddl(ServerConnection sc, String sql) throws SQLException {
    Statement stmt = null;
    try {
        stmt = con.createStatement();
        int count = stmt.executeUpdate(sql);
        OkPacket okPck = new OkPacket();
        okPck.affectedRows = count;
        okPck.insertId = 0;
        okPck.packetId = ++packetId;
        okPck.message = " OK!".getBytes();
        this.respHandler.okResponse(okPck.writeToBytes(sc), this);
    } finally {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException e) {
            }
        }
    }
}
Also used : OkPacket(io.mycat.net.mysql.OkPacket)

Example 12 with OkPacket

use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.

the class PostgreSQLBackendConnectionHandler method doProcessCommandComplete.

private void doProcessCommandComplete(PostgreSQLBackendConnection con, CommandComplete commandComplete, SelectResponse response) {
    if (commandComplete.isSelectComplete()) {
        if (response == null) {
            throw new RuntimeException("the select proess err ,the SelectResponse is empty");
        }
        doProcessBusinessQuery(con, response, commandComplete);
    } else {
        OkPacket okPck = new OkPacket();
        okPck.affectedRows = commandComplete.getAffectedRows();
        okPck.insertId = commandComplete.getInsertId();
        okPck.packetId = ++packetId;
        okPck.message = commandComplete.getCommandResponse().getBytes();
        con.getResponseHandler().okResponse(okPck.writeToBytes(), con);
    }
}
Also used : OkPacket(io.mycat.net.mysql.OkPacket)

Example 13 with OkPacket

use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.

the class UnLockTablesHandler method okResponse.

@Override
public void okResponse(byte[] data, BackendConnection conn) {
    boolean executeResponse = conn.syncAndExcute();
    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.packetId = ++packetId;
                ok.serverStatus = session.getSource().isAutocommit() ? 2 : 1;
            } finally {
                lock.unlock();
            }
            ok.write(session.getSource());
        }
    }
}
Also used : OkPacket(io.mycat.net.mysql.OkPacket)

Example 14 with OkPacket

use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.

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 (NIOConnection c : list) {
            StringBuilder s = new StringBuilder();
            logger.warn(s.append(c).append("killed by manager").toString());
            c.close("kill by manager");
            count++;
        }
    }
    OkPacket packet = new OkPacket();
    packet.packetId = 1;
    packet.affectedRows = count;
    packet.serverStatus = 2;
    packet.write(mc);
}
Also used : FrontendConnection(io.mycat.net.FrontendConnection) OkPacket(io.mycat.net.mysql.OkPacket) NIOConnection(io.mycat.net.NIOConnection)

Example 15 with OkPacket

use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.

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();
    }
    StringBuilder s = new StringBuilder();
    s.append(c).append("Reset show @@sql  @@sql.sum  @@sql.slow success by manager");
    logger.warn(s.toString());
    OkPacket ok = new OkPacket();
    ok.packetId = 1;
    ok.affectedRows = 1;
    ok.serverStatus = 2;
    ok.message = "Reset show @@sql  @@sql.sum @@sql.slow success".getBytes();
    ok.write(c);
}
Also used : OkPacket(io.mycat.net.mysql.OkPacket) UserStat(io.mycat.statistic.stat.UserStat)

Aggregations

OkPacket (io.mycat.net.mysql.OkPacket)18 PhysicalDBPool (io.mycat.backend.datasource.PhysicalDBPool)2 UserStat (io.mycat.statistic.stat.UserStat)2 BackendConnection (io.mycat.backend.BackendConnection)1 UserConfig (io.mycat.config.model.UserConfig)1 ConfigException (io.mycat.config.util.ConfigException)1 FrontendConnection (io.mycat.net.FrontendConnection)1 NIOConnection (io.mycat.net.NIOConnection)1 ErrorPacket (io.mycat.net.mysql.ErrorPacket)1 HeartbeatPacket (io.mycat.net.mysql.HeartbeatPacket)1 RouteResultsetNode (io.mycat.route.RouteResultsetNode)1 ServerConnection (io.mycat.server.ServerConnection)1 QueryResult (io.mycat.statistic.stat.QueryResult)1 ArrayList (java.util.ArrayList)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1