use of com.actiontech.dble.statistic.stat.UserStat in project dble by actiontech.
the class DbleServer method recycleSqlStat.
// clean up the old data in SqlStat
private Runnable recycleSqlStat() {
return new Runnable() {
@Override
public void run() {
Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
for (UserStat userStat : statMap.values()) {
userStat.getSqlLastStat().recycle();
userStat.getSqlRecorder().recycle();
userStat.getSqlHigh().recycle();
userStat.getSqlLargeRowStat().recycle();
}
}
};
}
use of com.actiontech.dble.statistic.stat.UserStat in project dble by actiontech.
the class ReloadSqlSlowTime method execute.
public static void execute(ManagerConnection c, long time) {
Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
for (UserStat userStat : statMap.values()) {
userStat.setSlowTime(time);
}
LOGGER.info(String.valueOf(c) + "Reset show @@sql.slow=" + time + " time success by manager");
OkPacket ok = new OkPacket();
ok.setPacketId(1);
ok.setAffectedRows(1);
ok.setServerStatus(2);
ok.setMessage("Reset show @@sql.slow time success".getBytes());
ok.write(c);
}
use of com.actiontech.dble.statistic.stat.UserStat in project dble by actiontech.
the class ReloadUserStat method execute.
public static void execute(ManagerConnection c) {
Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
for (UserStat userStat : statMap.values()) {
userStat.reset();
}
LOGGER.info(String.valueOf(c) + "Reset show @@sql @@sql.sum @@sql.slow @@sql.high @@sql.large @@sql.resultset success by manager");
OkPacket ok = new OkPacket();
ok.setPacketId(1);
ok.setAffectedRows(1);
ok.setServerStatus(2);
ok.setMessage("Reset show @@sql @@sql.sum @@sql.slow @@sql.high @@sql.large @@sql.resultset success".getBytes());
ok.write(c);
}
use of com.actiontech.dble.statistic.stat.UserStat 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.statistic.stat.UserStat in project dble by actiontech.
the class DbleServer method resultSetMapClear.
/**
* clean up the data in UserStatAnalyzer
*/
private Runnable resultSetMapClear() {
return new Runnable() {
@Override
public void run() {
try {
BufferPool pool = getBufferPool();
long bufferSize = pool.size();
long bufferCapacity = pool.capacity();
long bufferUsagePercent = (bufferCapacity - bufferSize) * 100 / bufferCapacity;
if (bufferUsagePercent < DbleServer.getInstance().getConfig().getSystem().getBufferUsagePercent()) {
Map<String, UserStat> map = UserStatAnalyzer.getInstance().getUserStatMap();
Set<String> userSet = DbleServer.getInstance().getConfig().getUsers().keySet();
for (String user : userSet) {
UserStat userStat = map.get(user);
if (userStat != null) {
SqlResultSizeRecorder recorder = userStat.getSqlResultSizeRecorder();
recorder.clearSqlResultSet();
}
}
}
} catch (Exception e) {
LOGGER.info("resultSetMapClear err " + e);
}
}
};
}
Aggregations