public class S3AStoreImpl extends org.apache.hadoop.service.CompositeService implements S3AStore, ObjectInputStreamFactory
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookObjectInputStreamFactory.StreamFactoryCallbacks| Modifier and Type | Method and Description |
|---|---|
Duration |
acquireReadCapacity(int capacity)
Acquire read capacity for rate limiting Acquire read capacity for operations..
|
Duration |
acquireWriteCapacity(int capacity)
Acquire write capacity for rate limiting Acquire write capacity for operations..
|
void |
bind(FactoryBindingParameters factoryBindingParameters)
This operation is not implemented, as
is this class which invokes it on the actual factory.
|
ClientManager |
clientManager()
Get the client manager.
|
software.amazon.awssdk.services.s3.model.CompleteMultipartUploadResponse |
completeMultipartUpload(software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest request)
Complete a multipart upload.
|
AuditSpanS3A |
createSpan(String operation,
String path1,
String path2)
Start an operation; this informs the audit service of the event
and then sets it as the active span.
|
File |
createTemporaryFileForWriting(String pathStr,
long size,
org.apache.hadoop.conf.Configuration conf)
Demand create the directory allocator, then create a temporary file.
|
protected void |
decrementGauge(Statistic statistic,
long count)
Decrement a gauge by a specific value.
|
Map.Entry<Duration,Optional<software.amazon.awssdk.services.s3.model.DeleteObjectResponse>> |
deleteObject(software.amazon.awssdk.services.s3.model.DeleteObjectRequest request)
Delete an object.
|
Map.Entry<Duration,software.amazon.awssdk.services.s3.model.DeleteObjectsResponse> |
deleteObjects(software.amazon.awssdk.services.s3.model.DeleteObjectsRequest deleteRequest)
Perform a bulk object delete operation against S3.
|
StreamFactoryRequirements |
factoryRequirements()
Get requirements from the factory which then tune behavior
elsewhere in the system.
|
org.apache.hadoop.fs.LocalDirAllocator |
getDirectoryAllocator()
Get the directory allocator.
|
org.apache.hadoop.fs.statistics.DurationTrackerFactory |
getDurationTrackerFactory() |
org.apache.hadoop.fs.statistics.IOStatistics |
getIOStatistics()
Get the instrumentation's IOStatistics.
|
software.amazon.awssdk.services.s3.S3AsyncClient |
getOrCreateAsyncClient()
Get the Async S3Client,raising a failure to create as an IOException.
|
software.amazon.awssdk.services.s3.S3Client |
getOrCreateAsyncS3ClientUnchecked()
Get the AsyncS3Client, raising a failure to create as an UncheckedIOException.
|
software.amazon.awssdk.services.s3.S3Client |
getOrCreateS3Client()
Get the S3Client, raising a failure to create as an IOException.
|
software.amazon.awssdk.services.s3.S3Client |
getOrCreateS3ClientUnchecked()
Get the S3Client, raising a failure to create as an UncheckedIOException.
|
software.amazon.awssdk.transfer.s3.S3TransferManager |
getOrCreateTransferManager()
Get the transfer manager, creating it and any dependencies if needed.
|
software.amazon.awssdk.services.s3.S3Client |
getOrCreateUnencryptedS3Client()
Get or create an unencrypted S3 client.
|
software.amazon.awssdk.core.ResponseInputStream<software.amazon.awssdk.services.s3.model.GetObjectResponse> |
getRangedS3Object(String key,
long start,
long end)
Retrieves a specific byte range of an S3 object as a stream.
|
RequestFactory |
getRequestFactory() |
S3AStatisticsContext |
getStatisticsContext() |
StoreContext |
getStoreContext() |
boolean |
hasPathCapability(org.apache.hadoop.fs.Path path,
String capability)
Return the store path capabilities.
|
software.amazon.awssdk.services.s3.model.HeadObjectResponse |
headObject(String key,
ChangeTracker changeTracker,
Invoker changeInvoker,
S3AFileSystemOperations fsHandler,
String operation)
Performs a HEAD request on an S3 object to retrieve its metadata.
|
protected void |
incrementGauge(Statistic statistic,
long count)
Increment a gauge by a specific value.
|
void |
incrementPutCompletedStatistics(boolean success,
long bytes)
At the end of a put/multipart upload operation, update the
relevant counters and gauges.
|
void |
incrementPutProgressStatistics(String key,
long bytes)
Callback for use in progress callbacks from put/multipart upload events.
|
void |
incrementPutStartStatistics(long bytes)
At the start of a put/multipart upload operation, update the
relevant counters.
|
void |
incrementReadOperations()
Increment read operations.
|
protected void |
incrementStatistic(Statistic statistic)
Increment a statistic by 1.
|
protected void |
incrementStatistic(Statistic statistic,
long count)
Increment a statistic by a specific value.
|
void |
incrementWriteOperations()
Increment the write operation counter.
|
boolean |
inputStreamHasCapability(String capability)
Return the capabilities of input streams created
through the store.
|
org.apache.hadoop.fs.statistics.DurationTrackerFactory |
nonNullDurationTrackerFactory(org.apache.hadoop.fs.statistics.DurationTrackerFactory factory)
Given a possibly null duration tracker factory, return a non-null
one for use in tracking durations -either that or the FS tracker
itself.
|
void |
operationRetried(Exception ex)
Callback when an operation was retried.
|
void |
operationRetried(String text,
Exception ex,
int retries,
boolean idempotent)
Callback from
Invoker when an operation is retried. |
UploadInfo |
putObject(software.amazon.awssdk.services.s3.model.PutObjectRequest putObjectRequest,
File file,
ProgressableProgressListener listener)
Start a transfer-manager managed async PUT of an object,
incrementing the put requests and put bytes
counters.
|
ObjectInputStream |
readObject(ObjectReadParameters parameters)
Create a new input stream.
|
protected void |
serviceInit(org.apache.hadoop.conf.Configuration conf)
Create and initialize any subsidiary services, including the input stream factory.
|
protected void |
serviceStart() |
InputStreamType |
streamType()
Get the input stream type.
|
software.amazon.awssdk.services.s3.model.UploadPartResponse |
uploadPart(software.amazon.awssdk.services.s3.model.UploadPartRequest request,
software.amazon.awssdk.core.sync.RequestBody body,
org.apache.hadoop.fs.statistics.DurationTrackerFactory trackerFactory)
Upload part of a multi-partition file.
|
software.amazon.awssdk.transfer.s3.model.CompletedFileUpload |
waitForUploadCompletion(String key,
UploadInfo uploadInfo)
Wait for an upload to complete.
|
addIfService, addService, getServices, removeService, serviceStopclose, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStopclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasCapabilityprotected void serviceInit(org.apache.hadoop.conf.Configuration conf)
throws Exception
serviceInit in class org.apache.hadoop.service.CompositeServiceconf - configurationExceptionprotected void serviceStart()
throws Exception
serviceStart in class org.apache.hadoop.service.CompositeServiceExceptionpublic boolean hasPathCapability(org.apache.hadoop.fs.Path path,
String capability)
hasPathCapability in interface org.apache.hadoop.fs.PathCapabilitiespath - path to query the capability of.capability - non-null, non-empty string to query the path for support.public boolean inputStreamHasCapability(String capability)
inputStreamHasCapability in interface S3AStorecapability - string to query the stream support for.public Duration acquireWriteCapacity(int capacity)
acquireWriteCapacity in interface S3AStorecapacity - capacity to acquire.public Duration acquireReadCapacity(int capacity)
acquireReadCapacity in interface S3AStorecapacity - capacity to acquire.public StoreContext getStoreContext()
getStoreContext in interface S3AStorepublic software.amazon.awssdk.transfer.s3.S3TransferManager getOrCreateTransferManager()
throws IOException
ClientManagergetOrCreateTransferManager in interface ClientManagerIOException - on any failure to create the managerpublic software.amazon.awssdk.services.s3.S3Client getOrCreateS3Client()
throws IOException
ClientManagergetOrCreateS3Client in interface ClientManagerIOException - failure to create the client.public software.amazon.awssdk.services.s3.S3AsyncClient getOrCreateAsyncClient()
throws IOException
ClientManagergetOrCreateAsyncClient in interface ClientManagerIOException - failure to create the client.public software.amazon.awssdk.services.s3.S3Client getOrCreateS3ClientUnchecked()
throws UncheckedIOException
ClientManagergetOrCreateS3ClientUnchecked in interface ClientManagerUncheckedIOException - failure to create the client.public software.amazon.awssdk.services.s3.S3Client getOrCreateAsyncS3ClientUnchecked()
throws UncheckedIOException
ClientManagergetOrCreateAsyncS3ClientUnchecked in interface ClientManagerUncheckedIOException - failure to create the client.public software.amazon.awssdk.services.s3.S3Client getOrCreateUnencryptedS3Client()
throws IOException
ClientManagergetOrCreateUnencryptedS3Client in interface ClientManagerIOException - on any failurepublic org.apache.hadoop.fs.statistics.DurationTrackerFactory getDurationTrackerFactory()
getDurationTrackerFactory in interface S3AStorepublic S3AStatisticsContext getStatisticsContext()
getStatisticsContext in interface S3AStorepublic RequestFactory getRequestFactory()
getRequestFactory in interface S3AStorepublic ClientManager clientManager()
clientManager in interface S3AStoreprotected void incrementStatistic(Statistic statistic)
statistic - The operation to incrementprotected void incrementStatistic(Statistic statistic, long count)
statistic - The operation to incrementcount - the count to incrementprotected void decrementGauge(Statistic statistic, long count)
statistic - The operation to decrementcount - the count to decrementprotected void incrementGauge(Statistic statistic, long count)
statistic - The operation to incrementcount - the count to incrementpublic void operationRetried(Exception ex)
ex - exception.public void operationRetried(String text, Exception ex, int retries, boolean idempotent)
Invoker when an operation is retried.text - text of the operationex - exceptionretries - number of retriesidempotent - is the method idempotentpublic org.apache.hadoop.fs.statistics.IOStatistics getIOStatistics()
getIOStatistics in interface org.apache.hadoop.fs.statistics.IOStatisticsSourcepublic void incrementReadOperations()
incrementReadOperations in interface S3AStorepublic void incrementWriteOperations()
incrementWriteOperations in interface S3AStorepublic void incrementPutStartStatistics(long bytes)
incrementPutStartStatistics in interface S3AStorebytes - bytes in the request.public void incrementPutCompletedStatistics(boolean success,
long bytes)
incrementPutCompletedStatistics in interface S3AStoresuccess - did the operation succeed?bytes - bytes in the request.public void incrementPutProgressStatistics(String key, long bytes)
incrementPutProgressStatistics in interface S3AStorekey - key to file that is being written (for logging)bytes - bytes successfully uploaded.public org.apache.hadoop.fs.statistics.DurationTrackerFactory nonNullDurationTrackerFactory(org.apache.hadoop.fs.statistics.DurationTrackerFactory factory)
nonNullDurationTrackerFactory in interface S3AStorefactory - factory.public AuditSpanS3A createSpan(String operation, @Nullable String path1, @Nullable String path2) throws IOException
operation - operation name.path1 - first path of operationpath2 - second path of operationIOException - failure@Retries.RetryRaw public Map.Entry<Duration,software.amazon.awssdk.services.s3.model.DeleteObjectsResponse> deleteObjects(software.amazon.awssdk.services.s3.model.DeleteObjectsRequest deleteRequest) throws software.amazon.awssdk.core.exception.SdkException
OBJECT_DELETE_REQUESTS and write
operation statistics
OBJECT_DELETE_OBJECTS is updated with the actual number
of objects deleted in the request.
Retry policy: retry untranslated; delete considered idempotent.
If the request is throttled, this is logged in the throttle statistics,
with the counter set to the number of keys, rather than the number
of invocations of the delete operation.
This is because S3 considers each key as one mutating operation on
the store when updating its load counters on a specific partition
of an S3 bucket.
If only the request was measured, this operation would under-report.
A write capacity will be requested proportional to the number of keys
preset in the request and will be re-requested during retries such that
retries throttle better. If the request is throttled, the time spent is
recorded in a duration IOStat named STORE_IO_RATE_LIMITED_DURATION..
deleteObjects in interface S3AStoredeleteRequest - keys to delete on the s3-backendMultiObjectDeleteException - one or more of the keys could not
be deleted.software.amazon.awssdk.core.exception.SdkException - amazon-layer failure.@Retries.RetryRaw public software.amazon.awssdk.services.s3.model.HeadObjectResponse headObject(String key, ChangeTracker changeTracker, Invoker changeInvoker, S3AFileSystemOperations fsHandler, String operation) throws IOException
headObject in interface S3AStorekey - The S3 object key to perform the HEAD operation onchangeTracker - Tracks changes to the object's metadata across operationschangeInvoker - The invoker responsible for executing the HEAD request with retriesfsHandler - Handler for filesystem-level operations and configurationsoperation - Description of the operation being performed for tracking purposesIOException - If the HEAD request fails, object doesn't exist, or other I/O errors occur@Retries.RetryRaw public software.amazon.awssdk.core.ResponseInputStream<software.amazon.awssdk.services.s3.model.GetObjectResponse> getRangedS3Object(String key, long start, long end) throws IOException
getRangedS3Object in interface S3AStorekey - The S3 object key to retrievestart - The starting byte position (inclusive) of the range to retrieveend - The ending byte position (inclusive) of the range to retrieveIOException - If the object cannot be retrieved other I/O errors occurFor additional metadata about the retrieved object@Retries.RetryRaw public Map.Entry<Duration,Optional<software.amazon.awssdk.services.s3.model.DeleteObjectResponse>> deleteObject(software.amazon.awssdk.services.s3.model.DeleteObjectRequest request) throws software.amazon.awssdk.core.exception.SdkException
OBJECT_DELETE_REQUESTS statistics.
Retry policy: retry untranslated; delete considered idempotent. 404 errors other than bucket not found are swallowed; this can be raised by third party stores (GCS).
A write capacity of 1 ( as it is signle object delete) will be requested before
the delete call and will be re-requested during retries such that
retries throttle better. If the request is throttled, the time spent is
recorded in a duration IOStat named STORE_IO_RATE_LIMITED_DURATION.
If an exception is caught and swallowed, the response will be empty;
otherwise it will be the response from the delete operation..
deleteObject in interface S3AStorerequest - request to makesoftware.amazon.awssdk.core.exception.SdkException - problems working with S3@Retries.OnceRaw public software.amazon.awssdk.services.s3.model.UploadPartResponse uploadPart(software.amazon.awssdk.services.s3.model.UploadPartRequest request, software.amazon.awssdk.core.sync.RequestBody body, @Nullable org.apache.hadoop.fs.statistics.DurationTrackerFactory trackerFactory) throws software.amazon.awssdk.awscore.exception.AwsServiceException, UncheckedIOException
Retry Policy: none.
uploadPart in interface S3AStoretrackerFactory - duration tracker factory for operationrequest - the upload part request.body - the request body.software.amazon.awssdk.awscore.exception.AwsServiceException - on problemsUncheckedIOException - failure to instantiate the s3 client@Retries.OnceRaw public UploadInfo putObject(software.amazon.awssdk.services.s3.model.PutObjectRequest putObjectRequest, File file, ProgressableProgressListener listener) throws IOException
It does not update the other counters, as existing code does that as progress callbacks come in. Byte length is calculated from the file length, or, if there is no file, from the content length of the header.
Because the operation is async, any stream supplied in the request must reference data (files, buffers) which stay valid until the upload completes. Retry policy: N/A: the transfer manager is performing the upload. Auditing: must be inside an audit span.
putObject in interface S3AStoreputObjectRequest - the requestfile - the file to be uploadedlistener - the progress listener for the requestIOException - if transfer manager creation failed.@Retries.OnceTranslated public software.amazon.awssdk.transfer.s3.model.CompletedFileUpload waitForUploadCompletion(String key, UploadInfo uploadInfo) throws IOException
S3AStore.incrementPutCompletedStatistics(boolean, long)
to update the statistics.waitForUploadCompletion in interface S3AStorekey - destination keyuploadInfo - upload to wait forIOException - IO failureCancellationException - if the wait() was cancelled@Retries.OnceRaw public software.amazon.awssdk.services.s3.model.CompleteMultipartUploadResponse completeMultipartUpload(software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest request)
completeMultipartUpload in interface S3AStorerequest - requestpublic org.apache.hadoop.fs.LocalDirAllocator getDirectoryAllocator()
getDirectoryAllocator in interface S3AStorepublic File createTemporaryFileForWriting(String pathStr, long size, org.apache.hadoop.conf.Configuration conf) throws IOException
LocalDirAllocator.SIZE_UNKNOWN if the
size is unknown.
LocalDirAllocator.createTmpFileForWrite(String, long, Configuration).createTemporaryFileForWriting in interface S3AStorepathStr - prefix for the temporary filesize - the size of the file that is going to be writtenconf - the Configuration objectIOException - IO problemspublic ObjectInputStream readObject(ObjectReadParameters parameters) throws IOException
ObjectInputStreamFactoryreadObject in interface ObjectInputStreamFactoryparameters - parameters.IOException - problem creating the stream.public StreamFactoryRequirements factoryRequirements()
ObjectInputStreamFactoryfactoryRequirements in interface ObjectInputStreamFactorypublic void bind(FactoryBindingParameters factoryBindingParameters)
bind in interface ObjectInputStreamFactoryfactoryBindingParameters - ignoredUnsupportedOperationException - alwayspublic InputStreamType streamType()
ObjectInputStreamFactorystreamType in interface ObjectInputStreamFactoryCopyright © 2008–2025 Apache Software Foundation. All rights reserved.