Search in sources :

Example 51 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class ShowCostTimeStat 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();
    QueryTimeCost[] recorders = QueryTimeCostContainer.getInstance().getRecorders();
    int realPos = QueryTimeCostContainer.getInstance().getRealPos();
    int start = 0;
    int end = realPos;
    if (realPos != recorders.length - 1 && recorders[realPos + 1] != null) {
        start = realPos + 1;
        end = realPos + recorders.length;
    }
    for (int i = start; i <= end; i++) {
        RowDataPacket row = getRow(recorders[i % recorders.length], 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 : 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) QueryTimeCost(com.actiontech.dble.statistic.stat.QueryTimeCost)

Example 52 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class ShowDataSource method execute.

public static void execute(ManagerConnection c, String name) {
    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();
    ServerConfig conf = DbleServer.getInstance().getConfig();
    if (null != name) {
        PhysicalDBNode dn = conf.getDataNodes().get(name);
        for (PhysicalDatasource w : dn.getDbPool().getAllDataSources()) {
            RowDataPacket row = getRow(w, c.getCharset().getResults());
            row.setPacketId(++packetId);
            buffer = row.write(buffer, c, true);
        }
    } else {
        // add all
        for (Map.Entry<String, PhysicalDBPool> entry : conf.getDataHosts().entrySet()) {
            PhysicalDBPool dataHost = entry.getValue();
            for (int i = 0; i < dataHost.getSources().length; i++) {
                RowDataPacket row = getRow(dataHost.getSources()[i], c.getCharset().getResults());
                row.setPacketId(++packetId);
                buffer = row.write(buffer, c, true);
                if (dataHost.getrReadSources().get(i) != null) {
                    for (PhysicalDatasource w : dataHost.getrReadSources().get(i)) {
                        RowDataPacket sRow = getRow(w, c.getCharset().getResults());
                        sRow.setPacketId(++packetId);
                        buffer = sRow.write(buffer, c, true);
                    }
                }
            }
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : PhysicalDBNode(com.actiontech.dble.backend.datasource.PhysicalDBNode) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool) ByteBuffer(java.nio.ByteBuffer) ServerConfig(com.actiontech.dble.config.ServerConfig) PhysicalDatasource(com.actiontech.dble.backend.datasource.PhysicalDatasource) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) Map(java.util.Map)

Example 53 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class ShowDatasourceCluster method response.

public static void response(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();
    for (RowDataPacket row : getRows(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);
    // post write
    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 54 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class ShowHeartbeatDetail method response.

public static void response(ManagerConnection c, String stmt) {
    Pair<String, String> pair = ManagerParseHeartbeat.getPair(stmt);
    String name = pair.getValue();
    if (name.length() == 0) {
        c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
        return;
    }
    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();
    for (RowDataPacket row : getRows(name, 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);
    // post write
    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 55 with FieldPacket

use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.

the class ShowProcessor 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();
    for (NIOProcessor p : DbleServer.getInstance().getFrontProcessors()) {
        RowDataPacket row = getRow(p);
        row.setPacketId(++packetId);
        buffer = row.write(buffer, c, true);
    }
    for (NIOProcessor p : DbleServer.getInstance().getBackendProcessors()) {
        RowDataPacket row = getRow(p);
        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) NIOProcessor(com.actiontech.dble.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) 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