Package org.apache.hadoop.fs.azurebfs
Class AzureBlobFileSystemStore
java.lang.Object
org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.fs.azurebfs.services.ListingSupport
@Public
@Evolving
public class AzureBlobFileSystemStore
extends Object
implements Closeable, org.apache.hadoop.fs.azurebfs.services.ListingSupport
Provides the bridging logic between Hadoop's abstract filesystem and Azure Storage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classorg.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.AzureBlobFileSystemStoreBuilderA builder class for AzureBlobFileSystemStore.static final classorg.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.PermissionsPermissions class contain provided permission and umask in octalNotation. -
Constructor Summary
ConstructorsConstructorDescriptionAzureBlobFileSystemStore(org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.AzureBlobFileSystemStoreBuilder abfsStoreBuilder) FileSystem Store forAzureBlobFileSystemfor Abfs operations. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidbreakLease(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) Break any current lease on an ABFS file.voidclose()voidcreateDirectory(Path path, FsPermission permission, FsPermission umask, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) Creates a directory.createFile(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, boolean overwrite, FsPermission permission, FsPermission umask, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidcreateFilesystem(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) createNonRecursive(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, boolean overwrite, FsPermission permission, FsPermission umask, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) Checks existence of parent of the given path.voiddelete(Path path, boolean recursive, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voiddeleteFilesystem(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) static StringextractEtagHeader(org.apache.hadoop.fs.azurebfs.services.AbfsHttpOperation result) Get the etag header from a response, stripping any quotations.org.apache.hadoop.fs.azurebfs.AbfsConfigurationgetAclStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) org.apache.hadoop.fs.azurebfs.services.AbfsClientorg.apache.hadoop.fs.azurebfs.services.AbfsClientgetClient(AbfsServiceType serviceType) org.apache.hadoop.fs.azurebfs.services.AbfsClientHandlergetFileStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) getFilesystemProperties(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) booleangetIsNamespaceEnabled(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) Resolves namespace information of the filesystem from the state ofisNamespaceEnabled().getPathStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) getRelativePath(Path path) getUri()getUser()booleanisAppendBlobKey(String key) Checks if the given key in Azure Storage should be stored as a page blob instead of block blob.booleanisInfiniteLeaseKey(String key) listStatus(Path path, String startFrom, List<FileStatus> fileStatuses, boolean fetchAll, String continuation, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) listStatus(Path path, String startFrom, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) listStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidmodifyAclEntries(Path path, List<AclEntry> aclSpec, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) org.apache.hadoop.fs.azurebfs.services.AbfsInputStreamopenFileForRead(Path path, Optional<org.apache.hadoop.fs.impl.OpenFileParameters> parameters, org.apache.hadoop.fs.FileSystem.Statistics statistics, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) org.apache.hadoop.fs.azurebfs.services.AbfsInputStreamopenFileForRead(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) openFileForWrite(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, boolean overwrite, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidvoidremoveAclEntries(Path path, List<AclEntry> aclSpec, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidremoveDefaultAcl(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) booleanrename(Path source, Path destination, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext, String sourceEtag) Rename a file or directory.voidRestricts all service types to BLOB when FNS account detected Updates the client to reflect the new default service type.voidsetAcl(Path path, List<AclEntry> aclSpec, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidsetFilesystemProperties(Hashtable<String, String> properties, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidsetOwner(Path path, String owner, String group, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidsetPathProperties(Path path, Hashtable<String, String> properties, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) voidsetPermission(Path path, FsPermission permission, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext)
-
Constructor Details
-
AzureBlobFileSystemStore
public AzureBlobFileSystemStore(org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.AzureBlobFileSystemStoreBuilder abfsStoreBuilder) throws IOException FileSystem Store forAzureBlobFileSystemfor Abfs operations. Built using theAzureBlobFileSystemStore.AzureBlobFileSystemStoreBuilderwith parameters required.- Parameters:
abfsStoreBuilder- Builder for AzureBlobFileSystemStore.- Throws:
IOException- Throw IOE in case of failure during constructing.
-
-
Method Details
-
isAppendBlobKey
Checks if the given key in Azure Storage should be stored as a page blob instead of block blob.- Parameters:
key- The key to check.- Returns:
- True if the key should be stored as a page blob, false otherwise.
-
getUser
- Returns:
- local user name.
-
getPrimaryGroup
- Returns:
- primary group that user belongs to.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getIsNamespaceEnabled
public boolean getIsNamespaceEnabled(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException Resolves namespace information of the filesystem from the state ofisNamespaceEnabled(). if the state is UNKNOWN, it will be determined by making a GET_ACL request to the root of the filesystem. GET_ACL call is synchronized to ensure a single call is made to determine the namespace information in case multiple threads are calling this method at the same time. The resolution of namespace information would be stored back assetNamespaceEnabled(boolean).- Parameters:
tracingContext- tracing context- Returns:
- true if namespace is enabled, false otherwise.
- Throws:
AzureBlobFileSystemException- server errors.
-
getAbfsConfiguration
public org.apache.hadoop.fs.azurebfs.AbfsConfiguration getAbfsConfiguration() -
getFilesystemProperties
public Hashtable<String,String> getFilesystemProperties(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
setFilesystemProperties
public void setFilesystemProperties(Hashtable<String, String> properties, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException- Throws:
AzureBlobFileSystemException
-
getPathStatus
public Hashtable<String,String> getPathStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
setPathProperties
public void setPathProperties(Path path, Hashtable<String, String> properties, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException- Throws:
IOException
-
createFilesystem
public void createFilesystem(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
deleteFilesystem
public void deleteFilesystem(org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
createNonRecursive
public OutputStream createNonRecursive(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, boolean overwrite, FsPermission permission, FsPermission umask, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException Checks existence of parent of the given path.- Parameters:
path- Path to check.statistics- FileSystem statistics.overwrite- Overwrite flag.permission- Permission of tha path.umask- Umask of the path.tracingContext- tracing context- Returns:
- OutputStream output stream of the created file.
- Throws:
IOException- if there is an issue with the operation.
-
createFile
public OutputStream createFile(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, boolean overwrite, FsPermission permission, FsPermission umask, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
createDirectory
public void createDirectory(Path path, FsPermission permission, FsPermission umask, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException Creates a directory.- Parameters:
path- Path of the directory to create.permission- Permission of the directory.umask- Umask of the directory.tracingContext- tracing context- Throws:
AzureBlobFileSystemException- server error.IOException
-
openFileForRead
public org.apache.hadoop.fs.azurebfs.services.AbfsInputStream openFileForRead(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
openFileForRead
public org.apache.hadoop.fs.azurebfs.services.AbfsInputStream openFileForRead(Path path, Optional<org.apache.hadoop.fs.impl.OpenFileParameters> parameters, org.apache.hadoop.fs.FileSystem.Statistics statistics, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
openFileForWrite
public OutputStream openFileForWrite(Path path, org.apache.hadoop.fs.FileSystem.Statistics statistics, boolean overwrite, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
breakLease
public void breakLease(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException Break any current lease on an ABFS file.- Parameters:
path- file nametracingContext- TracingContext instance to track correlation IDs- Throws:
AzureBlobFileSystemException- on any exception while breaking the lease
-
rename
public boolean rename(Path source, Path destination, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext, String sourceEtag) throws IOException Rename a file or directory. If a source etag is passed in, the operation will attempt to recover from a missing source file by probing the destination for existence and comparing etags.- Parameters:
source- path to source filedestination- destination of rename.tracingContext- trace contextsourceEtag- etag of source file. may be null or empty- Returns:
- true if recovery was needed and succeeded.
- Throws:
AzureBlobFileSystemException- failure, excluding any recovery from overload failures.IOException
-
delete
public void delete(Path path, boolean recursive, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
getFileStatus
public FileStatus getFileStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
listStatus
public FileStatus[] listStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Specified by:
listStatusin interfaceorg.apache.hadoop.fs.azurebfs.services.ListingSupport- Parameters:
path- The list path.tracingContext- Tracks identifiers for request header- Returns:
- the entries in the path.
- Throws:
IOException- in case of error
-
listStatus
@Unstable public FileStatus[] listStatus(Path path, String startFrom, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Specified by:
listStatusin interfaceorg.apache.hadoop.fs.azurebfs.services.ListingSupport- Parameters:
path- Path the list path.startFrom- the entry name that list results should start with. For example, if folder "/folder" contains four files: "afile", "bfile", "hfile", "ifile". Then listStatus(Path("/folder"), "hfile") will return "/folder/hfile" and "folder/ifile" Notice that if startFrom is a non-existent entry name, then the list response contains all entries after this non-existent entry in lexical order: listStatus(Path("/folder"), "cfile") will return "/folder/hfile" and "/folder/ifile".tracingContext- Tracks identifiers for request header- Returns:
- the entries in the path start from "startFrom" in lexical order.
- Throws:
IOException- in case of error
-
listStatus
public String listStatus(Path path, String startFrom, List<FileStatus> fileStatuses, boolean fetchAll, String continuation, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Specified by:
listStatusin interfaceorg.apache.hadoop.fs.azurebfs.services.ListingSupport- Parameters:
path- The list pathstartFrom- The entry name that list results should start with. For example, if folder "/folder" contains four files: "afile", "bfile", "hfile", "ifile". Then listStatus(Path("/folder"), "hfile") will return "/folder/hfile" and "folder/ifile" Notice that if startFrom is a non-existent entry name, then the list response contains all entries after this non-existent entry in lexical order: listStatus (Path("/folder"), "cfile") will return "/folder/hfile" and "/folder/ifile".fileStatuses- This list has to be filled with the FileStatus objectsfetchAll- flag to indicate if the above list needs to be filled with just one page os results or the entire result.continuation- Contiuation token. null means start rom the begining.tracingContext- TracingContext instance to track identifiers- Returns:
- Continuation token
- Throws:
IOException- in case of error
-
setOwner
public void setOwner(Path path, String owner, String group, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
setPermission
public void setPermission(Path path, FsPermission permission, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
modifyAclEntries
public void modifyAclEntries(Path path, List<AclEntry> aclSpec, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
removeAclEntries
public void removeAclEntries(Path path, List<AclEntry> aclSpec, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
removeDefaultAcl
public void removeDefaultAcl(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
removeAcl
public void removeAcl(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
setAcl
public void setAcl(Path path, List<AclEntry> aclSpec, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
getAclStatus
public AclStatus getAclStatus(Path path, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws IOException - Throws:
IOException
-
access
public void access(Path path, FsAction mode, org.apache.hadoop.fs.azurebfs.utils.TracingContext tracingContext) throws AzureBlobFileSystemException - Throws:
AzureBlobFileSystemException
-
isInfiniteLeaseKey
-
getRelativePath
-
restrictServiceTypeToBlob
public void restrictServiceTypeToBlob()Restricts all service types to BLOB when FNS account detected Updates the client to reflect the new default service type. -
getClient
@VisibleForTesting public org.apache.hadoop.fs.azurebfs.services.AbfsClient getClient() -
getClient
@VisibleForTesting public org.apache.hadoop.fs.azurebfs.services.AbfsClient getClient(AbfsServiceType serviceType) -
getClientHandler
@VisibleForTesting public org.apache.hadoop.fs.azurebfs.services.AbfsClientHandler getClientHandler() -
getUri
-
extractEtagHeader
public static String extractEtagHeader(org.apache.hadoop.fs.azurebfs.services.AbfsHttpOperation result) Get the etag header from a response, stripping any quotations. see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag- Parameters:
result- response to process.- Returns:
- the quote-unwrapped etag.
-