use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class SingleNodeHandler method okResponse.
@Override
public void okResponse(byte[] data, MySQLConnection conn) {
boolean executeResponse = false;
try {
executeResponse = conn.syncAndExcute();
} catch (UnsupportedEncodingException e) {
executeException(conn);
}
if (executeResponse) {
conn.setRunning(false);
ServerConnection source = session.getSource();
if (source.isAutocommit()) {
session.clearConnections();
}
endRunning();
OkPacket ok = new OkPacket();
ok.read(data);
source.setLastInsertId(ok.insertId);
buffer = source.writeToBuffer(data, buffer);
source.write(buffer);
}
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class SingleNodeExecutor method setLastInsertId.
private void setLastInsertId(BinaryPacket bin, ServerConnection sc) {
OkPacket ok = new OkPacket();
ok.read(bin);
if (ok.insertId > 0) {
sc.setLastInsertId(ok.insertId);
}
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class KillHandler method getOkPacket.
private static OkPacket getOkPacket() {
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = 0;
packet.serverStatus = 2;
return packet;
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class BlockingSession method cancel.
@Override
public void cancel(FrontendConnection sponsor) {
// TODO terminate session
source.writeErrMessage(ErrorCode.ER_QUERY_INTERRUPTED, "Query execution was interrupted");
if (sponsor != null) {
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = 0;
packet.serverStatus = 2;
packet.write(sponsor);
}
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
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();
count++;
}
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = count;
packet.serverStatus = 2;
packet.write(mc);
}
Aggregations