boolean flush ( ) { if ( ! dirty ) return true ; acquireExclusiveLock ( ) ; try { final long timer = OProfiler . getInstance ( ) . startChrono ( ) ; // FORCE THE WRITE OF THE BUFFER for ( int i = 0 ; i < FORCE_RETRY ; ++ i ) { try { buffer . force ( ) ; dirty = false ; break ; } catch ( Exception e ) { OLogManager . instance ( ) . debug ( this , "Cannot write memory buffer to disk. Retrying (" + ( i + 1 ) + "/" + FORCE_RETRY + ")..." ) ; OMemoryWatchDog . freeMemory ( FORCE_DELAY ) ; } } if ( dirty ) OLogManager . instance ( ) . debug ( this , "Cannot commit memory buffer to disk after %d retries" , FORCE_RETRY ) ; else OProfiler . getInstance ( ) . updateCounter ( "system.file.mmap.pagesCommitted" , 1 ) ; OProfiler . getInstance ( ) . stopChrono ( "system.file.mmap.commitPages" , timer ) ; return ! dirty ; } finally { releaseExclusiveLock ( ) ; } }
Flushes the memory mapped buffer to disk only if it s dirty .