Search in sources :

Example 26 with RowDataPacket

use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.

the class ShowHeartbeat 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.packetId;
    for (RowDataPacket row : getRows()) {
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 27 with RowDataPacket

use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.

the class ShowProcessor method getRow.

private static RowDataPacket getRow(NIOProcessor processor, String charset) {
    BufferPool bufferPool = processor.getBufferPool();
    long bufferSize = bufferPool.size();
    long bufferCapacity = bufferPool.capacity();
    long bufferSharedOpts = bufferPool.getSharedOptsCount();
    long bufferUsagePercent = (bufferCapacity - bufferSize) * 100 / bufferCapacity;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(processor.getName().getBytes());
    row.add(LongUtil.toBytes(processor.getNetInBytes()));
    row.add(LongUtil.toBytes(processor.getNetOutBytes()));
    row.add(LongUtil.toBytes(0));
    row.add(IntegerUtil.toBytes(0));
    row.add(IntegerUtil.toBytes(processor.getWriteQueueSize()));
    row.add(LongUtil.toBytes(bufferSize));
    row.add(LongUtil.toBytes(bufferCapacity));
    row.add(LongUtil.toBytes(bufferUsagePercent));
    row.add(LongUtil.toBytes(bufferSharedOpts));
    row.add(IntegerUtil.toBytes(processor.getFrontends().size()));
    row.add(IntegerUtil.toBytes(processor.getBackends().size()));
    return row;
}
Also used : DirectByteBufferPool(io.mycat.buffer.DirectByteBufferPool) BufferPool(io.mycat.buffer.BufferPool) RowDataPacket(io.mycat.net.mysql.RowDataPacket)

Example 28 with RowDataPacket

use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.

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.packetId;
    for (NIOProcessor p : MycatServer.getInstance().getProcessors()) {
        RowDataPacket row = getRow(p, c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) NIOProcessor(io.mycat.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 29 with RowDataPacket

use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.

the class ShowSQL method getRow.

private static RowDataPacket getRow(String user, UserSqlLastStat.SqlLast sql, int idx, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(LongUtil.toBytes(idx));
    row.add(StringUtil.encode(user, charset));
    row.add(LongUtil.toBytes(sql.getStartTime()));
    row.add(LongUtil.toBytes(sql.getExecuteTime()));
    row.add(StringUtil.encode(sql.getSql(), charset));
    return row;
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket)

Example 30 with RowDataPacket

use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.

the class ShowSQLDetail method execute.

public static void execute(ManagerConnection c, long sql) {
    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.packetId;
    for (int i = 0; i < 3; i++) {
        RowDataPacket row = getRow(sql, c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Aggregations

RowDataPacket (io.mycat.net.mysql.RowDataPacket)269 FieldPacket (io.mycat.net.mysql.FieldPacket)143 ByteBuffer (java.nio.ByteBuffer)140 EOFPacket (io.mycat.net.mysql.EOFPacket)137 MycatConfig (io.mycat.config.MycatConfig)20 LinkedList (java.util.LinkedList)16 PhysicalDatasource (io.mycat.backend.datasource.PhysicalDatasource)14 NIOProcessor (io.mycat.net.NIOProcessor)14 SchemaConfig (io.mycat.config.model.SchemaConfig)13 ResultSetHeaderPacket (io.mycat.net.mysql.ResultSetHeaderPacket)13 PhysicalDBPool (io.mycat.backend.datasource.PhysicalDBPool)12 UserStat (io.mycat.statistic.stat.UserStat)12 IOException (java.io.IOException)12 Map (java.util.Map)12 DBHeartbeat (io.mycat.backend.heartbeat.DBHeartbeat)10 ServerConnection (io.mycat.server.ServerConnection)10 BinaryRowDataPacket (io.mycat.net.mysql.BinaryRowDataPacket)8 File (java.io.File)8 DataSourceSyncRecorder (io.mycat.statistic.DataSourceSyncRecorder)6 BufferedReader (java.io.BufferedReader)6