use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowThreadPool method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
List<NameableExecutor> executors = getExecutors();
for (NameableExecutor exec : executors) {
if (exec != null) {
RowDataPacket row = getRow(exec, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowThreadPool method getRow.
private static RowDataPacket getRow(NameableExecutor exec, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(exec.getName(), charset));
row.add(IntegerUtil.toBytes(exec.getPoolSize()));
row.add(IntegerUtil.toBytes(exec.getActiveCount()));
row.add(IntegerUtil.toBytes(exec.getQueue().size()));
row.add(LongUtil.toBytes(exec.getCompletedTaskCount()));
row.add(LongUtil.toBytes(exec.getTaskCount()));
return row;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowVariables method getRow.
private static RowDataPacket getRow(String name, String value, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(name, charset));
row.add(StringUtil.encode(value, charset));
return row;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowWhiteHost method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
Map<String, List<UserConfig>> map = MycatServer.getInstance().getConfig().getFirewall().getWhitehost();
for (String key : map.keySet()) {
List<UserConfig> userConfigs = map.get(key);
String users = "";
for (int i = 0; i < userConfigs.size(); i++) {
if (i > 0) {
users += "," + userConfigs.get(i).getName();
} else {
users += userConfigs.get(i).getName();
}
}
RowDataPacket row = getRow(key, users, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowHeartbeat method getRows.
private static List<RowDataPacket> getRows() {
List<RowDataPacket> list = new LinkedList<RowDataPacket>();
MycatConfig conf = MycatServer.getInstance().getConfig();
// host nodes
Map<String, PhysicalDBPool> dataHosts = conf.getDataHosts();
for (PhysicalDBPool pool : dataHosts.values()) {
for (PhysicalDatasource ds : pool.getAllDataSources()) {
DBHeartbeat hb = ds.getHeartbeat();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(ds.getName().getBytes());
row.add(ds.getConfig().getDbType().getBytes());
if (hb != null) {
row.add(ds.getConfig().getIp().getBytes());
row.add(IntegerUtil.toBytes(ds.getConfig().getPort()));
row.add(IntegerUtil.toBytes(hb.getStatus()));
row.add(IntegerUtil.toBytes(hb.getErrorCount()));
row.add(hb.isChecking() ? "checking".getBytes() : "idle".getBytes());
row.add(LongUtil.toBytes(hb.getTimeout()));
row.add(hb.getRecorder().get().getBytes());
String lat = hb.getLastActiveTime();
row.add(lat == null ? null : lat.getBytes());
row.add(hb.isStop() ? "true".getBytes() : "false".getBytes());
} else {
row.add(null);
row.add(null);
row.add(null);
row.add(null);
row.add(null);
row.add(null);
row.add(null);
row.add(null);
row.add(null);
}
list.add(row);
}
}
return list;
}
Aggregations