Search in sources :

Example 71 with FieldPacket

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);
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) ExecutorService(java.util.concurrent.ExecutorService) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 72 with FieldPacket

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);
}
Also used : ThreadWorkUsage(com.actiontech.dble.statistic.stat.ThreadWorkUsage) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) Map(java.util.Map)

Example 73 with FieldPacket

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);
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 74 with FieldPacket

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);
}
Also used : Order(com.actiontech.dble.plan.Order) ItemField(com.actiontech.dble.plan.common.item.ItemField) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) RowDataComparator(com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)

Example 75 with FieldPacket

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();
    }
}
Also used : MySQLItemVisitor(com.actiontech.dble.plan.visitor.MySQLItemVisitor) PackageBufINf(com.actiontech.dble.manager.handler.PackageBufINf) ArrayList(java.util.ArrayList) ServerConnection(com.actiontech.dble.server.ServerConnection) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)81 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)65 ByteBuffer (java.nio.ByteBuffer)64 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)59 ArrayList (java.util.ArrayList)9 Map (java.util.Map)8 NIOProcessor (com.actiontech.dble.net.NIOProcessor)6 ResultSetHeaderPacket (com.actiontech.dble.net.mysql.ResultSetHeaderPacket)6 Item (com.actiontech.dble.plan.common.item.Item)6 UserStat (com.actiontech.dble.statistic.stat.UserStat)6 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)4 PackageBufINf (com.actiontech.dble.manager.handler.PackageBufINf)4 RowDataComparator (com.actiontech.dble.backend.mysql.nio.handler.util.RowDataComparator)3 ServerConfig (com.actiontech.dble.config.ServerConfig)3 FrontendConnection (com.actiontech.dble.net.FrontendConnection)3 Field (com.actiontech.dble.plan.common.field.Field)3 BackendConnection (com.actiontech.dble.backend.BackendConnection)2 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)2 TableConfig (com.actiontech.dble.config.model.TableConfig)2 UserConfig (com.actiontech.dble.config.model.UserConfig)2