Search in sources :

Example 1 with BufferPool

use of io.mycat.buffer.BufferPool 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)

Example 2 with BufferPool

use of io.mycat.buffer.BufferPool in project Mycat-Server by MyCATApache.

the class ShowProcessor method getRow.

private static RowDataPacket getRow(NIOProcessor processor, String charset) {
    BufferPool bufferPool = processor.getBufferPool();
    long bufferSize = bufferPool.size();
    long bufferCapacity = bufferPool.capacity();
    long bufferSharedOpts = bufferPool.getSharedOptsCount();
    long bufferUsagePercent = (bufferCapacity - bufferSize) * 100 / bufferCapacity;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(processor.getName().getBytes());
    row.add(LongUtil.toBytes(processor.getNetInBytes()));
    row.add(LongUtil.toBytes(processor.getNetOutBytes()));
    row.add(LongUtil.toBytes(0));
    row.add(IntegerUtil.toBytes(0));
    row.add(IntegerUtil.toBytes(processor.getWriteQueueSize()));
    row.add(LongUtil.toBytes(bufferSize));
    row.add(LongUtil.toBytes(bufferCapacity));
    row.add(LongUtil.toBytes(bufferUsagePercent));
    row.add(LongUtil.toBytes(bufferSharedOpts));
    row.add(IntegerUtil.toBytes(processor.getFrontends().size()));
    row.add(IntegerUtil.toBytes(processor.getBackends().size()));
    return row;
}
Also used : DirectByteBufferPool(io.mycat.buffer.DirectByteBufferPool) BufferPool(io.mycat.buffer.BufferPool) RowDataPacket(io.mycat.net.mysql.RowDataPacket)

Aggregations

BufferPool (io.mycat.buffer.BufferPool)2 DirectByteBufferPool (io.mycat.buffer.DirectByteBufferPool)2 RowDataPacket (io.mycat.net.mysql.RowDataPacket)1 SqlResultSizeRecorder (io.mycat.statistic.stat.SqlResultSizeRecorder)1 UserStat (io.mycat.statistic.stat.UserStat)1