Search in sources :

Example 26 with RowDataPacket

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

the class ShowSQLLarge method getRow.

private static RowDataPacket getRow(String user, UserSqlLargeStat.SqlLarge sql, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(user, charset));
    row.add(LongUtil.toBytes(sql.getSqlRows()));
    row.add(StringUtil.encode(FormatUtil.formatDate(sql.getStartTime()), charset));
    row.add(LongUtil.toBytes(sql.getExecuteTime()));
    row.add(StringUtil.encode(sql.getSql(), charset));
    return row;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 27 with RowDataPacket

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

the class ShowSQLSlow method getRow.

private static RowDataPacket getRow(String user, SQLRecord sql, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(user, charset));
    row.add(StringUtil.encode(FormatUtil.formatDate(sql.getStartTime()), charset));
    row.add(LongUtil.toBytes(sql.getExecuteTime()));
    row.add(StringUtil.encode(sql.getStatement(), charset));
    return row;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 28 with RowDataPacket

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

the class ShowSQLSumUser method execute.

public static void execute(ManagerConnection c, boolean isClear) {
    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();
    int i = 0;
    Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
    for (UserStat userStat : statMap.values()) {
        i++;
        RowDataPacket row = getRow(userStat, i, c.getCharset().getResults());
        row.setPacketId(++packetId);
        buffer = row.write(buffer, c, true);
    }
    if (isClear) {
        UserStatAnalyzer.getInstance().reset();
    }
    // 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) UserStat(com.actiontech.dble.statistic.stat.UserStat) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 29 with RowDataPacket

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

the class ShowSQLSumUser method getRow.

private static RowDataPacket getRow(UserStat userStat, long idx, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(LongUtil.toBytes(idx));
    if (userStat == null) {
        row.add(StringUtil.encode(("not fond"), charset));
        return row;
    }
    String user = userStat.getUser();
    UserSqlRWStat rwStat = userStat.getRWStat();
    long r = rwStat.getRCount();
    long w = rwStat.getWCount();
    String rStr = decimalFormat.format(1.0D * r / (r + w));
    int max = rwStat.getConcurrentMax();
    row.add(StringUtil.encode(user, charset));
    row.add(LongUtil.toBytes(r));
    row.add(LongUtil.toBytes(w));
    row.add(StringUtil.encode(String.valueOf(rStr), charset));
    row.add(StringUtil.encode(String.valueOf(max), charset));
    row.add(LongUtil.toBytes(rwStat.getNetInBytes()));
    row.add(LongUtil.toBytes(rwStat.getNetOutBytes()));
    row.add(StringUtil.encode(rwStat.getExecuteHistogram().toString(), charset));
    row.add(StringUtil.encode(rwStat.getTimeHistogram().toString(), charset));
    row.add(StringUtil.encode(FormatUtil.formatDate(rwStat.getLastExecuteTime()), charset));
    return row;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) UserSqlRWStat(com.actiontech.dble.statistic.stat.UserSqlRWStat)

Example 30 with RowDataPacket

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

the class ShowServer method getRow.

private static RowDataPacket getRow(String charset) {
    DbleServer server = DbleServer.getInstance();
    long startupTime = server.getStartupTime();
    long now = TimeUtil.currentTimeMillis();
    long upTime = now - startupTime;
    Runtime rt = Runtime.getRuntime();
    long total = rt.totalMemory();
    long max = rt.maxMemory();
    long used = (total - rt.freeMemory());
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(FormatUtil.formatTime(upTime, 3), charset));
    row.add(LongUtil.toBytes(used));
    row.add(LongUtil.toBytes(total));
    row.add(LongUtil.toBytes(max));
    row.add(StringUtil.encode(FormatUtil.formatDate(server.getConfig().getReloadTime()), charset));
    row.add(LongUtil.toBytes(server.getConfig().getRollbackTime()));
    row.add(StringUtil.encode(charset, charset));
    row.add(StringUtil.encode(DbleServer.getInstance().isOnline() ? "ON" : "OFF", charset));
    return row;
}
Also used : DbleServer(com.actiontech.dble.DbleServer) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

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