public class DownloadManager extends Object
Download manager, which automatically breaks a larger download into parallel downloads, based on object size. It also handles possible retries.
The retries in the download manager are smarter than the retries built into the client: The download manager modifies the request to only retry the parts that haven't been read yet. The client would retry the entire request, and re-download parts that have already been downloaded.
Since these retries have been implemented independent of the regular client retries, client
retries set using RetryConfiguration
are ignored.
Constructor and Description |
---|
DownloadManager(ObjectStorage objectStorage,
DownloadConfiguration config) |
Modifier and Type | Method and Description |
---|---|
GetObjectResponse |
downloadObjectToFile(GetObjectRequest request,
File target)
Download the object and save it to a file.
|
GetObjectResponse |
getObject_singleThreaded(GetObjectRequest request)
Used by
MultithreadStream . |
GetObjectResponse |
getObject(GetObjectRequest request)
This calls acts just like
ObjectStorage.getObject(GetObjectRequest) except that the
InputStream returned GetObjectResponse.getInputStream() will automatically
retry the get operation if there is failure. |
@ConstructorProperties(value={"objectStorage","config"}) public DownloadManager(ObjectStorage objectStorage, DownloadConfiguration config)
public GetObjectResponse getObject(GetObjectRequest request)
This calls acts just like ObjectStorage.getObject(GetObjectRequest)
except that the
InputStream
returned GetObjectResponse.getInputStream()
will automatically
retry the get operation if there is failure.
These retries introduce a new set of possible failures. If the object is modified during a get operation a retry can fail with a 412 or 404 status code.
request
- The request object containing the details to sendBmcException
- when an error occurs.public GetObjectResponse downloadObjectToFile(GetObjectRequest request, File target) throws IOException
Download the object and save it to a file.
This calls acts just like ObjectStorage.getObject(GetObjectRequest)
except that
the InputStream
returned GetObjectResponse.getInputStream()
will
automatically retry the get operation if there is failure.
These retries introduce a new set of possible failures. If the object is modified during a get operation a retry can fail with a 412 or 404 status code.
The downloaded object will be saved in the specified file.
The response will be returned, but note that the stream has already been consumed.
request
- The request object containing the details to sendtarget
- The file where the object should be savedBmcException
- when an error occurs.IOException
public GetObjectResponse getObject_singleThreaded(GetObjectRequest request)
Used by MultithreadStream
. This does NOT multithread the download.
Copyright © 2016–2024. All rights reserved.