final class DownloadCallable
extends java.lang.Object
implements java.util.concurrent.Callable<java.io.File>
Modifier and Type | Field and Description |
---|---|
private DownloadImpl |
download |
private java.io.File |
dstfile |
private java.util.concurrent.ScheduledExecutorService |
executor |
private long |
expectedFileLength |
private java.util.List<java.util.concurrent.Future<java.io.File>> |
futureFiles |
private boolean |
isDownloadParallel |
private java.lang.Integer |
lastFullyMergedPartNumber |
private java.util.concurrent.CountDownLatch |
latch |
private static org.apache.commons.logging.Log |
LOG |
private long |
origStartingByte |
private GetObjectRequest |
req |
private boolean |
resumeExistingDownload |
private AmazonS3 |
s3 |
private static boolean |
testing |
private long |
timeout |
Constructor and Description |
---|
DownloadCallable(AmazonS3 s3,
java.util.concurrent.CountDownLatch latch,
GetObjectRequest req,
boolean resumeExistingDownload,
DownloadImpl download,
java.io.File dstfile,
long origStartingByte,
long expectedFileLength,
long timeout,
java.util.concurrent.ScheduledExecutorService executor,
java.lang.Integer lastFullyDownloadedPartNumber,
boolean isDownloadParallel) |
Modifier and Type | Method and Description |
---|---|
private void |
adjustRequest(GetObjectRequest req)
This method is called only if it is a resumed download.
|
java.io.File |
call()
This method must return a non-null object, or else the existing
implementation in
AbstractTransfer.waitForCompletion()
would block forever. |
private void |
combineFiles()
Merges all the individual part Files into dstFile
|
private void |
downloadInParallel(int partCount)
Downloads each part of the object into a seperate file synchronously and
combines all the files into a single file.
|
private boolean |
isTimeoutEnabled() |
private S3Object |
retryableDownloadS3ObjectToFile(java.io.File file,
ServiceUtils.RetryableS3DownloadTask retryableS3DownloadTask,
boolean appendData) |
(package private) static void |
setTesting(boolean b)
Used for testing purpose only.
|
private void |
truncateDestinationFileIfNecessary()
If only partial part object is merged into the dstFile(due to pause
operation), adjust the file length so that the part starts writing from
the correct position.
|
private void |
updateDownloadStatus(S3Object result)
Takes the result from serial download,
updates the transfer state and monitor in downloadImpl object
based on the result.
|
private static final org.apache.commons.logging.Log LOG
private final AmazonS3 s3
private final java.util.concurrent.CountDownLatch latch
private final GetObjectRequest req
private final boolean resumeExistingDownload
private final DownloadImpl download
private final java.io.File dstfile
private final long origStartingByte
private final long timeout
private final java.util.concurrent.ScheduledExecutorService executor
private final java.util.List<java.util.concurrent.Future<java.io.File>> futureFiles
private final boolean isDownloadParallel
private java.lang.Integer lastFullyMergedPartNumber
private long expectedFileLength
private static boolean testing
DownloadCallable(AmazonS3 s3, java.util.concurrent.CountDownLatch latch, GetObjectRequest req, boolean resumeExistingDownload, DownloadImpl download, java.io.File dstfile, long origStartingByte, long expectedFileLength, long timeout, java.util.concurrent.ScheduledExecutorService executor, java.lang.Integer lastFullyDownloadedPartNumber, boolean isDownloadParallel)
public java.io.File call() throws java.lang.Exception
AbstractTransfer.waitForCompletion()
would block forever.call
in interface java.util.concurrent.Callable<java.io.File>
java.lang.Exception
private void updateDownloadStatus(S3Object result)
private void downloadInParallel(int partCount) throws java.lang.Exception
java.lang.Exception
private void combineFiles() throws java.lang.Exception
java.lang.Exception
private void truncateDestinationFileIfNecessary() throws java.io.IOException
java.io.IOException
private void adjustRequest(GetObjectRequest req)
private S3Object retryableDownloadS3ObjectToFile(java.io.File file, ServiceUtils.RetryableS3DownloadTask retryableS3DownloadTask, boolean appendData)
private boolean isTimeoutEnabled()
static void setTesting(boolean b)