Search in sources :

Example 36 with RowDataPacket

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

the class ShowBinlogStatus method getRow.

private static RowDataPacket getRow(String url, Map<String, String> result, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(url, charset));
    for (String field : FIELDS) {
        row.add(StringUtil.encode(result.get(field), charset));
    }
    return row;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 37 with RowDataPacket

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

the class ShowCommand method getRow.

private static RowDataPacket getRow(NIOProcessor processor) {
    CommandCount cc = processor.getCommands();
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(processor.getName().getBytes());
    row.add(LongUtil.toBytes(cc.initDBCount()));
    row.add(LongUtil.toBytes(cc.queryCount()));
    row.add(LongUtil.toBytes(cc.stmtPrepareCount()));
    row.add(LongUtil.toBytes(cc.stmtExecuteCount()));
    row.add(LongUtil.toBytes(cc.stmtCloseCount()));
    row.add(LongUtil.toBytes(cc.pingCount()));
    row.add(LongUtil.toBytes(cc.killCount()));
    row.add(LongUtil.toBytes(cc.quitCount()));
    row.add(LongUtil.toBytes(cc.otherCount()));
    return row;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) CommandCount(com.actiontech.dble.statistic.CommandCount)

Example 38 with RowDataPacket

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

the class ShowCommandCount 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 = getRow();
    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 39 with RowDataPacket

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

the class ShowConnection 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();
    NIOProcessor[] processors = DbleServer.getInstance().getFrontProcessors();
    for (NIOProcessor p : processors) {
        for (FrontendConnection fc : p.getFrontends().values()) {
            if (fc != null) {
                RowDataPacket row = getRow(fc, 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 : FrontendConnection(com.actiontech.dble.net.FrontendConnection) 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)

Example 40 with RowDataPacket

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

the class ShowConnectionCount method getRow.

private static RowDataPacket getRow() {
    int cons = 0;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    NIOProcessor[] processors = DbleServer.getInstance().getFrontProcessors();
    for (NIOProcessor p : processors) {
        for (FrontendConnection fc : p.getFrontends().values()) {
            if (fc != null) {
                cons++;
            }
        }
    }
    row.add(IntegerUtil.toBytes(cons));
    return row;
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) NIOProcessor(com.actiontech.dble.net.NIOProcessor)

Aggregations

RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)141 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)59 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)59 ByteBuffer (java.nio.ByteBuffer)59 ServerConfig (com.actiontech.dble.config.ServerConfig)8 NIOProcessor (com.actiontech.dble.net.NIOProcessor)8 Map (java.util.Map)8 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)7 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)7 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)7 LocalResult (com.actiontech.dble.backend.mysql.store.LocalResult)6 UnSortedLocalResult (com.actiontech.dble.backend.mysql.store.UnSortedLocalResult)6 DBHeartbeat (com.actiontech.dble.backend.heartbeat.DBHeartbeat)5 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)5 UserStat (com.actiontech.dble.statistic.stat.UserStat)5 BackendConnection (com.actiontech.dble.backend.BackendConnection)4 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)4 FrontendConnection (com.actiontech.dble.net.FrontendConnection)4 ResultSetHeaderPacket (com.actiontech.dble.net.mysql.ResultSetHeaderPacket)4 LinkedList (java.util.LinkedList)4