Class AzureFileSystem

java.lang.Object
java.nio.file.FileSystem
com.azure.storage.blob.nio.AzureFileSystem
All Implemented Interfaces:
Closeable, AutoCloseable

public final class AzureFileSystem extends FileSystem
Implement's Java's FileSystem interface for Azure Blob Storage.

The following behavior is specific to this FileSystem:

In the hierarchy of this file system, an AzureFileSystem corresponds to an Azure Blob Storage account. A file store is represented by a container in the storage account. Each container has one root directory.

Closing the file system will not block on outstanding operations. Any operations in progress will be allowed to terminate naturally after the file system is closed, though no further operations may be started after the parent file system is closed.

All instance of AzureFileSystem are opened for read-write access.

For a more complete description of the uses for the constants described here, please see the instructions for opening and configuring a FileSystem in the docs of FileSystemProvider.

  • Field Details

    • AZURE_STORAGE_SHARED_KEY_CREDENTIAL

      public static final String AZURE_STORAGE_SHARED_KEY_CREDENTIAL
      Expected type: String
      See Also:
    • AZURE_STORAGE_SAS_TOKEN_CREDENTIAL

      public static final String AZURE_STORAGE_SAS_TOKEN_CREDENTIAL
      Expected type: String
      See Also:
    • AZURE_STORAGE_HTTP_LOG_DETAIL_LEVEL

      public static final String AZURE_STORAGE_HTTP_LOG_DETAIL_LEVEL
      Expected type: com.azure.core.http.policy.HttpLogLevelDetail
      See Also:
    • AZURE_STORAGE_MAX_TRIES

      public static final String AZURE_STORAGE_MAX_TRIES
      Expected type: Integer
      See Also:
    • AZURE_STORAGE_TRY_TIMEOUT

      public static final String AZURE_STORAGE_TRY_TIMEOUT
      Expected type: Integer
      See Also:
    • AZURE_STORAGE_RETRY_DELAY_IN_MS

      public static final String AZURE_STORAGE_RETRY_DELAY_IN_MS
      Expected type: Long
      See Also:
    • AZURE_STORAGE_MAX_RETRY_DELAY_IN_MS

      public static final String AZURE_STORAGE_MAX_RETRY_DELAY_IN_MS
      Expected type: Long
      See Also:
    • AZURE_STORAGE_RETRY_POLICY_TYPE

      public static final String AZURE_STORAGE_RETRY_POLICY_TYPE
      Expected type: com.azure.storage.common.policy.RetryPolicyType
      See Also:
    • AZURE_STORAGE_SECONDARY_HOST

      public static final String AZURE_STORAGE_SECONDARY_HOST
      Expected type: String
      See Also:
    • AZURE_STORAGE_UPLOAD_BLOCK_SIZE

      public static final String AZURE_STORAGE_UPLOAD_BLOCK_SIZE
      Expected type: Long
      See Also:
    • AZURE_STORAGE_MAX_CONCURRENCY_PER_REQUEST

      public static final String AZURE_STORAGE_MAX_CONCURRENCY_PER_REQUEST
      Expected type: Integer
      See Also:
    • AZURE_STORAGE_PUT_BLOB_THRESHOLD

      public static final String AZURE_STORAGE_PUT_BLOB_THRESHOLD
      Expected type: Long
      See Also:
    • AZURE_STORAGE_DOWNLOAD_RESUME_RETRIES

      public static final String AZURE_STORAGE_DOWNLOAD_RESUME_RETRIES
      Expected type: Integer
      See Also:
    • AZURE_STORAGE_FILE_STORES

      public static final String AZURE_STORAGE_FILE_STORES
      Expected type: String
      See Also:
    • AZURE_STORAGE_SKIP_INITIAL_CONTAINER_CHECK

      public static final String AZURE_STORAGE_SKIP_INITIAL_CONTAINER_CHECK
      Expected type: Boolean
      See Also:
  • Method Details

    • provider

      public FileSystemProvider provider()
      Returns the provider that created this file system.
      Specified by:
      provider in class FileSystem
      Returns:
      the provider that created this file system.
    • close

      public void close() throws IOException
      Closes this file system.

      After a file system is closed then all subsequent access to the file system, either by methods defined by this class or on objects associated with this file system, throw ClosedFileSystemException. If the file system is already closed then invoking this method has no effect.

      Closing the file system will not block on outstanding operations. Any operations in progress will be allowed to terminate naturally after the file system is closed, though no further operations may be started after the parent file system is closed.

      Once closed, a file system with the same identifier as the one closed may be re-opened.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class FileSystem
      Throws:
      IOException - If an I/O error occurs.
    • isOpen

      public boolean isOpen()
      Tells whether this file system is open.
      Specified by:
      isOpen in class FileSystem
      Returns:
      whether this file system is open.
    • isReadOnly

      public boolean isReadOnly()
      Tells whether this file system allows only read-only access to its file stores.

      Always returns false. It may be the case that the authentication method provided to this file system only supports read operations and hence the file system is implicitly read only in this view, but that does not imply the underlying account/file system is inherently read only. Creating/specifying read only file systems is not supported.

      Specified by:
      isReadOnly in class FileSystem
      Returns:
      false
    • getSeparator

      public String getSeparator()
      Returns the name separator, represented as a string.

      The separator used in this file system is "/".

      Specified by:
      getSeparator in class FileSystem
      Returns:
      "/"
    • getRootDirectories

      public Iterable<Path> getRootDirectories()
      Returns an object to iterate over the paths of the root directories.

      The list of root directories corresponds to the list of available file stores and therefore containers specified upon initialization. A root directory always takes the form "<file-store-name>:". This list will respect the parameters provided during initialization.

      If a finite list of containers was provided on start up, this list will not change during the lifetime of this object. If containers are added to the account after initialization, they will be ignored. If a container is deleted or otherwise becomes unavailable, its root directory will still be returned but operations to it will fail.

      Specified by:
      getRootDirectories in class FileSystem
      Returns:
      an object to iterate over the paths of the root directories
    • getFileStores

      public Iterable<FileStore> getFileStores()
      Returns an object to iterate over the underlying file stores

      This list will respect the parameters provided during initialization.

      If a finite list of containers was provided on start up, this list will not change during the lifetime of this object. If containers are added to the account after initialization, they will be ignored. If a container is deleted or otherwise becomes unavailable, its root directory will still be returned but operations to it will fail.

      Specified by:
      getFileStores in class FileSystem
    • supportedFileAttributeViews

      public Set<String> supportedFileAttributeViews()
      Returns the set of the names of the file attribute views supported by this FileSystem.

      This file system supports the following views:

      Specified by:
      supportedFileAttributeViews in class FileSystem
    • getPath

      public Path getPath(String first, String... more)
      Converts a path string, or a sequence of more that when joined form a path string, to a Path.

      If more does not specify any elements then the value of the first parameter is the path string to convert. If more specifies one or more elements than each non-empty string, including first, is considered to be a sequence of name elements (see Path) and is joined to form a path string. The more will be joined using the name separator.

      Each name element will be String-joined to the other elements by this file system's first path separator. Naming conventions and allowed characters are as defined by the Azure Blob Storage service. The root component is interpreted as the container name and all name elements are interpreted as a part of the blob name. The character ':' is only allowed in the root component and must be the last character of the root component.

      Specified by:
      getPath in class FileSystem
      Parameters:
      first - the path string or initial part of the path string
      more - additional strings to be joined to form the path string
      Throws:
      InvalidPathException - if the path string cannot be converted.
    • getPathMatcher

      Unsupported.
      Specified by:
      getPathMatcher in class FileSystem
      Parameters:
      s - the matcher
      Throws:
      UnsupportedOperationException - unsupported.
      IllegalArgumentException - never
      PatternSyntaxException - never
    • getUserPrincipalLookupService

      public UserPrincipalLookupService getUserPrincipalLookupService()
      Unsupported.
      Specified by:
      getUserPrincipalLookupService in class FileSystem
      Throws:
      UnsupportedOperationException - unsupported.
    • newWatchService

      public WatchService newWatchService() throws IOException
      Unsupported.
      Specified by:
      newWatchService in class FileSystem
      Throws:
      UnsupportedOperationException - unsupported.
      IOException - Never thrown.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object