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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations