public void cancelSegments ( IntSet cancelledSegments ) { if ( isCancelled ) { throw new IllegalArgumentException ( "The task is already cancelled." ) ; } if ( trace ) { log . tracef ( "Partially cancelling inbound state transfer from node %s, segments %s" , source , cancelledSegments ) ; } synchronized ( segments ) { // healthy paranoia if ( ! segments . containsAll ( cancelledSegments ) ) { throw new IllegalArgumentException ( "Some of the specified segments cannot be cancelled because they were not previously requested" ) ; } unfinishedSegments . removeAll ( cancelledSegments ) ; if ( unfinishedSegments . isEmpty ( ) ) { isCancelled = true ; } } sendCancelCommand ( cancelledSegments ) ; if ( isCancelled ) { notifyCompletion ( false ) ; } }
Cancels a set of segments and marks them as finished .