private void checkAndFlush() {
        try {
            int nowSize = memoryQueue.size();
            if (nowSize == 0) {
                return;
            }
            List<JobLogPo> batch = new ArrayList<JobLogPo>();
            for (int i = 0; i < nowSize; i++) {
                JobLogPo jobLogPo = memoryQueue.poll();
                batch.add(jobLogPo);

                if (batch.size() >= batchFlushSize) {
                    flush(batch);
                }
            }
            if (batch.size() > 0) {
                flush(batch);
            }

        } finally {
            flushing.compareAndSet(true, false);
        }
    }
private void checkAndFlush ( ) { try { int nowSize = memoryQueue . size ( ) ; if ( nowSize == 0 ) { return ; } List < JobLogPo > batch = new ArrayList < JobLogPo > ( ) ; for ( int i = 0 ; i < nowSize ; i ++ ) { JobLogPo jobLogPo = memoryQueue . poll ( ) ; batch . add ( jobLogPo ) ; if ( batch . size ( ) >= batchFlushSize ) { flush ( batch ) ; } } if ( batch . size ( ) > 0 ) { flush ( batch ) ; } } finally { flushing . compareAndSet ( true , false ) ; } }
检查内存中是否有日志,如果有就批量刷盘