use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
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 io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class ShowWhiteHost method setHost.
public static synchronized void setHost(ManagerConnection c, String ips) {
OkPacket ok = new OkPacket();
String[] users = ips.split(",");
if (users.length < 2) {
c.writeErrMessage(ErrorCode.ER_YES, "white host info error.");
return;
}
String host = "";
List<UserConfig> userConfigs = new ArrayList<UserConfig>();
int i = 0;
for (String user : users) {
if (i == 0) {
host = user;
i++;
} else {
i++;
UserConfig uc = MycatServer.getInstance().getConfig().getUsers().get(user);
if (null == uc) {
c.writeErrMessage(ErrorCode.ER_YES, "user doesn't exist in host.");
return;
}
if (uc.getSchemas() == null || uc.getSchemas().size() == 0) {
c.writeErrMessage(ErrorCode.ER_YES, "host contains one root privileges user.");
return;
}
userConfigs.add(uc);
}
}
if (MycatServer.getInstance().getConfig().getFirewall().addWhitehost(host, userConfigs)) {
try {
FirewallConfig.updateToFile(host, userConfigs);
} catch (Exception e) {
LOGGER.warn("set while host error : " + e.getMessage());
c.writeErrMessage(ErrorCode.ER_YES, "white host set success ,but write to file failed :" + e.getMessage());
}
ok.packetId = 1;
ok.affectedRows = 1;
ok.serverStatus = 2;
ok.message = "white host set to succeed.".getBytes();
ok.write(c);
} else {
c.writeErrMessage(ErrorCode.ER_YES, "host duplicated.");
}
}
use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
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, PhysicalDBPool> dns = MycatServer.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.warn(s.append(FormatUtil.formatTime(time, 3)).append("' by manager.").toString());
}
}
}
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = count;
packet.serverStatus = 2;
packet.write(c);
}
use of io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
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 io.mycat.net.mysql.OkPacket in project Mycat-Server by MyCATApache.
the class KillHandler method getOkPacket.
private static OkPacket getOkPacket() {
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = 0;
packet.serverStatus = 2;
return packet;
}
Aggregations