public class UploadObjectObserver extends Object
This observer is designed for extension so that custom behavior can be
provided. A customer observer can be configured via
UploadObjectRequest.withUploadObjectObserver(UploadObjectObserver)
.
UploadObjectRequest
Constructor and Description |
---|
UploadObjectObserver() |
Modifier and Type | Method and Description |
---|---|
protected <X extends AmazonWebServiceRequest> |
appendUserAgent(X request,
String userAgent)
Appends the given user agent to the given request.
|
protected AmazonS3 |
getAmazonS3()
Returns the
AmazonS3 instance initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService) |
protected ExecutorService |
getExecutorService()
Returns the
ExecutorService instance initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService) |
List<Future<UploadPartResult>> |
getFutures() |
protected UploadObjectRequest |
getRequest()
Returns the request initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService) |
protected S3DirectSpi |
getS3DirectSpi()
Returns the
S3DirectSpi instance initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService) |
protected String |
getUploadId()
Returns the upload id after the multi-part upload has been initiated via
UploadObjectObserver.onUploadInitiation(UploadObjectRequest) |
UploadObjectObserver |
init(UploadObjectRequest req,
S3DirectSpi s3direct,
AmazonS3 s3,
ExecutorService es)
Used to initialized this observer.
|
protected InitiateMultipartUploadRequest |
newInitiateMultipartUploadRequest(UploadObjectRequest req) |
protected UploadPartRequest |
newUploadPartRequest(PartCreationEvent event,
File part)
Creates and returns an upload-part request corresponding to a ciphertext
file upon a part-creation event.
|
void |
onAbort()
Notified from
AmazonS3EncryptionClient.uploadObject(UploadObjectRequest) when
failed to upload any part. |
CompleteMultipartUploadResult |
onCompletion(List<PartETag> partETags)
Notified from
AmazonS3EncryptionClient.uploadObject(UploadObjectRequest) when
all parts have been successfully uploaded to S3. |
void |
onPartCreate(PartCreationEvent event)
Notified from
MultiFileOutputStream.fos() when a part ready for
upload has been successfully created on disk. |
String |
onUploadInitiation(UploadObjectRequest req)
Notified from
AmazonS3EncryptionClient.uploadObject(UploadObjectRequest) to
initiate a multi-part upload. |
protected UploadPartResult |
uploadPart(UploadPartRequest reqUploadPart)
Uploads the ciphertext via the non-encrypting s3 client.
|
public UploadObjectObserver init(UploadObjectRequest req, S3DirectSpi s3direct, AmazonS3 s3, ExecutorService es)
AmazonS3EncryptionClient
.
Implementation of this method should never block.
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 uploadsprotected InitiateMultipartUploadRequest newInitiateMultipartUploadRequest(UploadObjectRequest req)
public String onUploadInitiation(UploadObjectRequest req)
AmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
to
initiate a multi-part upload.req
- the upload object requestpublic void onPartCreate(PartCreationEvent event)
MultiFileOutputStream.fos()
when a part ready for
upload has been successfully created on disk. By default, this method
performs the following:
UploadObjectObserver.newUploadPartRequest(PartCreationEvent, File)
to
create an upload-part request for the newly created ciphertext fileUploadObjectObserver.appendUserAgent(AmazonWebServiceRequest, String)
to
append the necessary user agent string to the requestUploadObjectObserver.uploadPart(UploadPartRequest)
, to be performedTo enable parallel uploads, implementation of this method should never block.
event
- to represent the completion of a ciphertext file creation
which is ready for multipart upload to S3.public CompleteMultipartUploadResult onCompletion(List<PartETag> partETags)
AmazonS3EncryptionClient.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.partETags
- all the etags returned from S3 for the previous part uploads.public void onAbort()
AmazonS3EncryptionClient.uploadObject(UploadObjectRequest)
when
failed to upload any part. This method is responsible for cancelling
ongoing uploads and aborting the multi-part upload request.protected UploadPartRequest newUploadPartRequest(PartCreationEvent event, File part)
event
- the part-creation event of the ciphertxt file.part
- the created ciphertext file corresponding to the upload-partprotected UploadPartResult uploadPart(UploadPartRequest reqUploadPart)
reqUploadPart
- part upload requestprotected <X extends AmazonWebServiceRequest> X appendUserAgent(X request, String userAgent)
public List<Future<UploadPartResult>> getFutures()
protected UploadObjectRequest getRequest()
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected String getUploadId()
UploadObjectObserver.onUploadInitiation(UploadObjectRequest)
protected S3DirectSpi getS3DirectSpi()
S3DirectSpi
instance initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected AmazonS3 getAmazonS3()
AmazonS3
instance initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
protected ExecutorService getExecutorService()
ExecutorService
instance initialized via
UploadObjectObserver.init(UploadObjectRequest, S3DirectSpi, AmazonS3, ExecutorService)
Copyright © 2024. All rights reserved.