Package ubic.gemma.core.util
Class SimpleDownloader
- java.lang.Object
-
- ubic.gemma.core.util.SimpleDownloader
-
public class SimpleDownloader extends Object
A simple downloader for FTP and HTTP(s) URLs.- Author:
- poirigui
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleDownloader.URLAndDestination
-
Constructor Summary
Constructors Constructor Description SimpleDownloader(SimpleRetryPolicy retryPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
download(URL url, Path dest, boolean force)
Download a file from a URL to a local destination.Future<Long>
downloadAsync(URL url, Path dest, boolean force)
Download a file from a URL to a local destination asynchronously.long
downloadInParallel(List<SimpleDownloader.URLAndDestination> urls2dest, boolean force)
Download a file from a URL to a local destination asynchronously.void
setCheckArchiveIntegrity(boolean checkArchiveIntegrity)
Set whether to check the integrity of gzipped files after downloading.void
setFileLockManager(FileLockManager fileLockManager)
void
setFtpClientFactory(FTPClientFactory ftpClientFactory)
Set the factory for creating FTP clients.void
setTaskExecutor(ExecutorService taskExecutor)
Set the task executor for performing asynchronous downloads.
-
-
-
Constructor Detail
-
SimpleDownloader
public SimpleDownloader(@Nullable SimpleRetryPolicy retryPolicy)
- Parameters:
retryPolicy
- policy for retrying failed downloads, ornull
to only attempt downloads once
-
-
Method Detail
-
setFtpClientFactory
public void setFtpClientFactory(@Nullable FTPClientFactory ftpClientFactory)
Set the factory for creating FTP clients.
-
setTaskExecutor
public void setTaskExecutor(@Nullable ExecutorService taskExecutor)
Set the task executor for performing asynchronous downloads.
-
setFileLockManager
public void setFileLockManager(@Nullable FileLockManager fileLockManager)
-
setCheckArchiveIntegrity
public void setCheckArchiveIntegrity(boolean checkArchiveIntegrity)
Set whether to check the integrity of gzipped files after downloading.
-
downloadInParallel
public long downloadInParallel(List<SimpleDownloader.URLAndDestination> urls2dest, boolean force) throws IOException, InterruptedException
Download a file from a URL to a local destination asynchronously.- Throws:
IOException
InterruptedException
-
downloadAsync
public Future<Long> downloadAsync(URL url, Path dest, boolean force)
Download a file from a URL to a local destination asynchronously.
-
download
public long download(URL url, Path dest, boolean force) throws IOException
Download a file from a URL to a local destination.- Parameters:
url
- URL to downloaddest
- destination for the downloadforce
- download even if the file exists, has the same size and is up to date- Returns:
- the number of bytes that were downloaded
- Throws:
IOException
-
-