Package alluxio.util

Class UnderFileSystemUtils


  • @ThreadSafe
    public final class UnderFileSystemUtils
    extends java.lang.Object
    Utility functions for working with UnderFileSystem.
    • Method Detail

      • deleteDirIfExists

        public static void deleteDirIfExists​(UnderFileSystem ufs,
                                             java.lang.String path)
                                      throws java.io.IOException
        Deletes the directory at the given path if it exists.
        Parameters:
        ufs - instance of UnderFileSystem
        path - path to the directory
        Throws:
        java.io.IOException
      • mkdirIfNotExists

        public static void mkdirIfNotExists​(UnderFileSystem ufs,
                                            java.lang.String path)
                                     throws java.io.IOException
        Attempts to create the directory if it does not already exist.
        Parameters:
        ufs - instance of UnderFileSystem
        path - path to the directory
        Throws:
        java.io.IOException
      • touch

        public static void touch​(UnderFileSystem ufs,
                                 java.lang.String path)
                          throws java.io.IOException
        Creates an empty file.
        Parameters:
        ufs - instance of UnderFileSystem
        path - path to the file
        Throws:
        java.io.IOException
      • deleteFileIfExists

        public static void deleteFileIfExists​(UnderFileSystem ufs,
                                              java.lang.String path)
        Deletes the specified path from the specified under file system if it is a file and exists.
        Parameters:
        ufs - instance of UnderFileSystem
        path - the path to delete
      • isGcs

        public static boolean isGcs​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is a Google cloud store implementation
      • isLocal

        public static boolean isLocal​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is a local file system implementation
      • isHdfs

        public static boolean isHdfs​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is a Hadoop distributed file system implementation
      • isOss

        public static boolean isOss​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is an Object storage service implementation
      • isS3

        public static boolean isS3​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is an S3 implementation
      • isSwift

        public static boolean isSwift​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is a Swift storage implementation
      • isWeb

        public static boolean isWeb​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is a Http implementation
      • isCephFS

        public static boolean isCephFS​(UnderFileSystem ufs)
        Parameters:
        ufs - the UnderFileSystem implementation to check
        Returns:
        true if the implementation is a Cephfs storage implementation
      • getBucketName

        public static java.lang.String getBucketName​(AlluxioURI uri)
        Parameters:
        uri - the UFS path
        Returns:
        the bucket or container name of the object storage
      • approximateContentHash

        public static java.lang.String approximateContentHash​(long length,
                                                              long modTime)
        Returns an approximate content hash, using the length and modification time.
        Parameters:
        length - the content length
        modTime - the content last modification time
        Returns:
        the content hash