private void updateIndicesAfterLogTruncation ( TaskAttemptID firstAttempt , Map < Task , Map < LogName , LogFileDetail > > updatedTaskLogFileDetails ) { for ( Entry < Task , Map < LogName , LogFileDetail > > entry : updatedTaskLogFileDetails . entrySet ( ) ) { Task task = entry . getKey ( ) ; Map < LogName , LogFileDetail > logFileDetails = entry . getValue ( ) ; Map < LogName , Long [ ] > logLengths = new HashMap < LogName , Long [ ] > ( ) ; // set current and previous lengths for ( LogName logName : TaskLog . LOGS_TRACKED_BY_INDEX_FILES ) { logLengths . put ( logName , new Long [ ] { Long . valueOf ( 0L ) , Long . valueOf ( 0L ) } ) ; LogFileDetail lfd = logFileDetails . get ( logName ) ; if ( lfd != null ) { // Set previous lengths logLengths . get ( logName ) [ 0 ] = Long . valueOf ( lfd . start ) ; // Set current lengths logLengths . get ( logName ) [ 1 ] = Long . valueOf ( lfd . start + lfd . length ) ; } } try { TaskLog . writeToIndexFile ( firstAttempt , task . getTaskID ( ) , task . isTaskCleanupTask ( ) , logLengths ) ; } catch ( IOException ioe ) { LOG . warn ( "Exception in updateIndicesAfterLogTruncation : " + StringUtils . stringifyException ( ioe ) ) ; LOG . warn ( "Exception encountered while updating index file of task " + task . getTaskID ( ) + ". Ignoring and continuing with other tasks." ) ; } } }
Truncation of logs is done . Now sync the index files to reflect the truncated sizes .