use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
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.getPacketId();
List<ExecutorService> executors = getExecutors();
for (ExecutorService exec : executors) {
if (exec != null) {
RowDataPacket row = getRow((NameableExecutor) exec, c.getCharset().getResults());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowThreadUsed method execute.
public static void execute(ManagerConnection c) {
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.getPacketId();
for (Map.Entry<String, ThreadWorkUsage> entry : DbleServer.getInstance().getThreadUsedMap().entrySet()) {
RowDataPacket row = getRow(entry.getKey(), entry.getValue(), c.getCharset().getResults());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowVersion 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.getPacketId();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(Versions.getServerVersion());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class MultiNodeSelectHandler method mergeFieldEof.
private void mergeFieldEof(List<byte[]> fields, BackendConnection conn) throws IOException {
fieldCount = fields.size();
List<FieldPacket> fieldPackets = new ArrayList<>();
for (byte[] field : fields) {
this.netOutBytes += field.length;
FieldPacket fieldPacket = new FieldPacket();
fieldPacket.read(field);
if (rrs.getSchema() != null) {
fieldPacket.setDb(rrs.getSchema().getBytes());
}
if (rrs.getTableAlias() != null) {
fieldPacket.setTable(rrs.getTableAlias().getBytes());
}
if (rrs.getTable() != null) {
fieldPacket.setOrgTable(rrs.getTable().getBytes());
}
fieldPackets.add(fieldPacket);
}
List<Order> orderBys = new ArrayList<>();
for (String groupBy : rrs.getGroupByCols()) {
ItemField itemField = new ItemField(rrs.getSchema(), rrs.getTableAlias(), groupBy);
orderBys.add(new Order(itemField));
}
rowComparator = new RowDataComparator(fieldPackets, orderBys);
outputHandler.fieldEofResponse(null, null, fieldPackets, null, false, conn);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowTablesHandler method fieldEofResponse.
@Override
public void fieldEofResponse(byte[] header, List<byte[]> fields, List<FieldPacket> fieldPacketsNull, byte[] eof, boolean isLeft, BackendConnection conn) {
ServerConnection source = session.getSource();
buffer = allocBuffer();
PackageBufINf bufInf;
if (info.isFull()) {
List<FieldPacket> fieldPackets = new ArrayList<>(2);
bufInf = ShowTables.writeFullTablesHeader(buffer, source, showTableSchema, fieldPackets);
packetId = bufInf.getPacketId();
buffer = bufInf.getBuffer();
if (info.getWhere() != null) {
MySQLItemVisitor mev = new MySQLItemVisitor(source.getSchema(), source.getCharset().getResultsIndex(), DbleServer.getInstance().getTmManager());
info.getWhereExpr().accept(mev);
sourceFields = HandlerTool.createFields(fieldPackets);
whereItem = HandlerTool.createItem(mev.getItem(), sourceFields, 0, false, DMLResponseHandler.HandlerType.WHERE);
bufInf = ShowTables.writeFullTablesRow(buffer, source, shardingTablesMap, packetId, whereItem, sourceFields);
packetId = bufInf.getPacketId();
buffer = bufInf.getBuffer();
} else {
bufInf = ShowTables.writeFullTablesRow(buffer, source, shardingTablesMap, packetId, null, null);
packetId = bufInf.getPacketId();
buffer = bufInf.getBuffer();
}
} else {
bufInf = ShowTables.writeTablesHeaderAndRows(buffer, source, shardingTablesMap, showTableSchema);
packetId = bufInf.getPacketId();
buffer = bufInf.getBuffer();
}
}
Aggregations