Search in sources :

Example 1 with BufferPool

use of com.actiontech.dble.buffer.BufferPool in project dble by actiontech.

the class ShowProcessor method getRow.

private static RowDataPacket getRow(NIOProcessor processor) {
    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 : BufferPool(com.actiontech.dble.buffer.BufferPool) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 2 with BufferPool

use of com.actiontech.dble.buffer.BufferPool 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)2 DirectByteBufferPool (com.actiontech.dble.buffer.DirectByteBufferPool)1 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)1 SqlResultSizeRecorder (com.actiontech.dble.statistic.stat.SqlResultSizeRecorder)1 UserStat (com.actiontech.dble.statistic.stat.UserStat)1