Package com.amazonaws.services.s3
Class UploadObjectObserver
java.lang.Object
com.amazonaws.services.s3.UploadObjectObserver
An observer that gets notified of ciphertext file creation for the purpose of
pipelined parallel multi-part uploads of encrypted data to S3. This observer
is responsible for uploading the files to S3 via multi-part upload, including
the multi-part upload initiation, individual part uploads, and multi-part
upload completion.
This observer is designed for extension so that custom behavior can be
provided. A customer observer can be configured via
UploadObjectRequest.withUploadObjectObserver(UploadObjectObserver)
.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <X extends AmazonWebServiceRequest>
XappendUserAgent
(X request, String userAgent) Appends the given user agent to the given request.protected AmazonS3
Returns theAmazonS3
instance initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected ExecutorService
Returns theExecutorService
instance initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected UploadObjectRequest
Returns the request initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected com.amazonaws.services.s3.internal.S3DirectSpi
Returns theS3DirectSpi
instance initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected String
Returns the upload id after the multi-part upload has been initiated viaonUploadInitiation(UploadObjectRequest)
init
(UploadObjectRequest req, com.amazonaws.services.s3.internal.S3DirectSpi s3direct, AmazonS3 s3, ExecutorService es) Used to initialized this observer.protected InitiateMultipartUploadRequest
protected UploadPartRequest
newUploadPartRequest
(com.amazonaws.services.s3.internal.PartCreationEvent event, File part) Creates and returns an upload-part request corresponding to a ciphertext file upon a part-creation event.void
onAbort()
Notified fromAmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
when failed to upload any part.onCompletion
(List<PartETag> partETags) Notified fromAmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
when all parts have been successfully uploaded to S3.void
onPartCreate
(com.amazonaws.services.s3.internal.PartCreationEvent event) Notified fromMultiFileOutputStream.fos()
when a part ready for upload has been successfully created on disk.Notified fromAmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
to initiate a multi-part upload.protected UploadPartResult
uploadPart
(UploadPartRequest reqUploadPart) Uploads the ciphertext via the non-encrypting s3 client.
-
Constructor Details
-
UploadObjectObserver
public UploadObjectObserver()
-
-
Method Details
-
init
public UploadObjectObserver init(UploadObjectRequest req, com.amazonaws.services.s3.internal.S3DirectSpi s3direct, AmazonS3 s3, ExecutorService es) Used to initialized this observer. This method is an SPI (service provider interface) that is called fromAmazonS3EncryptionClient
.Implementation of this method should never block.
- Parameters:
req
- the upload object requests3direct
- used to perform non-encrypting s3 operation via the current instance of s3 (encryption) clients3
- the current instance of s3 (encryption) clientes
- the executor service to be used for concurrent uploads- Returns:
- this object
-
newInitiateMultipartUploadRequest
-
onUploadInitiation
Notified fromAmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
to initiate a multi-part upload.- Parameters:
req
- the upload object request- Returns:
- the initiated multi-part uploadId
-
onPartCreate
public void onPartCreate(com.amazonaws.services.s3.internal.PartCreationEvent event) Notified fromMultiFileOutputStream.fos()
when a part ready for upload has been successfully created on disk. By default, this method performs the following:- calls
newUploadPartRequest(PartCreationEvent, File)
to create an upload-part request for the newly created ciphertext file - call
appendUserAgent(AmazonWebServiceRequest, String)
to append the necessary user agent string to the request - and finally submit a concurrent task, which calls the method
uploadPart(UploadPartRequest)
, to be performed
To enable parallel uploads, implementation of this method should never block.
- Parameters:
event
- to represent the completion of a ciphertext file creation which is ready for multipart upload to S3.
- calls
-
onCompletion
Notified fromAmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
when all parts have been successfully uploaded to S3. This method is responsible for finishing off the upload by making a complete multi-part upload request to S3 with the given list of etags.- Parameters:
partETags
- all the etags returned from S3 for the previous part uploads.- Returns:
- the completed multi-part upload result
-
onAbort
public void onAbort()Notified fromAmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
when failed to upload any part. This method is responsible for cancelling ongoing uploads and aborting the multi-part upload request. -
newUploadPartRequest
protected UploadPartRequest newUploadPartRequest(com.amazonaws.services.s3.internal.PartCreationEvent event, File part) Creates and returns an upload-part request corresponding to a ciphertext file upon a part-creation event.- Parameters:
event
- the part-creation event of the ciphertxt file.part
- the created ciphertext file corresponding to the upload-part
-
uploadPart
Uploads the ciphertext via the non-encrypting s3 client.- Parameters:
reqUploadPart
- part upload request- Returns:
- the result of the part upload when there is no exception
-
appendUserAgent
Appends the given user agent to the given request.- Returns:
- the given request.
-
getFutures
-
getRequest
Returns the request initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
-
getUploadId
Returns the upload id after the multi-part upload has been initiated viaonUploadInitiation(UploadObjectRequest)
-
getS3DirectSpi
protected com.amazonaws.services.s3.internal.S3DirectSpi getS3DirectSpi()Returns theS3DirectSpi
instance initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
-
getAmazonS3
Returns theAmazonS3
instance initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
-
getExecutorService
Returns theExecutorService
instance initialized viainit(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
-