Package alluxio.util
Class UnderFileSystemUtils
- java.lang.Object
-
- alluxio.util.UnderFileSystemUtils
-
@ThreadSafe public final class UnderFileSystemUtils extends java.lang.Object
Utility functions for working withUnderFileSystem
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
approximateContentHash(long length, long modTime)
Returns an approximate content hash, using the length and modification time.static void
deleteDirIfExists(UnderFileSystem ufs, java.lang.String path)
Deletes the directory at the given path if it exists.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.static java.lang.String
getBucketName(AlluxioURI uri)
static boolean
isCephFS(UnderFileSystem ufs)
static boolean
isGcs(UnderFileSystem ufs)
static boolean
isHdfs(UnderFileSystem ufs)
static boolean
isLocal(UnderFileSystem ufs)
static boolean
isOss(UnderFileSystem ufs)
static boolean
isS3(UnderFileSystem ufs)
static boolean
isSwift(UnderFileSystem ufs)
static boolean
isWeb(UnderFileSystem ufs)
static void
mkdirIfNotExists(UnderFileSystem ufs, java.lang.String path)
Attempts to create the directory if it does not already exist.static void
touch(UnderFileSystem ufs, java.lang.String path)
Creates an empty file.
-
-
-
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 ofUnderFileSystem
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 ofUnderFileSystem
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 ofUnderFileSystem
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 ofUnderFileSystem
path
- the path to delete
-
isGcs
public static boolean isGcs(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is a Google cloud store implementation
-
isLocal
public static boolean isLocal(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is a local file system implementation
-
isHdfs
public static boolean isHdfs(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is a Hadoop distributed file system implementation
-
isOss
public static boolean isOss(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is an Object storage service implementation
-
isS3
public static boolean isS3(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is an S3 implementation
-
isSwift
public static boolean isSwift(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is a Swift storage implementation
-
isWeb
public static boolean isWeb(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
implementation to check- Returns:
- true if the implementation is a Http implementation
-
isCephFS
public static boolean isCephFS(UnderFileSystem ufs)
- Parameters:
ufs
- theUnderFileSystem
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 lengthmodTime
- the content last modification time- Returns:
- the content hash
-
-