use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowSQLDetail method execute.
public static void execute(ManagerConnection c, long sql) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// 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);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// write buffer
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowSQLDetail method getRow.
private static RowDataPacket getRow(long sql, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add("mysql_1".getBytes());
row.add(LongUtil.toBytes(123L));
row.add(StringUtil.encode(nf.format(2.3), charset));
row.add(LongUtil.toBytes(1279188420682L));
row.add(StringUtil.encode(nf.format(3.42), charset));
return row;
}
use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowSQLExecute method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// write rows
byte packetId = eof.packetId;
for (int i = 0; i < 3; i++) {
RowDataPacket row = getRow(1000 * (i + 1), c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// write buffer
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowServer method getRow.
private static RowDataPacket getRow(String charset) {
CobarServer server = CobarServer.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(LongUtil.toBytes(server.getConfig().getReloadTime()));
row.add(LongUtil.toBytes(server.getConfig().getRollbackTime()));
row.add(StringUtil.encode(charset, charset));
row.add(StringUtil.encode(CobarServer.getInstance().isOnline() ? "ON" : "OFF", charset));
return row;
}
use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowSlow method getRow.
private static RowDataPacket getRow(SQLRecord sqlR, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(sqlR.host, charset));
row.add(StringUtil.encode(sqlR.schema, charset));
row.add(StringUtil.encode(sqlR.dataNode, charset));
row.add(IntegerUtil.toBytes(sqlR.dataNodeIndex));
row.add(LongUtil.toBytes(sqlR.startTime));
row.add(LongUtil.toBytes(sqlR.executeTime));
row.add(StringUtil.encode(sqlR.statement, charset));
return row;
}
Aggregations