Search in sources :

Example 1 with SqlResultSizeRecorder

use of io.mycat.statistic.stat.SqlResultSizeRecorder in project Mycat-Server by MyCATApache.

the class MycatServer method resultSetMapClear.

/**
	 * 在bufferpool使用率大于使用率阈值时不清理
	 * 在bufferpool使用率小于使用率阈值时清理大结果集清单内容
	 * 
	 */
private Runnable resultSetMapClear() {
    return new Runnable() {

        @Override
        public void run() {
            try {
                BufferPool bufferPool = getBufferPool();
                long bufferSize = bufferPool.size();
                long bufferCapacity = bufferPool.capacity();
                long bufferUsagePercent = (bufferCapacity - bufferSize) * 100 / bufferCapacity;
                if (bufferUsagePercent < config.getSystem().getBufferUsagePercent()) {
                    Map<String, UserStat> map = UserStatAnalyzer.getInstance().getUserStatMap();
                    Set<String> userSet = config.getUsers().keySet();
                    for (String user : userSet) {
                        UserStat userStat = map.get(user);
                        if (userStat != null) {
                            SqlResultSizeRecorder recorder = userStat.getSqlResultSizeRecorder();
                            //System.out.println(recorder.getSqlResultSet().size());
                            recorder.clearSqlResultSet();
                        }
                    }
                }
            } catch (Exception e) {
                LOGGER.warn("resultSetMapClear err " + e);
            }
        }

        ;
    };
}
Also used : BufferPool(io.mycat.buffer.BufferPool) DirectByteBufferPool(io.mycat.buffer.DirectByteBufferPool) UserStat(io.mycat.statistic.stat.UserStat) SqlResultSizeRecorder(io.mycat.statistic.stat.SqlResultSizeRecorder)

Aggregations

BufferPool (io.mycat.buffer.BufferPool)1 DirectByteBufferPool (io.mycat.buffer.DirectByteBufferPool)1 SqlResultSizeRecorder (io.mycat.statistic.stat.SqlResultSizeRecorder)1 UserStat (io.mycat.statistic.stat.UserStat)1