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