private void completeLog ( UfsJournalFile currentLog , long nextSequenceNumber ) throws IOException { String current = currentLog . getLocation ( ) . toString ( ) ; if ( nextSequenceNumber <= currentLog . getStart ( ) ) { LOG . info ( "No journal entry found in current journal file {}. Deleting it" , current ) ; if ( ! mUfs . deleteFile ( current ) ) { LOG . warn ( "Failed to delete empty journal file {}" , current ) ; } return ; } LOG . info ( "Completing log {} with next sequence number {}" , current , nextSequenceNumber ) ; String completed = UfsJournalFile . encodeLogFileLocation ( mJournal , currentLog . getStart ( ) , nextSequenceNumber ) . toString ( ) ; if ( ! mUfs . renameFile ( current , completed ) ) { // Completes could happen concurrently, check whether another master already did the rename. if ( ! mUfs . exists ( completed ) ) { throw new IOException ( String . format ( "Failed to rename journal log from %s to %s" , current , completed ) ) ; } if ( mUfs . exists ( current ) ) { // Rename is not atomic, so this could happen if we failed partway through a rename. LOG . info ( "Deleting current log {}" , current ) ; if ( ! mUfs . deleteFile ( current ) ) { LOG . warn ( "Failed to delete current log file {}" , current ) ; } } } }
Completes the given log .