private int loadFSEdits ( ) throws IOException { FSDirectory fsDir = fsNamesys . dir ; int numEdits = 0 ; long startTime = FSNamesystem . now ( ) ; LOG . info ( "Ingest: Consuming transactions: " + this . toString ( ) ) ; try { logVersion = inputEditStream . getVersion ( ) ; if ( ! LayoutVersion . supports ( Feature . TXID_BASED_LAYOUT , logVersion ) ) throw new RuntimeException ( "Log version is too old" ) ; currentPosition = inputEditStream . getPosition ( ) ; numEdits = ingestFSEdits ( ) ; // continue to ingest } finally { LOG . info ( "Ingest: Closing ingest for segment: " + this . toString ( ) ) ; // At this time we are done reading the transaction log // We need to sync to have on disk status the same as in memory // if we saw end segment, we already synced if ( endTxId == - 1 && fsDir . fsImage . getEditLog ( ) . isOpen ( ) ) { fsDir . fsImage . getEditLog ( ) . logSync ( ) ; } inputEditStream . close ( ) ; standby . clearIngestState ( ) ; } LOG . info ( "Ingest: Edits segment: " + this . toString ( ) + " edits # " + numEdits + " loaded in " + ( FSNamesystem . now ( ) - startTime ) / 1000 + " seconds." ) ; if ( logVersion != FSConstants . LAYOUT_VERSION ) // other version numEdits ++ ; // save this image asap return numEdits ; }
Load an edit log and continue applying the changes to the in - memory structure . This is where we ingest transactions into the standby .