use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.
the class ShowSQLSlow 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();
Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
for (UserStat userStat : statMap.values()) {
String user = userStat.getUser();
List<SQLRecord> keyList = userStat.getSqlRecorder().getRecords();
for (SQLRecord key : keyList) {
if (key != null) {
RowDataPacket row = getRow(user, key, c.getCharset().getResults());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
}
if (isClear) {
userStat.clearSqlSlow();
}
}
// 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.EOFPacket in project dble by actiontech.
the class ShowSQLSumTable 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, TableStat> statMap = TableStatAnalyzer.getInstance().getTableStatMap();
for (TableStat tableStat : statMap.values()) {
i++;
RowDataPacket row = getRow(tableStat,i, c.getCharset());//getRow(sqlStat,sql, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c,true);
}
*/
List<TableStat> list = TableStatAnalyzer.getInstance().getTableStats(isClear);
if (list != null) {
int i = 1;
for (TableStat tableStat : list) {
if (tableStat != null) {
RowDataPacket row = getRow(tableStat, i, c.getCharset().getResults());
i++;
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.EOFPacket in project dble by actiontech.
the class ShowServer 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(c.getCharset().getResults());
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.EOFPacket in project dble by actiontech.
the class ConfFileHandler method handle.
public static void handle(String stmt, 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();
String theStmt = stmt.toUpperCase().trim();
PackageBufINf bufInf;
if (theStmt.equals("FILE @@LIST")) {
bufInf = listConfigFiles(c, buffer, packetId);
} else if (theStmt.startsWith("FILE @@SHOW")) {
int index = stmt.lastIndexOf(' ');
String fileName = stmt.substring(index + 1);
bufInf = showConfigFile(c, buffer, packetId, fileName);
} else if (theStmt.startsWith(UPLOAD_CMD)) {
int index = stmt.indexOf(' ', UPLOAD_CMD.length());
int index2 = stmt.indexOf(' ', index + 1);
if (index <= 0 || index2 <= 0 || index + 1 > stmt.length() || index2 + 1 > stmt.length()) {
bufInf = showInfo(c, buffer, packetId, "Invald param ,usage ");
}
String fileName = stmt.substring(index + 1, index2);
String content = stmt.substring(index2 + 1).trim();
bufInf = upLoadConfigFile(c, buffer, packetId, fileName, content);
} else {
bufInf = showInfo(c, buffer, packetId, "Invald command ");
}
packetId = bufInf.getPacketId();
buffer = bufInf.getBuffer();
// 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.EOFPacket in project dble by actiontech.
the class Explain2Handler method showError.
private static void showError(String stmt, ServerConnection c, String msg) {
ByteBuffer buffer = c.allocate();
// write header
ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT);
byte packetId = header.getPacketId();
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : FIELDS) {
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
// write eof
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.write(buffer, c, true);
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(stmt, c.getCharset().getResults()));
row.add(StringUtil.encode(msg, c.getCharset().getResults()));
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);
// post write
c.write(buffer);
}
Aggregations