private void uploadPartsInParallel ( UploadPartRequestFactory requestFactory , String uploadId ) { Map < Integer , PartSummary > partNumbers = identifyExistingPartsForResume ( uploadId ) ; while ( requestFactory . hasMoreRequests ( ) ) { if ( threadPool . isShutdown ( ) ) throw new CancellationException ( "TransferManager has been shutdown" ) ; UploadPartRequest request = requestFactory . getNextUploadPartRequest ( ) ; if ( partNumbers . containsKey ( request . getPartNumber ( ) ) ) { PartSummary summary = partNumbers . get ( request . getPartNumber ( ) ) ; eTagsToSkip . add ( new PartETag ( request . getPartNumber ( ) , summary . getETag ( ) ) ) ; transferProgress . updateProgress ( summary . getSize ( ) ) ; continue ; } futures . add ( threadPool . submit ( new UploadPartCallable ( s3 , request , shouldCalculatePartMd5 ( ) ) ) ) ; } }
Submits a callable for each part to upload to our thread pool and records its corresponding Future .