core/src/main/java/org/infinispan/statetransfer/StateConsumerImpl.java
/**
    * Cancel transfers for segments we no longer own.
    *
    * @param removedSegments segments to be cancelled
    */
Cancel transfers for segments we no longer own.
@param removedSegments segments to be cancelled
Cancel transfers for segments we no longer own . @param removedSegments segments to be cancelled
private void cancelTransfers(Set<Integer> removedSegments) {
      synchronized (transferMapsLock) {
         List<Integer> segmentsToCancel = new ArrayList<>(removedSegments);
         while (!segmentsToCancel.isEmpty()) {
            int segmentId = segmentsToCancel.remove(0);
            InboundTransferTask inboundTransfer = transfersBySegment.get(segmentId);
            if (inboundTransfer != null) { 
               Set<Integer> cancelledSegments = new SmallIntSet(removedSegments);
               cancelledSegments.retainAll(inboundTransfer.getSegments());
               segmentsToCancel.removeAll(cancelledSegments);
               transfersBySegment.keySet().removeAll(cancelledSegments);
               inboundTransfer.cancelSegments(cancelledSegments);
               if (inboundTransfer.isCancelled()) {
                  removeTransfer(inboundTransfer);
               }
            }
         }
      }
   }
private void cancelTransfers ( Set < Integer > removedSegments ) { synchronized ( transferMapsLock ) { List < Integer > segmentsToCancel = new ArrayList < > ( removedSegments ) ; while ( ! segmentsToCancel . isEmpty ( ) ) { int segmentId = segmentsToCancel . remove ( 0 ) ; InboundTransferTask inboundTransfer = transfersBySegment . get ( segmentId ) ; if ( inboundTransfer != null ) { Set < Integer > cancelledSegments = new SmallIntSet ( removedSegments ) ; cancelledSegments . retainAll ( inboundTransfer . getSegments ( ) ) ; segmentsToCancel . removeAll ( cancelledSegments ) ; transfersBySegment . keySet ( ) . removeAll ( cancelledSegments ) ; inboundTransfer . cancelSegments ( cancelledSegments ) ; if ( inboundTransfer . isCancelled ( ) ) { removeTransfer ( inboundTransfer ) ; } } } } }
Cancel transfers for segments we no longer own.
Cancel transfers for segments we no longer own .
// we need to check the transfer was not already completed //this will also remove it from transfersBySource if the entire task gets cancelled