@InterfaceAudience.Private @InterfaceStability.Unstable public class WriteOperationHelper extends Object
It hides direct access to the S3 API and is a location where the object operations can be evolved/enhanced.
Features
Modifier | Constructor and Description |
---|---|
protected |
WriteOperationHelper(S3AFileSystem owner,
org.apache.hadoop.conf.Configuration conf)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
abortMultipartCommit(String destKey,
String uploadId)
Abort a multipart commit operation.
|
void |
abortMultipartUpload(com.amazonaws.services.s3.model.MultipartUpload upload)
Abort a multipart commit operation.
|
void |
abortMultipartUpload(String destKey,
String uploadId,
Invoker.Retried retrying)
Abort a multipart upload operation.
|
int |
abortMultipartUploadsUnderPath(String prefix)
Abort multipart uploads under a path: limited to the first
few hundred.
|
com.amazonaws.services.s3.model.CompleteMultipartUploadResult |
commitUpload(String destKey,
String uploadId,
List<com.amazonaws.services.s3.model.PartETag> partETags,
long length,
BulkOperationState operationState)
This completes a multipart upload to the destination key via
finalizeMultipartUpload() . |
com.amazonaws.services.s3.model.CompleteMultipartUploadResult |
completeMPUwithRetries(String destKey,
String uploadId,
List<com.amazonaws.services.s3.model.PartETag> partETags,
long length,
AtomicInteger errorCount)
This completes a multipart upload to the destination key via
finalizeMultipartUpload() . |
com.amazonaws.services.s3.model.PutObjectRequest |
createPutObjectRequest(String dest,
File sourceFile)
Create a
PutObjectRequest request to upload a file. |
com.amazonaws.services.s3.model.PutObjectRequest |
createPutObjectRequest(String destKey,
InputStream inputStream,
long length)
Create a
PutObjectRequest request against the specific key. |
org.apache.hadoop.conf.Configuration |
getConf()
Get the configuration of this instance; essentially the owning
filesystem configuration.
|
BulkOperationState |
initiateCommitOperation(org.apache.hadoop.fs.Path path)
Initiate a commit operation through any metastore.
|
String |
initiateMultiPartUpload(String destKey)
Start the multipart upload process.
|
com.amazonaws.services.s3.model.ObjectMetadata |
newObjectMetadata(long length)
Create a new object metadata instance.
|
com.amazonaws.services.s3.model.SelectObjectContentRequest |
newSelectRequest(org.apache.hadoop.fs.Path path)
Create a S3 Select request for the destination path.
|
com.amazonaws.services.s3.model.UploadPartRequest |
newUploadPartRequest(String destKey,
String uploadId,
int partNumber,
int size,
InputStream uploadStream,
File sourceFile,
Long offset)
Create and initialize a part request of a multipart upload.
|
com.amazonaws.services.s3.model.PutObjectResult |
putObject(com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest)
PUT an object directly (i.e.
|
<T> T |
retry(String action,
String path,
boolean idempotent,
Invoker.Operation<T> operation)
Execute a function with retry processing.
|
void |
revertCommit(String destKey,
BulkOperationState operationState)
Revert a commit by deleting the file.
|
com.amazonaws.services.s3.model.SelectObjectContentResult |
select(org.apache.hadoop.fs.Path source,
com.amazonaws.services.s3.model.SelectObjectContentRequest request,
String action)
Execute an S3 Select operation.
|
String |
toString()
The toString method is intended to be used in logging/toString calls.
|
com.amazonaws.services.s3.transfer.model.UploadResult |
uploadObject(com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest)
PUT an object via the transfer manager.
|
com.amazonaws.services.s3.model.UploadPartResult |
uploadPart(com.amazonaws.services.s3.model.UploadPartRequest request)
Upload part of a multi-partition file.
|
void |
writeFailed(Exception ex)
Callback on a write failure.
|
void |
writeSuccessful(long length)
Callback on a successful write.
|
protected WriteOperationHelper(S3AFileSystem owner, org.apache.hadoop.conf.Configuration conf)
owner
- owner FS creating the helperconf
- Configuration objectpublic <T> T retry(String action, String path, boolean idempotent, Invoker.Operation<T> operation) throws IOException
T
- type of return valueaction
- action to execute (used in error messages)path
- path of work (used in error messages)idempotent
- does the operation have semantics
which mean that it can be retried even if was already executed?operation
- operation to executeIOException
- any IOE raised, or translated exceptionpublic com.amazonaws.services.s3.model.PutObjectRequest createPutObjectRequest(String destKey, InputStream inputStream, long length)
PutObjectRequest
request against the specific key.destKey
- destination keyinputStream
- source data.length
- size, if known. Use -1 for not knownpublic com.amazonaws.services.s3.model.PutObjectRequest createPutObjectRequest(String dest, File sourceFile)
PutObjectRequest
request to upload a file.dest
- key to PUT to.sourceFile
- source filepublic void writeSuccessful(long length)
length
- length of the writepublic void writeFailed(Exception ex)
ex
- Any exception raised which triggered the failure.public com.amazonaws.services.s3.model.ObjectMetadata newObjectMetadata(long length)
length
- size, if known. Use -1 for not known@Retries.RetryTranslated public String initiateMultiPartUpload(String destKey) throws IOException
destKey
- destination of uploadIOException
- IO problem@Retries.RetryTranslated public com.amazonaws.services.s3.model.CompleteMultipartUploadResult completeMPUwithRetries(String destKey, String uploadId, List<com.amazonaws.services.s3.model.PartETag> partETags, long length, AtomicInteger errorCount) throws IOException
finalizeMultipartUpload()
.
Retry policy: retrying, translated.
Retries increment the errorCount
counter.destKey
- destinationuploadId
- multipart operation IdpartETags
- list of partial uploadslength
- length of the uploaderrorCount
- a counter incremented by 1 on every error; for
use in statisticsIOException
- if problems arose which could not be retried, or
the retry count was exceeded@Retries.RetryTranslated public void abortMultipartUpload(String destKey, String uploadId, Invoker.Retried retrying) throws IOException
destKey
- destination key of the uploaduploadId
- multipart operation Idretrying
- callback invoked on every retryIOException
- failure to abortFileNotFoundException
- if the abort ID is unknown@Retries.RetryTranslated public void abortMultipartUpload(com.amazonaws.services.s3.model.MultipartUpload upload) throws IOException
upload
- upload to abort.IOException
- on problems.@Retries.RetryTranslated public int abortMultipartUploadsUnderPath(String prefix) throws IOException
prefix
- prefix for uploads to abortIOException
- trouble; FileNotFoundExceptions are swallowed.@Retries.RetryTranslated public void abortMultipartCommit(String destKey, String uploadId) throws IOException
destKey
- destination key of ongoing operationuploadId
- multipart operation IdIOException
- on problems.FileNotFoundException
- if the abort ID is unknownpublic com.amazonaws.services.s3.model.UploadPartRequest newUploadPartRequest(String destKey, String uploadId, int partNumber, int size, InputStream uploadStream, File sourceFile, Long offset)
uploadStream
or sourceFile
must be specified.
A subset of the file may be posted, by providing the starting point
in offset
and a length of block in size
equal to
or less than the remaining bytes.destKey
- destination key of ongoing operationuploadId
- ID of ongoing uploadpartNumber
- current part number of the uploadsize
- amount of datauploadStream
- source of data to uploadsourceFile
- optional source file.offset
- offset in file to start reading.public String toString()
@Retries.RetryTranslated public com.amazonaws.services.s3.model.PutObjectResult putObject(com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest) throws IOException
putObjectRequest
- the requestIOException
- on problems@Retries.RetryTranslated public com.amazonaws.services.s3.transfer.model.UploadResult uploadObject(com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest) throws IOException
putObjectRequest
- the requestIOException
- on problems@Retries.OnceTranslated public void revertCommit(String destKey, @Nullable BulkOperationState operationState) throws IOException
destKey
- destination keyoperationState
- operational state for a bulk updateIOException
- on problems@Retries.RetryTranslated public com.amazonaws.services.s3.model.CompleteMultipartUploadResult commitUpload(String destKey, String uploadId, List<com.amazonaws.services.s3.model.PartETag> partETags, long length, @Nullable BulkOperationState operationState) throws IOException
finalizeMultipartUpload()
.
Retry policy: retrying, translated.
Retries increment the errorCount
counter.destKey
- destinationuploadId
- multipart operation IdpartETags
- list of partial uploadslength
- length of the uploadoperationState
- operational state for a bulk updateIOException
- if problems arose which could not be retried, or
the retry count was exceededpublic BulkOperationState initiateCommitOperation(org.apache.hadoop.fs.Path path) throws IOException
path
- path under which the writes will all take place.IOException
- failure to instantiate.@Retries.RetryTranslated public com.amazonaws.services.s3.model.UploadPartResult uploadPart(com.amazonaws.services.s3.model.UploadPartRequest request) throws IOException
request
- requestIOException
- on problemspublic org.apache.hadoop.conf.Configuration getConf()
public com.amazonaws.services.s3.model.SelectObjectContentRequest newSelectRequest(org.apache.hadoop.fs.Path path)
path
- pre-qualified path for query@Retries.RetryTranslated public com.amazonaws.services.s3.model.SelectObjectContentResult select(org.apache.hadoop.fs.Path source, com.amazonaws.services.s3.model.SelectObjectContentRequest request, String action) throws IOException
source
- source for selectionrequest
- Select request to issue.action
- the action for use in exception creationIOException
- failureCopyright © 2008–2020 Apache Software Foundation. All rights reserved.