use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class ReloadUser method execute.
public static void execute(ManagerConnection c) {
boolean status = false;
if (status) {
StringBuilder s = new StringBuilder();
s.append(c).append("Reload userConfig success by manager");
logger.warn(s.toString());
OkPacket ok = new OkPacket();
ok.packetId = 1;
ok.affectedRows = 1;
ok.serverStatus = 2;
ok.message = "Reload userConfig success".getBytes();
ok.write(c);
} else {
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
}
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class RollbackUser method execute.
public static void execute(ManagerConnection c) {
boolean status = false;
if (status) {
StringBuilder s = new StringBuilder();
s.append(c).append("Rollback user success by manager");
logger.warn(s.toString());
OkPacket ok = new OkPacket();
ok.packetId = 1;
ok.affectedRows = 1;
ok.serverStatus = 2;
ok.message = "Rollback user success".getBytes();
ok.write(c);
} else {
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
}
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
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().intValue() * 1000L;
Map<String, MySQLDataNode> dns = CobarServer.getInstance().getConfig().getDataNodes();
for (String key : keys.getKey()) {
MySQLDataNode dn = dns.get(key);
if (dn != null) {
dn.setHeartbeatRecoveryTime(TimeUtil.currentTimeMillis() + time);
++count;
StringBuilder s = new StringBuilder();
s.append(dn.getName()).append(" stop heartbeat '");
logger.warn(s.append(FormatUtil.formatTime(time, 3)).append("' by manager."));
}
}
}
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = count;
packet.serverStatus = 2;
packet.write(c);
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
the class RollbackConfig method execute.
public static void execute(ManagerConnection c) {
final ReentrantLock lock = CobarServer.getInstance().getConfig().getLock();
lock.lock();
try {
if (rollback()) {
StringBuilder s = new StringBuilder();
s.append(c).append("Rollback config success by manager");
LOGGER.warn(s.toString());
OkPacket ok = new OkPacket();
ok.packetId = 1;
ok.affectedRows = 1;
ok.serverStatus = 2;
ok.message = "Rollback config success".getBytes();
ok.write(c);
} else {
c.writeErrMessage(ErrorCode.ER_YES, "Rollback config failure");
}
} finally {
lock.unlock();
}
}
use of com.alibaba.cobar.net.mysql.OkPacket in project cobar by alibaba.
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, MySQLDataNode> dns = CobarServer.getInstance().getConfig().getDataNodes();
Integer idx = pair.getValue();
for (String key : pair.getKey()) {
MySQLDataNode dn = dns.get(key);
if (dn != null) {
int m = dn.getActivedIndex();
int n = (idx == null) ? dn.next(m) : idx.intValue();
if (dn.switchSource(n, false, "MANAGER")) {
++count;
}
}
}
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = count;
packet.serverStatus = 2;
packet.write(c);
}
Aggregations