private void queueEmptyMaybeFlush ( ) { if ( PERIODIC_FORCE_FLUSH ) { long currentTime = time . get ( ) ; /* Try not to flush more than once every x times per mili-seconds time period. */ if ( ( currentTime - lastFlushTime ) > FORCE_FLUSH_AFTER_THIS_MANY_MILI_SECONDS ) { /* If the writer had things to flush, and we flushed then increment the number of flushes. */ if ( writer . syncToDisk ( ) ) { //could take 100 ms to 1 second this . numberOfFlushesTotal . incrementAndGet ( ) ; } /* We update the flush time no matter what. */ lastFlushTime = time . get ( ) ; } } }
If we detect that the in - coming transfer outputDataQueue channel is empty then it could be an excellent time to sync to disk .