final void flush ( ) throws ObjectManagerException { final String methodName = "flush" ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . entry ( this , cclass , methodName ) ; int startPage = 0 ; // The logBuffer we will wait for. LogBuffer flushLogBuffer = null ; synchronized ( logBufferLock ) { startPage = lastPageFilling ; // // Don't flush a new empty page, where we have stepped past the sector byte // // but not put anything in it. // if (nextFreeByteInLogBuffer % pageSize == 1) { // int newStartPage = startPage -1; // if (lastPageNotified == newStartPage ) { // System.out.println("FFFFFFFFFFFFFFF Flush bypassed"); // if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled()) // trace.exit(this, // cclass, // "flush"); // return; // } // } // if (nextFreeByteInLogBuffer % pageSize == 1). // Capture the logBuffer containing the page we will flush. flushLogBuffer = logBuffer ; flushLogBuffer . pageWaiterExists [ startPage ] = true ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isDebugEnabled ( ) ) trace . debug ( this , cclass , methodName , new Object [ ] { "logBuffer_flushing" , new Integer ( startPage ) , new Integer ( firstPageFilling ) , new Integer ( lastPageFilling ) , new Integer ( flushLogBuffer . pageWritersActive . get ( startPage ) ) } ) ; } // synchronized (logBufferLock). flushLogBuffer . waitForFlush ( startPage ) ; if ( Tracing . isAnyTracingEnabled ( ) && trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , methodName ) ; }
Writes buffered output to hardened storage . By the time this method returns all of the data in the logBuffer must have been written to the disk . We mark the last page as having a thread waiting . If there are no threads currently writing to any page we wake the flushHelper otherwise we let the writers wake the flushHelper if it is stalled . Blocks until the write to disk has completed .