Package org.apache.hadoop.fs.s3a
Class S3AFileSystem
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.fs.FileSystem
org.apache.hadoop.fs.s3a.S3AFileSystem
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.conf.Configurable,org.apache.hadoop.fs.BulkDeleteSource,org.apache.hadoop.fs.PathCapabilities,AWSPolicyProvider,DelegationTokenProvider,StoreContextFactory,org.apache.hadoop.fs.statistics.IOStatisticsSource,org.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<AuditSpanS3A>,org.apache.hadoop.fs.store.audit.AuditSpanSource<AuditSpanS3A>,org.apache.hadoop.fs.StreamCapabilities,org.apache.hadoop.security.token.DelegationTokenIssuer
@Private
@Evolving
public class S3AFileSystem
extends org.apache.hadoop.fs.FileSystem
implements org.apache.hadoop.fs.StreamCapabilities, AWSPolicyProvider, DelegationTokenProvider, org.apache.hadoop.fs.statistics.IOStatisticsSource, org.apache.hadoop.fs.store.audit.AuditSpanSource<AuditSpanS3A>, org.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<AuditSpanS3A>, StoreContextFactory
The core S3A Filesystem implementation.
This subclass is marked as private as code should not be creating it
directly; use
FileSystem.get(Configuration) and variants to
create one.
If cast to S3AFileSystem, extra methods and features may be accessed.
Consider those private and unstable.
Because it prints some of the state of the instrumentation,
the output of toString() must also be considered unstable.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final classprotected classCallbacks from theGetContentSummaryOperation.protected final classOperations needed for Header Processing.protected classCallbacks fromListing.protected classCallbacks from theMkdirOperation.Nested classes/interfaces inherited from class org.apache.hadoop.fs.FileSystem
org.apache.hadoop.fs.FileSystem.DirectoryEntries, org.apache.hadoop.fs.FileSystem.DirListingIterator<T extends org.apache.hadoop.fs.FileStatus>, org.apache.hadoop.fs.FileSystem.StatisticsNested classes/interfaces inherited from interface org.apache.hadoop.fs.s3a.auth.delegation.AWSPolicyProvider
AWSPolicyProvider.AccessLevelNested classes/interfaces inherited from interface org.apache.hadoop.fs.StreamCapabilities
org.apache.hadoop.fs.StreamCapabilities.StreamCapability -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault blocksize as used in blocksize and FS status queries.static final org.slf4j.LoggerFields inherited from class org.apache.hadoop.fs.FileSystem
DEFAULT_FS, FS_DEFAULT_NAME_KEY, SHUTDOWN_HOOK_PRIORITY, statistics, TRASH_PREFIX, USER_HOME_PREFIXFields inherited from interface org.apache.hadoop.security.token.DelegationTokenIssuer
TOKEN_LOGFields inherited from interface org.apache.hadoop.fs.StreamCapabilities
ABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, IOSTATISTICS_CONTEXT, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER, VECTOREDIO, VECTOREDIO_BUFFERS_SLICED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabortMultipartUpload(String destKey, String uploadId) Abort a multipart upload.voidabortMultipartUpload(software.amazon.awssdk.services.s3.model.MultipartUpload upload) Abort a multipart upload.voidabortOutstandingMultipartUploads(long seconds) Abort all outstanding MPUs older than a given age.voidaccess(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.permission.FsAction mode) Soft check of access by forwarding to the audit manager and so on to the auditor.org.apache.hadoop.fs.FSDataOutputStreamappend(org.apache.hadoop.fs.Path f, int bufferSize, org.apache.hadoop.util.Progressable progress) Append to an existing file (optional operation).booleancancelDeleteOnExit(org.apache.hadoop.fs.Path f) Cancel the scheduled deletion of the path when the FileSystem is closed.protected URIcanonicalizeUri(URI rawUri) Override the base canonicalization logic and relay toS3xLoginHelper.canonicalizeUri(URI, int).voidcheckPath(org.apache.hadoop.fs.Path path) Check that a Path belongs to this FileSystem.voidclose()Close the filesystem.protected S3ListResultcontinueListObjects(S3ListRequest request, S3ListResult prevResult, org.apache.hadoop.fs.statistics.DurationTrackerFactory trackerFactory) List the next set of objects.voidcopyFromLocalFile(boolean delSrc, boolean overwrite, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst) The src file is on the local disk.org.apache.hadoop.fs.FSDataOutputStreamcreate(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.permission.FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) Create an FSDataOutputStream at the indicated Path with write-progress reporting.org.apache.hadoop.fs.BulkDeletecreateBulkDelete(org.apache.hadoop.fs.Path path) S3A implementation to create a bulk delete operation using which actual bulk delete calls can be made.createBulkDeleteCallbacks(org.apache.hadoop.fs.Path path, int pageSize, AuditSpanS3A span) Create the callbacks for the bulk delete operation.protected ClientManagercreateClientManager(S3ClientFactory clientFactory, S3ClientFactory unencryptedClientFactory, S3ClientFactory.S3ClientCreationParameters clientCreationParameters, org.apache.hadoop.fs.statistics.DurationTrackerFactory durationTrackerFactory) Create the Client Manager; protected to allow for mocking.Create the CopyFromLocalCallbacks; protected to assist in mocking.Create an instance of the delegation operations.org.apache.hadoop.fs.FSDataOutputStreamBuildercreateFile(org.apache.hadoop.fs.Path path) Create instance of an FSDataOutputStreamBuilder for creating a file at the given path.Override point: create the callbacks for getContentSummary.Create the callbacks.createListObjectsRequest(String key, String delimiter) Create aListObjectsRequestrequest against this bucket, with the maximum keys returned in a query set bymaxKeys.createMarkerToolOperations(String target) Create a marker tools operations binding for this store.Override point: create the callbacks for Mkdir.createMultipartUploader(org.apache.hadoop.fs.Path basePath) org.apache.hadoop.fs.FSDataOutputStreamcreateNonRecursive(org.apache.hadoop.fs.Path p, org.apache.hadoop.fs.permission.FsPermission permission, EnumSet<org.apache.hadoop.fs.CreateFlag> flags, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) The S3A implementations downgrades to the recursive creation, to avoid any race conditions with parent entries "disappearing".protected S3AReadOpContextcreateReadContext(org.apache.hadoop.fs.FileStatus fileStatus, org.apache.hadoop.fs.store.audit.AuditSpan auditSpan) Create the read context for reading from the referenced file, using FS state as well as the status.protected RequestFactoryBuild the request factory.protected S3AInternalsCreate the S3AInternals; left as something mocking subclasses may want to override.protected S3AStorecreateS3AStore(ClientManager clientManager, int rateLimitCapacity) Create and start the S3AStore instance.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.protected static S3AStorageStatisticscreateStorageStatistics(org.apache.hadoop.fs.statistics.IOStatistics ioStatistics) Create the storage statistics or bind to an existing one.Build an immutable store context.createWriteOperationHelper(org.apache.hadoop.fs.store.audit.AuditSpan auditSpan) Create a Write Operation Helper with the given span.protected voiddecrementGauge(Statistic statistic, long count) Decrement a gauge by a specific value.booleandelete(org.apache.hadoop.fs.Path f, boolean recursive) Delete a Path.protected voiddeleteObject(String key) Delete an object.booleandeleteOnExit(org.apache.hadoop.fs.Path f) This override bypasses checking for existence.protected booleandeleteWithoutCloseCheck(org.apache.hadoop.fs.Path f, boolean recursive) Same as delete(), except that it does not check if fs is closed.protected org.apache.hadoop.fs.store.audit.AuditSpanentryPoint(Statistic operation, String path1, String path2) Entry point to an operation.protected org.apache.hadoop.fs.store.audit.AuditSpanentryPoint(Statistic operation, org.apache.hadoop.fs.Path path) Entry point to an operation.booleanexists(org.apache.hadoop.fs.Path f) Override superclass so as to add statistic collection.Get the active audit span.org.apache.hadoop.security.token.DelegationTokenIssuer[]Ask any DT plugin for any extra token issuers.The audit manager.Get the auditor; valid once initialized.org.apache.hadoop.fs.store.audit.AuditSpanSourceGet the audit span source; allows for components like the committers to have a source of spans without being hard coded to the FS only.Get the bucket of this filesystem.S3AInternals method.protected software.amazon.awssdk.services.s3.model.HeadBucketResponseRequest bucket metadata.Return a service name iff delegation tokens are enabled and the token binding is issuing delegation tokens.Get the canonical URI.Get the change detection policy for this FS instance.org.apache.hadoop.fs.ContentSummarygetContentSummary(org.apache.hadoop.fs.Path f) This is a very slow operation against object storage.longReturn the number of bytes that large input files should be optimally be split into to minimize I/O time.intorg.apache.hadoop.security.token.Token<AbstractS3ATokenIdentifier>getDelegationToken(String renewer) Get a delegation token if the FS is set up for them.Get the delegation token support for this filesystem; not null iff delegation support is enabled.protected org.apache.hadoop.fs.statistics.DurationTrackerFactoryGet the factory for duration tracking.Get the encryption secrets.org.apache.hadoop.fs.store.EtagChecksumgetFileChecksum(org.apache.hadoop.fs.Path f, long length) When enabled, get the etag of a object at the path via HEAD request and return it as a checksum object.org.apache.hadoop.fs.FileStatusgetFileStatus(org.apache.hadoop.fs.Path f) Return a file status object that represents the path.org.apache.hadoop.security.token.Token<? extends org.apache.hadoop.security.token.TokenIdentifier>org.apache.hadoop.fs.FileSystem.StatisticsGet FS Statistic for this S3AFS instance.Get the input policy for this FS instance.Get S3A Instrumentation.org.apache.hadoop.fs.statistics.IOStatisticsGet the instrumentation's IOStatistics.Get current listing instance.longGet the threshold for multipart files.protected software.amazon.awssdk.services.s3.model.HeadObjectResponsegetObjectMetadata(String key, ChangeTracker changeTracker, Invoker changeInvoker, String operation) Request object metadata; increments counters in the process.software.amazon.awssdk.services.s3.model.HeadObjectResponsegetObjectMetadata(org.apache.hadoop.fs.Path path) Deprecated.use S3AInternals API.org.apache.hadoop.security.UserGroupInformationgetOwner()Get the owner of this FS: who created it?longGet the partition size for multipart operations.org.apache.hadoop.fs.impl.FlagSet<PerformanceFlagEnum>Get the performance flags.Get the request factory which uses this store's audit span.Get the S3AInternals.protected software.amazon.awssdk.services.s3.S3ClientGet the S3 client created ininitialize(URI, Configuration).Get the encryption algorithm of this connector.Return the protocol scheme for the FileSystem.Get the storage statistics of this filesystem.getUri()Returns a URI whose scheme and authority identify this FileSystem.Get the username of the FS.org.apache.hadoop.fs.PathGet the current working directory for the given file system.Create a Write Operation Helper with the current active span.byte[]getXAttrs(org.apache.hadoop.fs.Path path) org.apache.hadoop.fs.FileStatus[]globStatus(org.apache.hadoop.fs.Path pathPattern) Increments the statisticStatistic.INVOCATION_GLOB_STATUS.org.apache.hadoop.fs.FileStatus[]globStatus(org.apache.hadoop.fs.Path pathPattern, org.apache.hadoop.fs.PathFilter filter) Increments the statisticStatistic.INVOCATION_GLOB_STATUS.booleanhasCapability(String capability) Deprecated.booleanhasPathCapability(org.apache.hadoop.fs.Path path, String capability) protected voidincrementGauge(Statistic statistic, long count) Increment a gauge by a specific value.protected voidincrementPutCompletedStatistics(boolean success, long bytes) At the end of a put/multipart upload operation, update the relevant counters and gauges.protected voidincrementPutProgressStatistics(String key, long bytes) Callback for use in progress callbacks from put/multipart upload events.protected voidincrementPutStartStatistics(long bytes) At the start of a put/multipart upload operation, update the relevant counters.voidIncrement read operations.protected voidincrementStatistic(Statistic statistic) Increment a statistic by 1.protected voidincrementStatistic(Statistic statistic, long count) Increment a statistic by a specific value.voidIncrement the write operation counter.voidinitialize(URI name, org.apache.hadoop.conf.Configuration originalConf) Initialize the filesystem.protected voidInitialize and launch the audit manager and service.static voidThis is purely for testing, as it force initializes all static initializers.protected voidInitialize the statistics binding.booleana method to know if Client side encryption is enabled or not.booleanisDirectory(org.apache.hadoop.fs.Path f) Optimized probe for a path referencing a dir.booleanisFile(org.apache.hadoop.fs.Path f) Optimized probe for a path referencing a file.booleanIs magic commit enabled?booleanisMagicCommitPath(org.apache.hadoop.fs.Path path) Predicate: is a path a magic commit path?booleanorg.apache.hadoop.fs.PathkeyToQualifiedPath(String key) Convert a key to a fully qualified path.Build the AWS policy for restricted access to the resources needed by this bucket.org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus>listFiles(org.apache.hadoop.fs.Path f, boolean recursive) .org.apache.hadoop.fs.RemoteIterator<S3ALocatedFileStatus>listFilesAndEmptyDirectories(org.apache.hadoop.fs.Path f, boolean recursive) Recursive List of files and empty directories.org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus>listLocatedStatus(org.apache.hadoop.fs.Path f) Override superclass so as to add statistic collection.org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus>listLocatedStatus(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.PathFilter filter) .List<software.amazon.awssdk.services.s3.model.MultipartUpload>listMultipartUploads(String prefix) Listing all multipart uploads; limited to the first few hundred.protected S3ListResultlistObjects(S3ListRequest request, org.apache.hadoop.fs.statistics.DurationTrackerFactory trackerFactory) Initiate alistObjectsoperation, incrementing metrics in the process.org.apache.hadoop.fs.FileStatus[]listStatus(org.apache.hadoop.fs.Path f) List the statuses of the files/directories in the given path if the path is a directory.org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.FileStatus>listStatusIterator(org.apache.hadoop.fs.Path p) Override subclass such that we benefit for async listing done inS3AFileSystem.org.apache.hadoop.fs.RemoteIterator<software.amazon.awssdk.services.s3.model.MultipartUpload>listUploads(String prefix) List any pending multipart uploads whose keys begin with prefix, using an iterator that can handle an unlimited number of entries.org.apache.hadoop.fs.RemoteIterator<software.amazon.awssdk.services.s3.model.MultipartUpload>listUploadsUnderPrefix(StoreContext storeContext, String prefix) List any pending multipart uploads whose keys begin with prefix, using an iterator that can handle an unlimited number of entries.listXAttrs(org.apache.hadoop.fs.Path path) org.apache.hadoop.fs.PathmakeQualified(org.apache.hadoop.fs.Path path) Turns a path (relative or otherwise) into an S3 key, adding a trailing "/" if the path is not the root and does not already have a "/" at the end.protected voidmaybeCreateFakeParentDirectory(org.apache.hadoop.fs.Path path) Create a fake parent directory if required.booleanmkdirs(org.apache.hadoop.fs.Path p, org.apache.hadoop.fs.permission.FsPermission permission) Make the given path and all non-existent parents into directories.Create a new instance of the committer statistics.software.amazon.awssdk.services.s3.model.PutObjectRequest.BuildernewPutObjectRequestBuilder(String key, long length, boolean isDirectoryMarker) Create a putObject request builder.protected org.apache.hadoop.fs.statistics.DurationTrackerFactorynonNullDurationTrackerFactory(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.org.apache.hadoop.fs.FSDataInputStreamopen(org.apache.hadoop.fs.Path f, int bufferSize) Opens an FSDataInputStream at the indicated Path.CompletableFuture<org.apache.hadoop.fs.FSDataInputStream>openFileWithOptions(org.apache.hadoop.fs.Path rawPath, org.apache.hadoop.fs.impl.OpenFileParameters parameters) Initiate the open() operation.voidCallback when an operation was retried.voidoperationRetried(String text, Exception ex, int retries, boolean idempotent) Callback fromInvokerwhen an operation is retried.pathToKey(org.apache.hadoop.fs.Path path) Turns a path (relative or otherwise) into an S3 key.protected voidDelete all paths that were marked as delete-on-exit.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.org.apache.hadoop.fs.Pathqualify(org.apache.hadoop.fs.Path path) Qualify a path.voidremoveKeys(List<software.amazon.awssdk.services.s3.model.ObjectIdentifier> keysToDelete, boolean deleteFakeDir) InvokeremoveKeysS3(List, boolean).booleanrename(org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst) Renames Path src to Path dst.protected voidsetAmazonS3Client(software.amazon.awssdk.services.s3.S3Client client) Set the client -used in mocking tests to force in a different client.protected voidSet the bucket.protected voidsetEncryptionSecrets(EncryptionSecrets secrets) Set the encryption secrets for requests.voidsetInputPolicy(S3AInputPolicy inputPolicy) Deprecated.use openFile() optionsprotected voidSet the URI field throughS3xLoginHelperand optionallycanonicalizeUri(URI)Exported for testing.voidsetWorkingDirectory(org.apache.hadoop.fs.Path newDir) Set the current working directory for the given file system.shareCredentials(String purpose) Get a shared copy of the AWS credentials, with its reference counter updated.protected voidStop all services.toString()protected voidVerify that the bucket exists.Methods inherited from class org.apache.hadoop.fs.FileSystem
append, append, append, append, appendFile, areSymlinksEnabled, clearStatistics, closeAll, closeAllForUGI, completeLocalOutput, concat, copyFromLocalFile, copyFromLocalFile, copyFromLocalFile, copyToLocalFile, copyToLocalFile, copyToLocalFile, create, create, create, create, create, create, create, create, create, create, create, create, createDataInputStreamBuilder, createDataInputStreamBuilder, createDataOutputStreamBuilder, createNewFile, createNonRecursive, createNonRecursive, createPathHandle, createSnapshot, createSnapshot, createSymlink, delete, deleteSnapshot, enableSymlinks, fixRelativePart, get, get, get, getAclStatus, getAllStatistics, getAllStoragePolicies, getBlockSize, getChildFileSystems, getDefaultBlockSize, getDefaultReplication, getDefaultReplication, getDefaultUri, getEnclosingRoot, getFileBlockLocations, getFileBlockLocations, getFileChecksum, getFileLinkStatus, getFileSystemClass, getFSofPath, getGlobalStorageStatistics, getHomeDirectory, getInitialWorkingDirectory, getLength, getLinkTarget, getLocal, getName, getNamed, getPathHandle, getQuotaUsage, getReplication, getServerDefaults, getServerDefaults, getStatistics, getStatistics, getStatus, getStatus, getStoragePolicy, getTrashRoot, getTrashRoots, getUsed, getUsed, listCorruptFileBlocks, listStatus, listStatus, listStatus, listStatusBatch, mkdirs, mkdirs, modifyAclEntries, moveFromLocalFile, moveFromLocalFile, moveToLocalFile, msync, newInstance, newInstance, newInstance, newInstanceLocal, open, open, open, openFile, openFile, openFileWithOptions, primitiveCreate, primitiveMkdir, primitiveMkdir, printStatistics, removeAcl, removeAclEntries, removeDefaultAcl, removeXAttr, rename, renameSnapshot, resolveLink, resolvePath, satisfyStoragePolicy, setAcl, setDefaultUri, setDefaultUri, setOwner, setPermission, setQuota, setQuotaByStorageType, setReplication, setStoragePolicy, setTimes, setVerifyChecksum, setWriteChecksum, setXAttr, setXAttr, startLocalOutput, supportsSymlinks, truncate, unsetStoragePolicyMethods inherited from class org.apache.hadoop.conf.Configured
getConf, setConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.security.token.DelegationTokenIssuer
addDelegationTokens
-
Field Details
-
DEFAULT_BLOCKSIZE
public static final int DEFAULT_BLOCKSIZEDefault blocksize as used in blocksize and FS status queries.- See Also:
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
S3AFileSystem
public S3AFileSystem()
-
-
Method Details
-
initialize
public void initialize(URI name, org.apache.hadoop.conf.Configuration originalConf) throws IOException Initialize the filesystem.This is called after a new FileSystem instance is constructed -but within the filesystem cache creation process. A slow start here while multiple threads are calling will result in multiple instances of the filesystem being created -and all but one deleted. Keep this as fast as possible, and avoid network IO.
This performs the majority of the filesystem setup, and as things are intermixed the ordering of operations is very sensitive. Be very careful when moving things.
To help identify where filesystem instances are created, the full stack is logged at TRACE.
Also, ignore checkstyle complaints about method length.
- Overrides:
initializein classorg.apache.hadoop.fs.FileSystem- Parameters:
name- a uri whose authority section names the host, port, etc. for this FileSystemoriginalConf- the configuration to use for the FS. The bucket-specific options are patched over the base ones before any use is made of the config.- Throws:
IOException
-
createS3AStore
@VisibleForTesting protected S3AStore createS3AStore(ClientManager clientManager, int rateLimitCapacity) Create and start the S3AStore instance. This is protected so that tests can override it.- Parameters:
clientManager- client managerrateLimitCapacity- rate limit- Returns:
- a new store instance
-
initializeStatisticsBinding
protected void initializeStatisticsBinding()Initialize the statistics binding. This is done by creating anIntegratedS3AStatisticsContextwith callbacks to get the FS's instrumentation and FileSystem.statistics field; the latter may change afterinitialize(URI, Configuration), so needs to be dynamically adapted. Protected so that (mock) subclasses can replace it with a different statistics binding, if desired. -
createStorageStatistics
protected static S3AStorageStatistics createStorageStatistics(org.apache.hadoop.fs.statistics.IOStatistics ioStatistics) Create the storage statistics or bind to an existing one.- Parameters:
ioStatistics- IOStatistics to build the storage statistics from.- Returns:
- a storage statistics instance; expected to be that of the FS.
-
verifyBucketExists
Verify that the bucket exists. Retry policy: retrying, translated.- Throws:
UnknownStoreException- the bucket is absentIOException- any other problem talking to S3
-
getInstrumentation
Get S3A Instrumentation. For test purposes.- Returns:
- this instance's instrumentation.
-
getFsStatistics
@VisibleForTesting public org.apache.hadoop.fs.FileSystem.Statistics getFsStatistics()Get FS Statistic for this S3AFS instance.- Returns:
- FS statistic instance.
-
getListing
Get current listing instance.- Returns:
- this instance's listing.
-
createClientManager
@VisibleForTesting protected ClientManager createClientManager(S3ClientFactory clientFactory, S3ClientFactory unencryptedClientFactory, S3ClientFactory.S3ClientCreationParameters clientCreationParameters, org.apache.hadoop.fs.statistics.DurationTrackerFactory durationTrackerFactory) Create the Client Manager; protected to allow for mocking. RequiresunboundedThreadPoolto be initialized.- Parameters:
clientFactory- (reflection-bonded) client factory.unencryptedClientFactory- (reflection-bonded) client factory.clientCreationParameters- parameters for client creation.durationTrackerFactory- factory for duration tracking.- Returns:
- a client manager instance.
-
initializeAuditService
Initialize and launch the audit manager and service. As this takes the FS IOStatistics store, it must be invoked after instrumentation is initialized.- Throws:
IOException- failure to instantiate/initialize.
-
getAuditManager
The audit manager.- Returns:
- the audit manager
-
getAuditor
Get the auditor; valid once initialized.- Returns:
- the auditor.
-
getActiveAuditSpan
Get the active audit span.- Specified by:
getActiveAuditSpanin interfaceorg.apache.hadoop.fs.store.audit.ActiveThreadSpanSource<AuditSpanS3A>- Returns:
- the span.
-
getAuditSpanSource
@Private public org.apache.hadoop.fs.store.audit.AuditSpanSource getAuditSpanSource()Get the audit span source; allows for components like the committers to have a source of spans without being hard coded to the FS only.- Returns:
- the source of spans -base implementation is this instance.
-
createSpan
public AuditSpanS3A createSpan(String operation, @Nullable String path1, @Nullable String path2) throws IOException Start an operation; this informs the audit service of the event and then sets it as the active span.- Specified by:
createSpanin interfaceorg.apache.hadoop.fs.store.audit.AuditSpanSource<AuditSpanS3A>- Parameters:
operation- operation name.path1- first path of operationpath2- second path of operation- Returns:
- a span for the audit
- Throws:
IOException- failure
-
createRequestFactory
Build the request factory. MUST be called after reading encryption secrets from settings/ delegation token. Protected, in case test/mock classes want to implement their own variants.- Returns:
- request factory.
-
getRequestFactory
Get the request factory which uses this store's audit span.- Returns:
- the request factory.
-
getPerformanceFlags
Get the performance flags.- Returns:
- performance flags.
-
createDelegationOperations
Create an instance of the delegation operations.- Returns:
- callbacks for DT support.
-
setEncryptionSecrets
Set the encryption secrets for requests.- Parameters:
secrets- secrets
-
getEncryptionSecrets
Get the encryption secrets. This potentially sensitive information and must be treated with care.- Returns:
- the current encryption secrets.
-
abortOutstandingMultipartUploads
Abort all outstanding MPUs older than a given age.- Parameters:
seconds- time in seconds- Throws:
IOException- on any failure, other than 403 "permission denied"
-
getScheme
Return the protocol scheme for the FileSystem.- Overrides:
getSchemein classorg.apache.hadoop.fs.FileSystem- Returns:
- "s3a"
-
getUri
Returns a URI whose scheme and authority identify this FileSystem.- Specified by:
getUriin classorg.apache.hadoop.fs.FileSystem
-
setUri
Set the URI field throughS3xLoginHelperand optionallycanonicalizeUri(URI)Exported for testing.- Parameters:
fsUri- filesystem URI.canonicalize- true if the URI should be canonicalized.
-
getCanonicalUri
Get the canonical URI.- Overrides:
getCanonicalUriin classorg.apache.hadoop.fs.FileSystem- Returns:
- the canonical URI of this FS.
-
getDefaultPort
@VisibleForTesting public int getDefaultPort()- Overrides:
getDefaultPortin classorg.apache.hadoop.fs.FileSystem
-
setAmazonS3Client
@VisibleForTesting protected void setAmazonS3Client(software.amazon.awssdk.services.s3.S3Client client) Set the client -used in mocking tests to force in a different client.- Parameters:
client- client.
-
getS3Client
@VisibleForTesting protected software.amazon.awssdk.services.s3.S3Client getS3Client()Get the S3 client created ininitialize(URI, Configuration).- Returns:
- the s3Client
- Throws:
UncheckedIOException- if the client could not be created.
-
getBucketLocation
S3AInternals method. .- Throws:
IOException
-
createS3AInternals
Create the S3AInternals; left as something mocking subclasses may want to override.- Returns:
- the internal implementation
-
getS3AInternals
Get the S3AInternals.- Returns:
- the internal implementation
-
getInputPolicy
Get the input policy for this FS instance.- Returns:
- the input policy
-
getChangeDetectionPolicy
Get the change detection policy for this FS instance. Only public to allow access in tests in other packages.- Returns:
- the change detection policy
-
getS3EncryptionAlgorithm
Get the encryption algorithm of this connector.- Returns:
- the encryption algorithm.
-
getBucket
Get the bucket of this filesystem.- Returns:
- the bucket
-
setBucket
Set the bucket.- Parameters:
bucket- the bucket
-
setInputPolicy
Deprecated.use openFile() optionsChange the input policy for this FS. This is now a no-op, retained in case some application or external test invokes it.- Parameters:
inputPolicy- new policy
-
pathToKey
Turns a path (relative or otherwise) into an S3 key.- Parameters:
path- input path, may be relative to the working dir- Returns:
- a key excluding the leading "/", or, if it is the root path, ""
-
maybeAddTrailingSlash
Turns a path (relative or otherwise) into an S3 key, adding a trailing "/" if the path is not the root and does not already have a "/" at the end.- Parameters:
key- s3 key or ""- Returns:
- the with a trailing "/", or, if it is the root key, "",
-
keyToQualifiedPath
Convert a key to a fully qualified path. This includes fixing up the URI so that if it ends with a trailing slash, that is corrected, similar toPath.normalizePath().- Parameters:
key- input key- Returns:
- the fully qualified path including URI scheme and bucket name.
-
makeQualified
public org.apache.hadoop.fs.Path makeQualified(org.apache.hadoop.fs.Path path) - Overrides:
makeQualifiedin classorg.apache.hadoop.fs.FileSystem
-
qualify
public org.apache.hadoop.fs.Path qualify(org.apache.hadoop.fs.Path path) Qualify a path. This includes fixing up the URI so that if it ends with a trailing slash, that is corrected, similar toPath.normalizePath().- Parameters:
path- path to qualify- Returns:
- a qualified path.
-
checkPath
public void checkPath(org.apache.hadoop.fs.Path path) Check that a Path belongs to this FileSystem. Unlike the superclass, this version does not look at authority, only hostnames.- Overrides:
checkPathin classorg.apache.hadoop.fs.FileSystem- Parameters:
path- to check- Throws:
IllegalArgumentException- if there is an FS mismatch
-
canonicalizeUri
Override the base canonicalization logic and relay toS3xLoginHelper.canonicalizeUri(URI, int). This allows for the option of changing this logic for better DT handling.- Overrides:
canonicalizeUriin classorg.apache.hadoop.fs.FileSystem- Parameters:
rawUri- raw URI.- Returns:
- the canonical URI to use in delegation tokens and file context.
-
open
@RetryTranslated public org.apache.hadoop.fs.FSDataInputStream open(org.apache.hadoop.fs.Path f, int bufferSize) throws IOException Opens an FSDataInputStream at the indicated Path.- Specified by:
openin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- the file name to openbufferSize- the size of the buffer to be used.- Throws:
IOException
-
createReadContext
@VisibleForTesting protected S3AReadOpContext createReadContext(org.apache.hadoop.fs.FileStatus fileStatus, org.apache.hadoop.fs.store.audit.AuditSpan auditSpan) Create the read context for reading from the referenced file, using FS state as well as the status.- Parameters:
fileStatus- file status.auditSpan- audit span.- Returns:
- a context for read operations.
-
create
@AuditEntryPoint public org.apache.hadoop.fs.FSDataOutputStream create(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.permission.FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) throws IOException Create an FSDataOutputStream at the indicated Path with write-progress reporting. Retry policy: retrying, translated on the getFileStatus() probe. No data is uploaded to S3 in this call, so retry issues related to that.- Specified by:
createin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- the file name to openpermission- the permission to set.overwrite- if a file with this name already exists, then if true, the file will be overwritten, and if false an error will be thrown.bufferSize- the size of the buffer to be used.replication- required block replication for the file.blockSize- the requested block size.progress- the progress reporter.- Throws:
IOException- in the event of IO related errors.- See Also:
-
FileSystem.setPermission(Path, FsPermission)
-
getWriteOperationHelper
Create a Write Operation Helper with the current active span. All operations made through this helper will activate the span before execution. This class permits other low-level operations against the store. It is unstable and only intended for code with intimate knowledge of the object store. If using this, be prepared for changes even on minor point releases.- Returns:
- a new helper.
-
createWriteOperationHelper
@Private public WriteOperationHelper createWriteOperationHelper(org.apache.hadoop.fs.store.audit.AuditSpan auditSpan) Create a Write Operation Helper with the given span. All operations made through this helper will activate the span before execution.- Parameters:
auditSpan- audit span- Returns:
- a new helper.
-
createFile
@AuditEntryPoint public org.apache.hadoop.fs.FSDataOutputStreamBuilder createFile(org.apache.hadoop.fs.Path path) Create instance of an FSDataOutputStreamBuilder for creating a file at the given path.- Overrides:
createFilein classorg.apache.hadoop.fs.FileSystem- Parameters:
path- path to create- Returns:
- a builder.
- Throws:
UncheckedIOException- for problems creating the audit span
-
createNonRecursive
@AuditEntryPoint public org.apache.hadoop.fs.FSDataOutputStream createNonRecursive(org.apache.hadoop.fs.Path p, org.apache.hadoop.fs.permission.FsPermission permission, EnumSet<org.apache.hadoop.fs.CreateFlag> flags, int bufferSize, short replication, long blockSize, org.apache.hadoop.util.Progressable progress) throws IOException The S3A implementations downgrades to the recursive creation, to avoid any race conditions with parent entries "disappearing".- Overrides:
createNonRecursivein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
append
public org.apache.hadoop.fs.FSDataOutputStream append(org.apache.hadoop.fs.Path f, int bufferSize, org.apache.hadoop.util.Progressable progress) throws IOException Append to an existing file (optional operation).- Specified by:
appendin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- the existing file to be appended.bufferSize- the size of the buffer to be used.progress- for reporting progress if it is not null.- Throws:
IOException- indicating that append is not supported.
-
rename
@AuditEntryPoint @RetryTranslated public boolean rename(org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst) throws IOException Renames Path src to Path dst. Can take place on local fs or remote DFS. Warning: S3 does not support renames. This method does a copy which can take S3 some time to execute with large files and directories. Since there is no Progressable passed in, this can time out jobs. Note: This implementation differs with other S3 drivers. Specifically:Fails if src is a file and dst is a directory. Fails if src is a directory and dst is a file. Fails if the parent of dst does not exist or is a file. Fails if dst is a directory that is not empty.- Specified by:
renamein classorg.apache.hadoop.fs.FileSystem- Parameters:
src- path to be renameddst- new path after rename- Returns:
- true if rename is successful
- Throws:
IOException- on IO failure
-
getFsDelegationToken
public org.apache.hadoop.security.token.Token<? extends org.apache.hadoop.security.token.TokenIdentifier> getFsDelegationToken() throws IOException- Specified by:
getFsDelegationTokenin interfaceDelegationTokenProvider- Throws:
IOException
-
getObjectMetadata
@AuditEntryPoint @LimitedPrivate("utilities") @RetryTranslated @Deprecated public software.amazon.awssdk.services.s3.model.HeadObjectResponse getObjectMetadata(org.apache.hadoop.fs.Path path) throws IOException Deprecated.use S3AInternals API.Low-level call to get at the object metadata. This method is used in some external applications and so must be viewed as a public entry point.- Parameters:
path- path to the object. This will be qualified.- Returns:
- metadata
- Throws:
IOException- IO and object access problems.
-
entryPoint
protected org.apache.hadoop.fs.store.audit.AuditSpan entryPoint(Statistic operation, org.apache.hadoop.fs.Path path) throws IOException Entry point to an operation. Increments the statistic; verifies the FS is active.- Parameters:
operation- The operation being invokedpath- first path of operation- Returns:
- a span for the audit
- Throws:
IOException- failure of audit service
-
entryPoint
protected org.apache.hadoop.fs.store.audit.AuditSpan entryPoint(Statistic operation, @Nullable String path1, @Nullable String path2) throws IOException Entry point to an operation. Increments the statistic; verifies the FS is active.- Parameters:
operation- The operation being invokedpath1- first path of operationpath2- second path of operation- Returns:
- a span for the audit
- Throws:
IOException- failure of audit service
-
incrementStatistic
Increment a statistic by 1. This increments both the instrumentation and storage statistics.- Parameters:
statistic- The operation to increment
-
incrementStatistic
Increment a statistic by a specific value. This increments both the instrumentation and storage statistics.- Parameters:
statistic- The operation to incrementcount- the count to increment
-
decrementGauge
Decrement a gauge by a specific value.- Parameters:
statistic- The operation to decrementcount- the count to decrement
-
incrementGauge
Increment a gauge by a specific value.- Parameters:
statistic- The operation to incrementcount- the count to increment
-
operationRetried
Callback when an operation was retried. Increments the statistics of ignored errors or throttled requests, depending up on the exception class.- Parameters:
ex- exception.
-
operationRetried
Callback fromInvokerwhen an operation is retried.- Parameters:
text- text of the operationex- exceptionretries- number of retriesidempotent- is the method idempotent
-
getStorageStatistics
Get the storage statistics of this filesystem.- Overrides:
getStorageStatisticsin classorg.apache.hadoop.fs.FileSystem- Returns:
- the storage statistics
-
getIOStatistics
public org.apache.hadoop.fs.statistics.IOStatistics getIOStatistics()Get the instrumentation's IOStatistics.- Specified by:
getIOStatisticsin interfaceorg.apache.hadoop.fs.statistics.IOStatisticsSource- Returns:
- statistics or null if instrumentation has not yet been instantiated.
-
getDurationTrackerFactory
protected org.apache.hadoop.fs.statistics.DurationTrackerFactory getDurationTrackerFactory()Get the factory for duration tracking.- Returns:
- a factory from the instrumentation.
-
nonNullDurationTrackerFactory
protected 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.- Parameters:
factory- factory.- Returns:
- a non-null factory.
-
getObjectMetadata
@RetryRaw protected software.amazon.awssdk.services.s3.model.HeadObjectResponse getObjectMetadata(String key, ChangeTracker changeTracker, Invoker changeInvoker, String operation) throws IOException Request object metadata; increments counters in the process. Retry policy: retry untranslated. Uses changeTracker to detect an unexpected file version (eTag or versionId)- Parameters:
key- keychangeTracker- the change tracker to detect unexpected object versionchangeInvoker- the invoker providing the retry policyoperation- the operation (e.g. "read" or "copy") triggering this call- Returns:
- the metadata
- Throws:
IOException- if the retry invocation raises one (it shouldn't).RemoteFileChangedException- if an unexpected version is detected
-
getBucketMetadata
@AuditEntryPoint @RetryTranslated protected software.amazon.awssdk.services.s3.model.HeadBucketResponse getBucketMetadata() throws IOExceptionRequest bucket metadata.- Returns:
- the metadata
- Throws:
UnknownStoreException- the bucket is absentIOException- any other problem talking to S3
-
listObjects
@RetryRaw protected S3ListResult listObjects(S3ListRequest request, @Nullable org.apache.hadoop.fs.statistics.DurationTrackerFactory trackerFactory) throws IOException Initiate alistObjectsoperation, incrementing metrics in the process. Retry policy: retry untranslated.- Parameters:
request- request to initiatetrackerFactory- duration tracking- Returns:
- the results
- Throws:
IOException- if the retry invocation raises one (it shouldn't).
-
continueListObjects
@RetryRaw protected S3ListResult continueListObjects(S3ListRequest request, S3ListResult prevResult, org.apache.hadoop.fs.statistics.DurationTrackerFactory trackerFactory) throws IOException List the next set of objects. Retry policy: retry untranslated.- Parameters:
request- last list objects request to continueprevResult- last paged result to continue fromtrackerFactory- duration tracking- Returns:
- the next result object
- Throws:
IOException- none, just there for retryUntranslated.
-
incrementReadOperations
public void incrementReadOperations()Increment read operations. -
incrementWriteOperations
public void incrementWriteOperations()Increment the write operation counter. This is somewhat inaccurate, as it appears to be invoked more often than needed in progress callbacks. -
deleteObject
@VisibleForTesting @RetryRaw protected void deleteObject(String key) throws software.amazon.awssdk.core.exception.SdkException, IOException Delete an object. Increments theOBJECT_DELETE_REQUESTSand write operation statistics. This call does not create any mock parent entries. Retry policy: retry untranslated; delete considered idempotent.- Parameters:
key- key to blob to delete.- Throws:
software.amazon.awssdk.core.exception.SdkException- problems working with S3org.apache.hadoop.fs.InvalidRequestException- if the request was rejected due to a mistaken attempt to delete the root directory.IOException
-
newPutObjectRequestBuilder
public software.amazon.awssdk.services.s3.model.PutObjectRequest.Builder newPutObjectRequestBuilder(String key, long length, boolean isDirectoryMarker) Create a putObject request builder. Adds the ACL and metadata- Parameters:
key- key of objectlength- length of object to be uploadedisDirectoryMarker- true if object to be uploaded is a directory marker- Returns:
- the request
-
putObject
@OnceRaw public UploadInfo putObject(software.amazon.awssdk.services.s3.model.PutObjectRequest putObjectRequest, File file, ProgressableProgressListener listener) throws IOException Start a transfer-manager managed async PUT of an object, incrementing the put requests and put bytes counters. 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.- Parameters:
putObjectRequest- the requestfile- the file to be uploadedlistener- the progress listener for the request- Returns:
- the upload initiated
- Throws:
IOException- if transfer manager creation failed.
-
incrementPutStartStatistics
protected void incrementPutStartStatistics(long bytes) At the start of a put/multipart upload operation, update the relevant counters.- Parameters:
bytes- bytes in the request.
-
incrementPutCompletedStatistics
protected void incrementPutCompletedStatistics(boolean success, long bytes) At the end of a put/multipart upload operation, update the relevant counters and gauges.- Parameters:
success- did the operation succeed?bytes- bytes in the request.
-
incrementPutProgressStatistics
Callback for use in progress callbacks from put/multipart upload events. Increments those statistics which are expected to be updated during the ongoing upload operation.- Parameters:
key- key to file that is being written (for logging)bytes- bytes successfully uploaded.
-
removeKeys
@VisibleForTesting @RetryRaw public void removeKeys(List<software.amazon.awssdk.services.s3.model.ObjectIdentifier> keysToDelete, boolean deleteFakeDir) throws MultiObjectDeleteException, software.amazon.awssdk.awscore.exception.AwsServiceException, IOException InvokeremoveKeysS3(List, boolean). If aMultiObjectDeleteExceptionis raised, the relevant statistics are updated.- Parameters:
keysToDelete- collection of keys to delete on the s3-backend. if empty, no request is made of the object store.deleteFakeDir- indicates whether this is for deleting fake dirs- Throws:
org.apache.hadoop.fs.InvalidRequestException- if the request was rejected due to a mistaken attempt to delete the root directory.MultiObjectDeleteException- one or more of the keys could not be deleted in a multiple object delete operation.software.amazon.awssdk.awscore.exception.AwsServiceException- amazon-layer failure.IOException- other IO Exception.
-
delete
@RetryTranslated @AuditEntryPoint public boolean delete(org.apache.hadoop.fs.Path f, boolean recursive) throws IOException Delete a Path. This operation is at leastO(files), with added overheads to enumerate the path. It is also not atomic.- Specified by:
deletein classorg.apache.hadoop.fs.FileSystem- Parameters:
f- the path to delete.recursive- if path is a directory and set to true, the directory is deleted else throws an exception. In case of a file the recursive can be set to either true or false.- Returns:
- true if the path existed and then was deleted; false if there was no path in the first place, or the corner cases of root path deletion have surfaced.
- Throws:
IOException- due to inability to delete a directory or file.
-
deleteWithoutCloseCheck
@VisibleForTesting protected boolean deleteWithoutCloseCheck(org.apache.hadoop.fs.Path f, boolean recursive) throws IOException Same as delete(), except that it does not check if fs is closed.- Parameters:
f- the path to delete.recursive- if path is a directory and set to true, the directory is deleted else throws an exception. In case of a file the recursive can be set to either true or false.- Returns:
- true if the path existed and then was deleted; false if there was no path in the first place, or the corner cases of root path deletion have surfaced.
- Throws:
IOException- due to inability to delete a directory or file.
-
maybeCreateFakeParentDirectory
@RetryTranslated @VisibleForTesting protected void maybeCreateFakeParentDirectory(org.apache.hadoop.fs.Path path) throws IOException, software.amazon.awssdk.core.exception.SdkException Create a fake parent directory if required. That is: it parent is not the root path and does not yet exist.- Parameters:
path- whose parent is created if needed.- Throws:
IOException- IO problemsoftware.amazon.awssdk.core.exception.SdkException
-
listStatusIterator
@AuditEntryPoint public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.FileStatus> listStatusIterator(org.apache.hadoop.fs.Path p) throws FileNotFoundException, IOException Override subclass such that we benefit for async listing done inS3AFileSystem. SeeListing#ObjectListingIterator.- Overrides:
listStatusIteratorin classorg.apache.hadoop.fs.FileSystem- Throws:
FileNotFoundExceptionIOException
-
listStatus
@AuditEntryPoint public org.apache.hadoop.fs.FileStatus[] listStatus(org.apache.hadoop.fs.Path f) throws FileNotFoundException, IOException List the statuses of the files/directories in the given path if the path is a directory.- Specified by:
listStatusin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- given path- Returns:
- the statuses of the files/directories in the given patch
- Throws:
FileNotFoundException- when the path does not exist; IOException see specific implementationIOException
-
createListObjectsRequest
Create aListObjectsRequestrequest against this bucket, with the maximum keys returned in a query set bymaxKeys.- Parameters:
key- key for requestdelimiter- any delimiter- Returns:
- the request
-
setWorkingDirectory
public void setWorkingDirectory(org.apache.hadoop.fs.Path newDir) Set the current working directory for the given file system. All relative paths will be resolved relative to it.- Specified by:
setWorkingDirectoryin classorg.apache.hadoop.fs.FileSystem- Parameters:
newDir- the current working directory.
-
getWorkingDirectory
public org.apache.hadoop.fs.Path getWorkingDirectory()Get the current working directory for the given file system.- Specified by:
getWorkingDirectoryin classorg.apache.hadoop.fs.FileSystem- Returns:
- the directory pathname
-
getUsername
Get the username of the FS.- Returns:
- the short name of the user who instantiated the FS
-
getOwner
public org.apache.hadoop.security.UserGroupInformation getOwner()Get the owner of this FS: who created it?- Returns:
- the owner of the FS.
-
mkdirs
@AuditEntryPoint public boolean mkdirs(org.apache.hadoop.fs.Path p, org.apache.hadoop.fs.permission.FsPermission permission) throws IOException, org.apache.hadoop.fs.FileAlreadyExistsException Make the given path and all non-existent parents into directories. Has the semantics of Unix'mkdir -p'. Existence of the directory hierarchy is not an error. Parent elements are scanned to see if any are a file, except under "MAGIC PATH" paths. There the FS assumes that the destination directory creation did that scan and that paths in job/task attempts are all "well formed"- Specified by:
mkdirsin classorg.apache.hadoop.fs.FileSystem- Parameters:
p- path to createpermission- to apply to path- Returns:
- true if a directory was created or already existed
- Throws:
org.apache.hadoop.fs.FileAlreadyExistsException- there is a file at the path specified or is discovered on one of its ancestors.IOException- other IO problems
-
createMkdirOperationCallbacks
Override point: create the callbacks for Mkdir. This does not create a new span; caller must be in one.- Returns:
- an implementation of the MkdirCallbacks,
-
getContentSummary
@RetryTranslated @AuditEntryPoint public org.apache.hadoop.fs.ContentSummary getContentSummary(org.apache.hadoop.fs.Path f) throws IOException This is a very slow operation against object storage. Execute it as a single span with whatever optimizations have been implemented.- Overrides:
getContentSummaryin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
createGetContentSummaryCallbacks
Override point: create the callbacks for getContentSummary. This does not create a new span; caller must be in one.- Returns:
- an implementation of the GetContentSummaryCallbacksImpl
-
access
@AuditEntryPoint public void access(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.permission.FsAction mode) throws org.apache.hadoop.security.AccessControlException, FileNotFoundException, IOException Soft check of access by forwarding to the audit manager and so on to the auditor.- Overrides:
accessin classorg.apache.hadoop.fs.FileSystem- Throws:
org.apache.hadoop.security.AccessControlExceptionFileNotFoundExceptionIOException
-
getFileStatus
@AuditEntryPoint @RetryTranslated public org.apache.hadoop.fs.FileStatus getFileStatus(org.apache.hadoop.fs.Path f) throws IOException Return a file status object that represents the path.- Specified by:
getFileStatusin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- The path we want information from- Returns:
- a FileStatus object
- Throws:
FileNotFoundException- when the path does not existIOException- on other problems.
-
copyFromLocalFile
@AuditEntryPoint public void copyFromLocalFile(boolean delSrc, boolean overwrite, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.Path dst) throws IOException The src file is on the local disk. Add it to FS at the given dst name. This version doesn't need to create a temporary file to calculate the md5. IfConstants.OPTIMIZED_COPY_FROM_LOCALis set to false, the superclass implementation is used.- Overrides:
copyFromLocalFilein classorg.apache.hadoop.fs.FileSystem- Parameters:
delSrc- whether to delete the srcoverwrite- whether to overwrite an existing filesrc- pathdst- path- Throws:
IOException- IO problemorg.apache.hadoop.fs.FileAlreadyExistsException- the destination file exists and overwrite==false
-
createCopyFromLocalCallbacks
protected CopyFromLocalOperation.CopyFromLocalOperationCallbacks createCopyFromLocalCallbacks(AuditSpanS3A span) throws IOException Create the CopyFromLocalCallbacks; protected to assist in mocking.- Parameters:
span- audit span.- Returns:
- the callbacks
- Throws:
IOException- failure to get the local fs.
-
deleteOnExit
This override bypasses checking for existence.- Overrides:
deleteOnExitin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- the path to delete; this may be unqualified.- Returns:
- true, always.
- Throws:
IOException- IO failure
-
cancelDeleteOnExit
public boolean cancelDeleteOnExit(org.apache.hadoop.fs.Path f) Cancel the scheduled deletion of the path when the FileSystem is closed.- Overrides:
cancelDeleteOnExitin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- the path to cancel deletion- Returns:
- true if the path was found in the delete-on-exit list.
-
processDeleteOnExit
protected void processDeleteOnExit()Delete all paths that were marked as delete-on-exit. This recursively deletes all files and directories in the specified paths. It does not check if file exists and filesystem is closed. The time to process this operation isO(paths), with the actual time dependent on the time for existence and deletion operations to complete, successfully or not.- Overrides:
processDeleteOnExitin classorg.apache.hadoop.fs.FileSystem
-
close
Close the filesystem. This shuts down all transfers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException- IO problem
-
stopAllServices
protected void stopAllServices()Stop all services. This is invoked in close() and during failures of initialize() -make sure that all operations here are robust to failures in both the expected state of this FS and of failures while being stopped. -
getDelegationTokens
Get the delegation token support for this filesystem; not null iff delegation support is enabled.- Returns:
- the token support, or an empty option.
-
getCanonicalServiceName
Return a service name iff delegation tokens are enabled and the token binding is issuing delegation tokens.- Specified by:
getCanonicalServiceNamein interfaceorg.apache.hadoop.security.token.DelegationTokenIssuer- Overrides:
getCanonicalServiceNamein classorg.apache.hadoop.fs.FileSystem- Returns:
- the canonical service name or null
-
getDelegationToken
@AuditEntryPoint public org.apache.hadoop.security.token.Token<AbstractS3ATokenIdentifier> getDelegationToken(String renewer) throws IOException Get a delegation token if the FS is set up for them. If the user already has a token, it is returned, even if it has expired.- Specified by:
getDelegationTokenin interfaceorg.apache.hadoop.security.token.DelegationTokenIssuer- Overrides:
getDelegationTokenin classorg.apache.hadoop.fs.FileSystem- Parameters:
renewer- the account name that is allowed to renew the token.- Returns:
- the delegation token or null
- Throws:
IOException- IO failure
-
getAdditionalTokenIssuers
public org.apache.hadoop.security.token.DelegationTokenIssuer[] getAdditionalTokenIssuers() throws IOExceptionAsk any DT plugin for any extra token issuers. These do not get told of the encryption secrets and can return any type of token. This allows DT plugins to issue extra tokens for ancillary services.- Specified by:
getAdditionalTokenIssuersin interfaceorg.apache.hadoop.security.token.DelegationTokenIssuer- Overrides:
getAdditionalTokenIssuersin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
listAWSPolicyRules
@Private public List<RoleModel.Statement> listAWSPolicyRules(Set<AWSPolicyProvider.AccessLevel> access) Build the AWS policy for restricted access to the resources needed by this bucket. if needed, and KMS operations.- Specified by:
listAWSPolicyRulesin interfaceAWSPolicyProvider- Parameters:
access- access level desired.- Returns:
- a policy for use in roles
-
getDefaultBlockSize
public long getDefaultBlockSize()Return the number of bytes that large input files should be optimally be split into to minimize I/O time.- Overrides:
getDefaultBlockSizein classorg.apache.hadoop.fs.FileSystem
-
toString
-
getPartitionSize
public long getPartitionSize()Get the partition size for multipart operations.- Returns:
- the value as set during initialization
-
getMultiPartThreshold
public long getMultiPartThreshold()Get the threshold for multipart files.- Returns:
- the value as set during initialization
-
isMagicCommitEnabled
public boolean isMagicCommitEnabled()Is magic commit enabled?- Returns:
- true if magic commit support is turned on.
-
isMagicCommitPath
public boolean isMagicCommitPath(org.apache.hadoop.fs.Path path) Predicate: is a path a magic commit path? True if magic commit is enabled and the path qualifies as special, and is not a a .pending or .pendingset file,- Parameters:
path- path to examine- Returns:
- true if writing a file to the path triggers a "magic" write.
-
globStatus
public org.apache.hadoop.fs.FileStatus[] globStatus(org.apache.hadoop.fs.Path pathPattern) throws IOException Increments the statisticStatistic.INVOCATION_GLOB_STATUS. Override superclass so as to disable symlink resolution as symlinks are not supported by S3A.- Overrides:
globStatusin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
globStatus
@AuditEntryPoint public org.apache.hadoop.fs.FileStatus[] globStatus(org.apache.hadoop.fs.Path pathPattern, org.apache.hadoop.fs.PathFilter filter) throws IOException Increments the statisticStatistic.INVOCATION_GLOB_STATUS. Override superclass so as to disable symlink resolution as symlinks are not supported by S3A. Although an AuditEntryPoint, the globber itself will talk do the filesystem through the filesystem API, so its operations will all appear part of separate operations.- Overrides:
globStatusin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
exists
Override superclass so as to add statistic collection.- Overrides:
existsin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
isDirectory
Optimized probe for a path referencing a dir. Even though it is optimized to a single HEAD, applications should not over-use this method...it is all too common.- Overrides:
isDirectoryin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
isFile
Optimized probe for a path referencing a file. Even though it is optimized to a single HEAD, applications should not over-use this method...it is all too common.- Overrides:
isFilein classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
getFileChecksum
@RetryTranslated @AuditEntryPoint public org.apache.hadoop.fs.store.EtagChecksum getFileChecksum(org.apache.hadoop.fs.Path f, long length) throws IOException When enabled, get the etag of a object at the path via HEAD request and return it as a checksum object.- If a tag has not changed, consider the object unchanged.
- Two tags being different does not imply the data is different.
Constants.ETAG_CHECKSUM_ENABLEDis set; turning it on has caused problems with Distcp (HADOOP-15273).- Overrides:
getFileChecksumin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- The file pathlength- The length of the file range for checksum calculation- Returns:
- The EtagChecksum or null if checksums are not enabled or supported.
- Throws:
IOException- IO failure- See Also:
-
getXAttr
@AuditEntryPoint public byte[] getXAttr(org.apache.hadoop.fs.Path path, String name) throws IOException - Overrides:
getXAttrin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
getXAttrs
@AuditEntryPoint public Map<String,byte[]> getXAttrs(org.apache.hadoop.fs.Path path) throws IOException - Overrides:
getXAttrsin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
getXAttrs
@AuditEntryPoint public Map<String,byte[]> getXAttrs(org.apache.hadoop.fs.Path path, List<String> names) throws IOException - Overrides:
getXAttrsin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
listXAttrs
- Overrides:
listXAttrsin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
createHeaderProcessingCallbacks
Create the callbacks.- Returns:
- An implementation of the header processing callbacks.
-
listFiles
@RetryTranslated @AuditEntryPoint public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus> listFiles(org.apache.hadoop.fs.Path f, boolean recursive) throws FileNotFoundException, IOException . This implementation is optimized for S3, which can do a bulk listing off all entries under a path in one single operation. Thus there is no need to recursively walk the directory tree. Instead aListObjectsRequestis created requesting a (windowed) listing of all entries under the given path. This is used to construct anObjectListingIteratorinstance, iteratively returning the sequence of lists of elements under the path. This is then iterated over in aFileStatusListingIterator, which generatesS3AFileStatusinstances, one per listing entry. These are then translated intoLocatedFileStatusinstances. This is essentially a nested and wrapped set of iterators, with some generator classes.- Overrides:
listFilesin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- a pathrecursive- if the subdirectories need to be traversed recursively- Returns:
- an iterator that traverses statuses of the files/directories in the given path
- Throws:
FileNotFoundException- ifpathdoes not existIOException- if any I/O error occurred
-
listFilesAndEmptyDirectories
@Private @RetryTranslated @AuditEntryPoint public org.apache.hadoop.fs.RemoteIterator<S3ALocatedFileStatus> listFilesAndEmptyDirectories(org.apache.hadoop.fs.Path f, boolean recursive) throws IOException Recursive List of files and empty directories.- Parameters:
f- path to list fromrecursive- recursive?- Returns:
- an iterator.
- Throws:
IOException- failure
-
listLocatedStatus
public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus> listLocatedStatus(org.apache.hadoop.fs.Path f) throws FileNotFoundException, IOException Override superclass so as to add statistic collection.- Overrides:
listLocatedStatusin classorg.apache.hadoop.fs.FileSystem- Throws:
FileNotFoundExceptionIOException
-
listLocatedStatus
@OnceTranslated("s3guard not retrying") @AuditEntryPoint public org.apache.hadoop.fs.RemoteIterator<org.apache.hadoop.fs.LocatedFileStatus> listLocatedStatus(org.apache.hadoop.fs.Path f, org.apache.hadoop.fs.PathFilter filter) throws FileNotFoundException, IOException . S3 Optimized directory listing. The initial operation performs the first bulk listing; extra listings will take place when all the current set of results are used up.- Overrides:
listLocatedStatusin classorg.apache.hadoop.fs.FileSystem- Parameters:
f- a pathfilter- a path filter- Returns:
- an iterator that traverses statuses of the files/directories in the given path
- Throws:
FileNotFoundException- ifpathdoes not existIOException- if any I/O error occurred
-
listUploads
@Private @RetryTranslated @AuditEntryPoint public org.apache.hadoop.fs.RemoteIterator<software.amazon.awssdk.services.s3.model.MultipartUpload> listUploads(@Nullable String prefix) throws IOException List any pending multipart uploads whose keys begin with prefix, using an iterator that can handle an unlimited number of entries. SeelistMultipartUploads(String)for a non-iterator version of this.- Parameters:
prefix- optional key prefix to search- Returns:
- Iterator over multipart uploads.
- Throws:
IOException- on failure
-
listUploadsUnderPrefix
@Private @RetryTranslated public org.apache.hadoop.fs.RemoteIterator<software.amazon.awssdk.services.s3.model.MultipartUpload> listUploadsUnderPrefix(StoreContext storeContext, @Nullable String prefix) throws IOException List any pending multipart uploads whose keys begin with prefix, using an iterator that can handle an unlimited number of entries. SeelistMultipartUploads(String)for a non-iterator version of this.- Parameters:
storeContext- store conext.prefix- optional key prefix to search- Returns:
- Iterator over multipart uploads.
- Throws:
IOException- on failure
-
listMultipartUploads
@Private @RetryTranslated public List<software.amazon.awssdk.services.s3.model.MultipartUpload> listMultipartUploads(String prefix) throws IOException Listing all multipart uploads; limited to the first few hundred. SeelistUploads(String)for an iterator-based version that does not limit the number of entries returned. Retry policy: retry, translated.- Parameters:
prefix- prefix to scan for, "" for none- Returns:
- a listing of multipart uploads.
- Throws:
IOException- IO failure, including any uprated SdkException
-
abortMultipartUpload
@OnceTranslated public void abortMultipartUpload(String destKey, String uploadId) throws IOException Abort a multipart upload. Retry policy: none.- Parameters:
destKey- destination keyuploadId- Upload ID- Throws:
IOException- IO failure, including any uprated SdkException
-
abortMultipartUpload
@OnceTranslated public void abortMultipartUpload(software.amazon.awssdk.services.s3.model.MultipartUpload upload) throws IOException Abort a multipart upload. Retry policy: none.- Parameters:
upload- the listed upload to abort.- Throws:
IOException- IO failure, including any uprated SdkException
-
newCommitterStatistics
Create a new instance of the committer statistics.- Returns:
- a new committer statistics instance
-
hasPathCapability
public boolean hasPathCapability(org.apache.hadoop.fs.Path path, String capability) throws IOException - Specified by:
hasPathCapabilityin interfaceorg.apache.hadoop.fs.PathCapabilities- Overrides:
hasPathCapabilityin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
hasCapability
Deprecated.Return the capabilities of this filesystem instance. This has been supplanted byhasPathCapability(Path, String).- Specified by:
hasCapabilityin interfaceorg.apache.hadoop.fs.StreamCapabilities- Parameters:
capability- string to query the stream support for.- Returns:
- whether the FS instance has the capability.
-
openFileWithOptions
@RetryTranslated @AuditEntryPoint public CompletableFuture<org.apache.hadoop.fs.FSDataInputStream> openFileWithOptions(org.apache.hadoop.fs.Path rawPath, org.apache.hadoop.fs.impl.OpenFileParameters parameters) throws IOException Initiate the open() operation. This is invoked from both the FileSystem and FileContext APIs. It's declared as an audit entry point but the span creation is pushed down into the open operation s it ultimately calls.- Overrides:
openFileWithOptionsin classorg.apache.hadoop.fs.FileSystem- Parameters:
rawPath- path to the fileparameters- open file parameters from the builder.- Returns:
- a future which will evaluate to the opened file.
- Throws:
IOException- failure to resolve the link.IllegalArgumentException- unknown mandatory key
-
createMultipartUploader
@AuditEntryPoint public S3AMultipartUploaderBuilder createMultipartUploader(org.apache.hadoop.fs.Path basePath) throws IOException - Overrides:
createMultipartUploaderin classorg.apache.hadoop.fs.FileSystem- Throws:
IOException
-
createStoreContext
Build an immutable store context. If called while the FS is being initialized, some of the context will be incomplete. new store context instances should be created as appropriate.- Specified by:
createStoreContextin interfaceStoreContextFactory- Returns:
- the store context of this FS.
-
createMarkerToolOperations
@AuditEntryPoint @Private public MarkerToolOperations createMarkerToolOperations(String target) throws IOException Create a marker tools operations binding for this store. Auditing:- Parameters:
target- target path- Returns:
- callbacks for operations.
- Throws:
IOException- if raised during span creation
-
initializeClass
@Private public static void initializeClass()This is purely for testing, as it force initializes all static initializers. See HADOOP-17385 for details. -
isCSEEnabled
public boolean isCSEEnabled()a method to know if Client side encryption is enabled or not.- Returns:
- a boolean stating if CSE is enabled.
-
isMultipartUploadEnabled
public boolean isMultipartUploadEnabled() -
createBulkDelete
public org.apache.hadoop.fs.BulkDelete createBulkDelete(org.apache.hadoop.fs.Path path) throws IllegalArgumentException, IOException S3A implementation to create a bulk delete operation using which actual bulk delete calls can be made.- Specified by:
createBulkDeletein interfaceorg.apache.hadoop.fs.BulkDeleteSource- Overrides:
createBulkDeletein classorg.apache.hadoop.fs.FileSystem- Returns:
- an implementation of the bulk delete.
- Throws:
IllegalArgumentExceptionIOException
-
createBulkDeleteCallbacks
protected BulkDeleteOperation.BulkDeleteOperationCallbacks createBulkDeleteCallbacks(org.apache.hadoop.fs.Path path, int pageSize, AuditSpanS3A span) Create the callbacks for the bulk delete operation.- Parameters:
path- path to delete.pageSize- page size.span- span for operations.- Returns:
- an instance of the Bulk Delete callbacks.
-