private int deleteSegments ( Log log , List < LogSegment > segments ) { int total = 0 ; for ( LogSegment segment : segments ) { boolean deleted = false ; try { try { segment . getMessageSet ( ) . close ( ) ; } catch ( IOException e ) { logger . warn ( e . getMessage ( ) , e ) ; } if ( ! segment . getFile ( ) . delete ( ) ) { deleted = true ; } else { total += 1 ; } } finally { logger . warn ( String . format ( "DELETE_LOG[%s] %s => %s" , log . name , segment . getFile ( ) . getAbsolutePath ( ) , deleted ) ) ; } } return total ; }
Attemps to delete all provided segments from a log and returns how many it was able to