public void flushAllLogs ( final boolean force ) { Iterator < Log > iter = getLogIterator ( ) ; while ( iter . hasNext ( ) ) { Log log = iter . next ( ) ; try { boolean needFlush = force ; if ( ! needFlush ) { long timeSinceLastFlush = System . currentTimeMillis ( ) - log . getLastFlushedTime ( ) ; Integer logFlushInterval = logFlushIntervalMap . get ( log . getTopicName ( ) ) ; if ( logFlushInterval == null ) { logFlushInterval = config . getDefaultFlushIntervalMs ( ) ; } final String flushLogFormat = "[%s] flush interval %d, last flushed %d, need flush? %s" ; needFlush = timeSinceLastFlush >= logFlushInterval . intValue ( ) ; logger . trace ( String . format ( flushLogFormat , log . getTopicName ( ) , logFlushInterval , log . getLastFlushedTime ( ) , needFlush ) ) ; } if ( needFlush ) { log . flush ( ) ; } } catch ( IOException ioe ) { logger . error ( "Error flushing topic " + log . getTopicName ( ) , ioe ) ; logger . error ( "Halting due to unrecoverable I/O error while flushing logs: " + ioe . getMessage ( ) , ioe ) ; Runtime . getRuntime ( ) . halt ( 1 ) ; } catch ( Exception e ) { logger . error ( "Error flushing topic " + log . getTopicName ( ) , e ) ; } } }
flush all messages to disk