Class ResourcesDownloader

  • All Implemented Interfaces:

    
    public class ResourcesDownloader
    
                        

    Manages the parallel http resources download. A shared thread pool is used by all the sample. A sampler will usually do the following

    
      // list of AsynSamplerResultHolder to download
      List<Callable<AsynSamplerResultHolder>> list = ...
    
      // max parallel downloads
      int maxConcurrentDownloads = ...
    
      // get the singleton instance
      ResourcesDownloader resourcesDownloader = ResourcesDownloader.getInstance();
    
      // schedule the downloads and wait for the completion
      List<Future<AsynSamplerResultHolder>> retExec =
              resourcesDownloader.invokeAllAndAwaitTermination(maxConcurrentDownloads, list);
    
    
    the call to invokeAllAndAwaitTermination will block until the downloads complete or get interrupted the Future list only contains task that have been scheduled in the threadpool. The status of those futures are either done or cancelled Future enhancements:
    • this implementation should be replaced with a NIO async download in order to reduce the number of threads needed
    Since:

    3.0