Search in sources :

Example 1 with SqlResultSizeRecorder

use of com.actiontech.dble.statistic.stat.SqlResultSizeRecorder 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);
            }
        }
    };
}
Also used : DirectByteBufferPool(com.actiontech.dble.buffer.DirectByteBufferPool) BufferPool(com.actiontech.dble.buffer.BufferPool) UserStat(com.actiontech.dble.statistic.stat.UserStat) SqlResultSizeRecorder(com.actiontech.dble.statistic.stat.SqlResultSizeRecorder)

Aggregations

BufferPool (com.actiontech.dble.buffer.BufferPool)1 DirectByteBufferPool (com.actiontech.dble.buffer.DirectByteBufferPool)1 SqlResultSizeRecorder (com.actiontech.dble.statistic.stat.SqlResultSizeRecorder)1 UserStat (com.actiontech.dble.statistic.stat.UserStat)1