use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class SelectUser method response.
public static void response(ServerConnection c) {
if (MycatServer.getInstance().isOnline()) {
ByteBuffer buffer = c.allocate();
buffer = header.write(buffer, c, true);
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
buffer = eof.write(buffer, c, true);
byte packetId = eof.packetId;
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(getUser(c));
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
c.write(buffer);
} else {
error.write(c);
}
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowCobarCluster method getRows.
private static List<RowDataPacket> getRows(ServerConnection c) {
List<RowDataPacket> rows = new LinkedList<RowDataPacket>();
MycatConfig config = MycatServer.getInstance().getConfig();
MycatCluster cluster = config.getCluster();
Map<String, SchemaConfig> schemas = config.getSchemas();
SchemaConfig schema = (c.getSchema() == null) ? null : schemas.get(c.getSchema());
// 如果没有指定schema或者schema为null,则使用全部集群。
if (schema == null) {
Map<String, MycatNode> nodes = cluster.getNodes();
for (MycatNode n : nodes.values()) {
if (n != null && n.isOnline()) {
rows.add(getRow(n, c.getCharset()));
}
}
} else {
Map<String, MycatNode> nodes = cluster.getNodes();
for (MycatNode n : nodes.values()) {
if (n != null && n.isOnline()) {
rows.add(getRow(n, c.getCharset()));
}
}
}
if (rows.size() == 0) {
alarm.error(Alarms.CLUSTER_EMPTY + c.toString());
}
return rows;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowMyCATCluster method response.
public static void response(ServerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write field
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
for (RowDataPacket row : getRows(c)) {
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
// last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// post write
c.write(buffer);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowMyCATCluster method getRow.
private static RowDataPacket getRow(MycatNode node, String charset) {
MycatNodeConfig conf = node.getConfig();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(conf.getHost(), charset));
row.add(IntegerUtil.toBytes(conf.getWeight()));
return row;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat-Server by MyCATApache.
the class ShareRowOutPutDataHandler method getRow.
// 不是主键,获取join左边的的记录
private byte[] getRow(Map<String, byte[]> batchRowsCopy, String value, int index) {
for (Map.Entry<String, byte[]> e : batchRowsCopy.entrySet()) {
String key = e.getKey();
RowDataPacket rowDataPkg = ResultSetUtil.parseRowData(e.getValue(), afields);
byte[] columnValue = rowDataPkg.fieldValues.get(index);
if (columnValue == null)
continue;
String id = ByteUtil.getString(columnValue);
if (id.equals(value)) {
return batchRowsCopy.remove(key);
}
}
return null;
}
Aggregations