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
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:// 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);
- this implementation should be replaced with a NIO async download in order to reduce the number of threads needed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
ResourcesDownloader.AsynSamplerResultHolder
Holder of AsynSampler result
-
Method Summary
Modifier and Type Method Description static ResourcesDownloader
getInstance()
void
shrink()
this method will try to shrink the thread pool size as much as possible it should be called at the end of a test List<Future<ResourcesDownloader.AsynSamplerResultHolder>>
invokeAllAndAwaitTermination(int maxConcurrentDownloads, List<Callable<ResourcesDownloader.AsynSamplerResultHolder>> list)
This method will block until the downloads complete or it get interrupted the Future list returned by this method only contains tasks that have been scheduled in the threadpool. -
-
Method Detail
-
getInstance
static ResourcesDownloader getInstance()
-
shrink
void shrink()
this method will try to shrink the thread pool size as much as possible it should be called at the end of a test
-
invokeAllAndAwaitTermination
List<Future<ResourcesDownloader.AsynSamplerResultHolder>> invokeAllAndAwaitTermination(int maxConcurrentDownloads, List<Callable<ResourcesDownloader.AsynSamplerResultHolder>> list)
This method will block until the downloads complete or it get interrupted the Future list returned by this method only contains tasks that have been scheduled in the threadpool. The status of those futures are either done or cancelled
- Parameters:
maxConcurrentDownloads
- max concurrent downloadslist
- list of resources to download
-
-
-
-