use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class ShowCommand 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();
for (NIOProcessor p : DbleServer.getInstance().getFrontProcessors()) {
RowDataPacket row = getRow(p);
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);
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class ShowCommandCount method getRow.
private static RowDataPacket getRow() {
long querys = 0;
for (NIOProcessor p : DbleServer.getInstance().getFrontProcessors()) {
querys += p.getCommands().queryCount();
}
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(LongUtil.toBytes(querys));
return row;
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class ShowConnection method getRow.
private static RowDataPacket getRow(FrontendConnection c, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(c.getProcessor().getName().getBytes());
row.add(LongUtil.toBytes(c.getId()));
row.add(StringUtil.encode(c.getHost(), charset));
row.add(IntegerUtil.toBytes(c.getPort()));
row.add(IntegerUtil.toBytes(c.getLocalPort()));
row.add(StringUtil.encode(c.getUser(), charset));
row.add(StringUtil.encode(c.getSchema(), charset));
row.add(StringUtil.encode(c.getCharset().getClient(), charset));
row.add(StringUtil.encode(c.getCharset().getCollation(), charset));
row.add(StringUtil.encode(c.getCharset().getResults(), charset));
row.add(LongUtil.toBytes(c.getNetInBytes()));
row.add(LongUtil.toBytes(c.getNetOutBytes()));
row.add(LongUtil.toBytes((TimeUtil.currentTimeMillis() - c.getStartupTime()) / 1000L));
ByteBuffer bb = c.getReadBuffer();
row.add(IntegerUtil.toBytes(bb == null ? 0 : bb.capacity()));
row.add(IntegerUtil.toBytes(c.getWriteQueue().size()));
String txLevel = "";
String autocommit = "";
if (c instanceof ServerConnection) {
ServerConnection serverConn = (ServerConnection) c;
txLevel = serverConn.getTxIsolation() + "";
autocommit = serverConn.isAutocommit() + "";
}
row.add(txLevel.getBytes());
row.add(autocommit.getBytes());
row.add(StringUtil.encode(c.getStringOfSysVariables(), charset));
row.add(StringUtil.encode(c.getStringOfUsrVariables(), charset));
return row;
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class ShowConnectionCount 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);
}
use of com.actiontech.dble.net.mysql.RowDataPacket in project dble by actiontech.
the class ShowConnectionSQL method getRow.
private static RowDataPacket getRow(FrontendConnection c, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(LongUtil.toBytes(c.getId()));
row.add(StringUtil.encode(c.getHost(), charset));
row.add(StringUtil.encode(c.getUser(), charset));
row.add(StringUtil.encode(c.getSchema(), charset));
row.add(StringUtil.encode(FormatUtil.formatDate(c.getLastReadTime()), charset));
long rt = c.getLastReadTime();
long wt = c.getLastWriteTime();
row.add(LongUtil.toBytes((wt > rt) ? (wt - rt) : (TimeUtil.currentTimeMillis() - rt)));
row.add(StringUtil.encode(c.getExecuteSql(), charset));
return row;
}
Aggregations