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);
}
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;
}
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()));
}
}
}
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);
}
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);
}
Aggregations