Interface UnderFileSystem
-
- All Superinterfaces:
AsyncUfsClient
,java.lang.AutoCloseable
,java.io.Closeable
- All Known Subinterfaces:
AtomicFileOutputStreamCallback
- All Known Implementing Classes:
BaseUnderFileSystem
,ConsistentUnderFileSystem
,ManagedBlockingUfsForwarder
,ObjectUnderFileSystem
,UnderFileSystemWithLogging
@PublicApi @ThreadSafe public interface UnderFileSystem extends java.io.Closeable, AsyncUfsClient
Alluxio stores data into an under layer file system. Any file system implementing this interface can be a valid under layer file system. There are two sets of APIs in the under file system: (1) normal operations (e.g. create, renameFile, deleteFile) (2) operations deal with the eventual consistency issue (e.g. createNonexistingFile, renameRenamableFile) When confirmed by Alluxio metadata that an operation should succeed but may fail because of the under filesystem eventual consistency issue, use the second set of APIs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
UnderFileSystem.Factory
The factory for theUnderFileSystem
.static class
UnderFileSystem.SpaceType
The different types of space indicate the total space, the free space and the space used in the under file system.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
cleanup()
Cleans up the under file system.void
connectFromMaster(java.lang.String hostname)
Takes any necessary actions required to establish a connection to the under file system from the given master host e.g.void
connectFromWorker(java.lang.String hostname)
Takes any necessary actions required to establish a connection to the under file system from the given worker host e.g.java.io.OutputStream
create(java.lang.String path)
Creates a file in the under file system with the indicated name.java.io.OutputStream
create(java.lang.String path, CreateOptions options)
Creates a file in the under file system with the specifiedCreateOptions
.java.io.OutputStream
createNonexistingFile(java.lang.String path)
Creates a file in the under file system with the indicated name.java.io.OutputStream
createNonexistingFile(java.lang.String path, CreateOptions options)
Creates a file in the under file system with the specifiedCreateOptions
.boolean
deleteDirectory(java.lang.String path)
Deletes a directory from the under file system with the indicated name non-recursively.boolean
deleteDirectory(java.lang.String path, DeleteOptions options)
Deletes a directory from the under file system with the indicated name.boolean
deleteExistingDirectory(java.lang.String path)
Deletes a directory from the under file system.boolean
deleteExistingDirectory(java.lang.String path, DeleteOptions options)
Deletes a directory from the under file system with the indicated name.boolean
deleteExistingFile(java.lang.String path)
Deletes a file from the under file system with the indicated name.boolean
deleteFile(java.lang.String path)
Deletes a file from the under file system with the indicated name.boolean
exists(java.lang.String path)
Checks if a file or directory exists in under file system.Pair<AccessControlList,DefaultAccessControlList>
getAclPair(java.lang.String path)
Gets the ACL and the Default ACL of a file or directory in under file system.SyncInfo
getActiveSyncInfo()
Return the active sync info for the specified syncPoints.long
getBlockSizeByte(java.lang.String path)
Deprecated.block size should be returned as part of theUfsFileStatus
fromgetFileStatus(String)
orgetExistingFileStatus(String)
default AlluxioConfiguration
getConfiguration()
Gets the under file system configuration.UfsDirectoryStatus
getDirectoryStatus(java.lang.String path)
Gets the directory status.UfsDirectoryStatus
getExistingDirectoryStatus(java.lang.String path)
Gets the directory status.UfsFileStatus
getExistingFileStatus(java.lang.String path)
Gets the file status.UfsStatus
getExistingStatus(java.lang.String path)
Gets the file or directory status.java.util.List<java.lang.String>
getFileLocations(java.lang.String path)
Gets the list of locations of the indicated path.java.util.List<java.lang.String>
getFileLocations(java.lang.String path, FileLocationOptions options)
Gets the list of locations of the indicated path given options.default UfsFileStatus
getFileStatus(java.lang.String path)
Gets the file status.UfsFileStatus
getFileStatus(java.lang.String path, GetStatusOptions options)
Gets the file status.java.lang.String
getFingerprint(java.lang.String path)
Deprecated.UfsMode
getOperationMode(java.util.Map<java.lang.String,UfsMode> physicalUfsState)
AnUnderFileSystem
may be composed of one or more "physical UFS"s.Fingerprint
getParsedFingerprint(java.lang.String path)
Computes and returns a fingerprint for the path.Fingerprint
getParsedFingerprint(java.lang.String path, java.lang.String contentHash)
Same asgetParsedFingerprint(String)
except, will use the given content hash as theFingerprint.Tag.CONTENT_HASH
field of the fingerprint if non-null.java.util.List<java.lang.String>
getPhysicalStores()
AnUnderFileSystem
may be composed of one or more "physical UFS"s.long
getSpace(java.lang.String path, UnderFileSystem.SpaceType type)
Queries the under file system about the space of the indicated path (e.g., space left, space used and etc).default UfsStatus
getStatus(java.lang.String path)
Gets the file or directory status.UfsStatus
getStatus(java.lang.String path, GetStatusOptions options)
Gets the file or directory status.default byte[]
getTemporaryToken(java.lang.String path, java.lang.String sid, java.lang.String effect, Mode.Bits action)
Gets a temporary token according to path, sid, effect and action.java.lang.String
getUnderFSType()
Returns the name of the under filesystem implementation.boolean
isDirectory(java.lang.String path)
Checks if a directory exists in under file system.boolean
isExistingDirectory(java.lang.String path)
Checks if a directory exists in under file system.boolean
isFile(java.lang.String path)
Checks if a file exists in under file system.boolean
isObjectStorage()
boolean
isSeekable()
Denotes if the under storage supports seeking.default boolean
isTemporaryConnectionToken()
Denotes if the under storage is in the temporary connection token mode.UfsStatus[]
listStatus(java.lang.String path)
Returns an array of statuses of the files and directories in the directory denoted by this abstract pathname.UfsStatus[]
listStatus(java.lang.String path, ListOptions options)
Returns an array of statuses of the files and directories in the directory denoted by this abstract pathname, with options.default java.util.Optional<UfsStatus[]>
listStatuses(java.lang.String path, ListOptions options)
Returns an array of statuses of the files and directories in the directory denoted by this abstract pathname, with options.java.util.Iterator<UfsStatus>
listStatusIterable(java.lang.String path, ListOptions options, java.lang.String startAfter, int batchSize)
Lists the ufs statuses iteratively.boolean
mkdirs(java.lang.String path)
Creates the directory named by this abstract pathname.boolean
mkdirs(java.lang.String path, MkdirsOptions options)
Creates the directory named by this abstract pathname, with specifiedMkdirsOptions
.java.io.InputStream
open(java.lang.String path)
Opens anInputStream
for a file in under filesystem at the indicated path.java.io.InputStream
open(java.lang.String path, OpenOptions options)
Opens anInputStream
for a file in under filesystem at the indicated path.java.io.InputStream
openExistingFile(java.lang.String path)
Opens anInputStream
for a file in under filesystem at the indicated path.java.io.InputStream
openExistingFile(java.lang.String path, OpenOptions options)
Opens anInputStream
for a file in under filesystem at the indicated path.PositionReader
openPositionRead(java.lang.String path, long fileLength)
Opens a file for position read.default byte[]
refreshTemporaryToken(byte[] oldTemporaryToken)
Refreshes the old temporary token.boolean
renameDirectory(java.lang.String src, java.lang.String dst)
Renames a directory fromsrc
todst
in under file system.boolean
renameFile(java.lang.String src, java.lang.String dst)
Renames a file fromsrc
todst
in under file system.boolean
renameRenamableDirectory(java.lang.String src, java.lang.String dst)
Renames a directory fromsrc
todst
in under file system.boolean
renameRenamableFile(java.lang.String src, java.lang.String dst)
Renames a file fromsrc
todst
in under file system.AlluxioURI
resolveUri(AlluxioURI ufsBaseUri, java.lang.String alluxioPath)
Returns anAlluxioURI
representation for theUnderFileSystem
given a base UFS URI, and the Alluxio path from the base.void
setAclEntries(java.lang.String path, java.util.List<AclEntry> aclEntries)
Sets the access control list of a file or directory in under file system.void
setMode(java.lang.String path, short mode)
Changes posix file mode.void
setOwner(java.lang.String path, java.lang.String owner, java.lang.String group)
Sets the user and group of the given path.default void
setTemporaryTokenRefreshContext(UserState userState)
Sets the userState to UFS instance.boolean
startActiveSyncPolling(long txId)
Start Active Sync.void
startSync(AlluxioURI uri)
Add Sync Point.boolean
stopActiveSyncPolling()
Stop Active Sync.void
stopSync(AlluxioURI uri)
Stop Sync Point.boolean
supportsActiveSync()
Whether this type of UFS supports active sync.boolean
supportsFlush()
Whether this type of UFS supports flush.-
Methods inherited from interface alluxio.underfs.AsyncUfsClient
performListingAsync
-
-
-
-
Method Detail
-
cleanup
void cleanup() throws java.io.IOException
Cleans up the under file system. If any data or files are created and not completed/aborted correctly in normal ways, they should be cleaned in this method.- Throws:
java.io.IOException
-
connectFromMaster
void connectFromMaster(java.lang.String hostname) throws java.io.IOException
Takes any necessary actions required to establish a connection to the under file system from the given master host e.g. logging inDepending on the implementation this may be a no-op
- Parameters:
hostname
- the host that wants to connect to the under file system- Throws:
java.io.IOException
-
connectFromWorker
void connectFromWorker(java.lang.String hostname) throws java.io.IOException
Takes any necessary actions required to establish a connection to the under file system from the given worker host e.g. logging inDepending on the implementation this may be a no-op
- Parameters:
hostname
- the host that wants to connect to the under file system- Throws:
java.io.IOException
-
create
java.io.OutputStream create(java.lang.String path) throws java.io.IOException
Creates a file in the under file system with the indicated name. Parents directories will be created recursively.- Parameters:
path
- the file name- Returns:
- A
OutputStream
object - Throws:
java.io.IOException
-
create
java.io.OutputStream create(java.lang.String path, CreateOptions options) throws java.io.IOException
Creates a file in the under file system with the specifiedCreateOptions
. Implementations should make sure that the path under creation appears in listings only after a successful close and that contents are written in its entirety or not at all.- Parameters:
path
- the file nameoptions
- the options for create- Returns:
- A
OutputStream
object - Throws:
java.io.IOException
-
createNonexistingFile
java.io.OutputStream createNonexistingFile(java.lang.String path) throws java.io.IOException
Creates a file in the under file system with the indicated name. Similar tocreate(String)
but deals with the delete-then-create eventual consistency issue.- Parameters:
path
- the file name- Returns:
- A
OutputStream
object - Throws:
java.io.IOException
-
createNonexistingFile
java.io.OutputStream createNonexistingFile(java.lang.String path, CreateOptions options) throws java.io.IOException
Creates a file in the under file system with the specifiedCreateOptions
. Similar tocreate(String, CreateOptions)
but deals with the delete-then-create eventual consistency issue.- Parameters:
path
- the file nameoptions
- the options for create- Returns:
- A
OutputStream
object - Throws:
java.io.IOException
-
deleteDirectory
boolean deleteDirectory(java.lang.String path) throws java.io.IOException
Deletes a directory from the under file system with the indicated name non-recursively. A non-recursive delete is successful only if the directory is empty.- Parameters:
path
- of the directory to delete- Returns:
- true if directory was found and deleted, false otherwise
- Throws:
java.io.IOException
-
deleteDirectory
boolean deleteDirectory(java.lang.String path, DeleteOptions options) throws java.io.IOException
Deletes a directory from the under file system with the indicated name.- Parameters:
path
- of the directory to deleteoptions
- for directory delete semantics- Returns:
- true if directory was found and deleted, false otherwise
- Throws:
java.io.IOException
-
deleteExistingDirectory
boolean deleteExistingDirectory(java.lang.String path) throws java.io.IOException
Deletes a directory from the under file system. Similar todeleteDirectory(String)
but deals with the create-delete eventual consistency issue.- Parameters:
path
- of the directory to delete- Returns:
- true if directory was found and deleted, false otherwise
- Throws:
java.io.IOException
-
deleteExistingDirectory
boolean deleteExistingDirectory(java.lang.String path, DeleteOptions options) throws java.io.IOException
Deletes a directory from the under file system with the indicated name. Similar todeleteDirectory(String, DeleteOptions)
but deals with the create-then-delete eventual consistency issue.- Parameters:
path
- of the directory to deleteoptions
- for directory delete semantics- Returns:
- true if directory was found and deleted, false otherwise
- Throws:
java.io.IOException
-
deleteFile
boolean deleteFile(java.lang.String path) throws java.io.IOException
Deletes a file from the under file system with the indicated name.- Parameters:
path
- of the file to delete- Returns:
- true if file was found and deleted, false otherwise
- Throws:
java.io.IOException
-
deleteExistingFile
boolean deleteExistingFile(java.lang.String path) throws java.io.IOException
Deletes a file from the under file system with the indicated name. Similar todeleteFile(String)
but deals with the create-then-delete eventual consistency issue.- Parameters:
path
- of the file to delete- Returns:
- true if file was found and deleted, false otherwise
- Throws:
java.io.IOException
-
exists
boolean exists(java.lang.String path) throws java.io.IOException
Checks if a file or directory exists in under file system.- Parameters:
path
- the absolute path- Returns:
- true if the path exists, false otherwise
- Throws:
java.io.IOException
-
getAclPair
@Nullable Pair<AccessControlList,DefaultAccessControlList> getAclPair(java.lang.String path) throws java.io.IOException
Gets the ACL and the Default ACL of a file or directory in under file system.- Parameters:
path
- the path to the file or directory- Returns:
- the access control list, along with a Default ACL if it is a directory return null if ACL is unsupported or disabled
- Throws:
java.io.IOException
- if ACL is supported and enabled but cannot be retrieved
-
getBlockSizeByte
@Deprecated long getBlockSizeByte(java.lang.String path) throws java.io.IOException
Deprecated.block size should be returned as part of theUfsFileStatus
fromgetFileStatus(String)
orgetExistingFileStatus(String)
Gets the block size of a file in under file system, in bytes.- Parameters:
path
- the file name- Returns:
- the block size in bytes
- Throws:
java.io.IOException
-
getConfiguration
default AlluxioConfiguration getConfiguration() throws java.io.IOException
Gets the under file system configuration.- Returns:
- the configuration
- Throws:
java.io.IOException
-
getDirectoryStatus
UfsDirectoryStatus getDirectoryStatus(java.lang.String path) throws java.io.IOException
Gets the directory status. The caller must already know the path is a directory. This method will throw an exception if the path exists, but is a file.- Parameters:
path
- the path to the directory- Returns:
- the directory status
- Throws:
java.io.FileNotFoundException
- when the path does not existjava.io.IOException
-
getExistingDirectoryStatus
UfsDirectoryStatus getExistingDirectoryStatus(java.lang.String path) throws java.io.IOException
Gets the directory status. Similar togetDirectoryStatus(String)
but deals with the write-then-get-status eventual consistency issue.- Parameters:
path
- the path to the directory- Returns:
- the directory status
- Throws:
java.io.IOException
-
getFileLocations
java.util.List<java.lang.String> getFileLocations(java.lang.String path) throws java.io.IOException
Gets the list of locations of the indicated path.- Parameters:
path
- the file name- Returns:
- The list of locations
- Throws:
java.io.IOException
-
getFileLocations
java.util.List<java.lang.String> getFileLocations(java.lang.String path, FileLocationOptions options) throws java.io.IOException
Gets the list of locations of the indicated path given options.- Parameters:
path
- the file nameoptions
- method options- Returns:
- The list of locations
- Throws:
java.io.IOException
-
getFileStatus
default UfsFileStatus getFileStatus(java.lang.String path) throws java.io.IOException
Gets the file status. The caller must already know the path is a file. This method will throw an exception if the path exists, but is a directory.- Parameters:
path
- the path to the file- Returns:
- the file status
- Throws:
java.io.FileNotFoundException
- when the path does not existjava.io.IOException
-
getFileStatus
UfsFileStatus getFileStatus(java.lang.String path, GetStatusOptions options) throws java.io.IOException
Gets the file status. The caller must already know the path is a file. This method will throw an exception if the path exists, but is a directory.- Parameters:
path
- the path to the fileoptions
- method options- Returns:
- the file status
- Throws:
java.io.FileNotFoundException
- when the path does not existjava.io.IOException
-
getExistingFileStatus
UfsFileStatus getExistingFileStatus(java.lang.String path) throws java.io.IOException
Gets the file status. Similar togetFileStatus(String)
but deals with the write-then-get-status eventual consistency issue.- Parameters:
path
- the path to the file- Returns:
- the file status
- Throws:
java.io.IOException
-
getFingerprint
@Deprecated java.lang.String getFingerprint(java.lang.String path)
Deprecated.Computes and returns a fingerprint for the path. The fingerprint is used to determine if two UFS files are identical. The fingerprint must be deterministic, and must not change if a file is only renamed (identical content and permissions). ReturnsConstants.INVALID_UFS_FINGERPRINT
if there is any error.- Parameters:
path
- the path to compute the fingerprint for- Returns:
- the string representing the fingerprint
-
getParsedFingerprint
Fingerprint getParsedFingerprint(java.lang.String path)
Computes and returns a fingerprint for the path. The fingerprint is used to determine if two UFS files are identical. The fingerprint must be deterministic, and must not change if a file is only renamed (identical content and permissions). ReturnsFingerprint.INVALID_FINGERPRINT
if there is any error. The default implementation relies ongetFingerprint(String)
and there is one extra parsing. This default implementation is mainly for backward compatibility. Override this for performance.- Parameters:
path
- the path to compute the fingerprint for- Returns:
- the string representing the fingerprint
-
getParsedFingerprint
Fingerprint getParsedFingerprint(java.lang.String path, @Nullable java.lang.String contentHash)
Same asgetParsedFingerprint(String)
except, will use the given content hash as theFingerprint.Tag.CONTENT_HASH
field of the fingerprint if non-null. This is intended to be used when the file is already in Alluxio and a fingerprint is being created based on that file where the content hash has already been computed.- Parameters:
path
- the path to compute the fingerprint forcontentHash
- is used as theFingerprint.Tag.CONTENT_HASH
field when creating the fingerprint.- Returns:
- the string representing the fingerprint
-
getOperationMode
UfsMode getOperationMode(java.util.Map<java.lang.String,UfsMode> physicalUfsState)
AnUnderFileSystem
may be composed of one or more "physical UFS"s. This method is used to determine the operation mode based on the physical UFS operation modes. For example, if thisUnderFileSystem
is composed of physical UFS hdfs://ns1/ and hdfs://ns2/ with read operations split b/w the two, with physicalUfsState{hdfs://ns1/:NO_ACCESS, hdfs://ns2/:READ_WRITE} this method can return READ_ONLY to allow reads to proceed from hdfs://ns2/.- Parameters:
physicalUfsState
- the state of physical UFSs for thisUnderFileSystem
; keys are expected to be normalized (ending with /)- Returns:
- the desired operation mode for this UFS
-
getPhysicalStores
java.util.List<java.lang.String> getPhysicalStores()
AnUnderFileSystem
may be composed of one or more "physical UFS"s. This method returns all underlying physical stores; normalized with only scheme and authority.- Returns:
- physical UFSs this
UnderFileSystem
is composed of
-
getSpace
long getSpace(java.lang.String path, UnderFileSystem.SpaceType type) throws java.io.IOException
Queries the under file system about the space of the indicated path (e.g., space left, space used and etc).- Parameters:
path
- the path to querytype
- the type of queries- Returns:
- The space in bytes
- Throws:
java.io.IOException
-
getStatus
default UfsStatus getStatus(java.lang.String path) throws java.io.IOException
Gets the file or directory status. The caller does not need to know if the path is a file or directory. This method will determine the path type, and will return the appropriate status.- Parameters:
path
- the path to get the status- Returns:
- the file or directory status
- Throws:
java.io.FileNotFoundException
- when the path does not existjava.io.IOException
-
getStatus
UfsStatus getStatus(java.lang.String path, GetStatusOptions options) throws java.io.IOException
Gets the file or directory status. The caller does not need to know if the path is a file or directory. This method will determine the path type, and will return the appropriate status.- Parameters:
path
- the path to get the statusoptions
- method options- Returns:
- the file or directory status
- Throws:
java.io.FileNotFoundException
- when the path does not existjava.io.IOException
-
getExistingStatus
UfsStatus getExistingStatus(java.lang.String path) throws java.io.IOException
Gets the file or directory status. Similar togetStatus(String)
but deals with the write-then-get-status eventual consistency issue.- Parameters:
path
- the path to get the status- Returns:
- the file or directory status
- Throws:
java.io.IOException
-
getUnderFSType
java.lang.String getUnderFSType()
Returns the name of the under filesystem implementation. The name should be lowercase and not include any spaces, e.g. "hdfs", "s3".- Returns:
- name of the under filesystem implementation
-
isDirectory
boolean isDirectory(java.lang.String path) throws java.io.IOException
Checks if a directory exists in under file system.- Parameters:
path
- the absolute directory path- Returns:
- true if the path exists and is a directory, false otherwise
- Throws:
java.io.IOException
-
isExistingDirectory
boolean isExistingDirectory(java.lang.String path) throws java.io.IOException
Checks if a directory exists in under file system. Similar toisDirectory(String)
but deals with the write-then-list eventual consistency issue.- Parameters:
path
- the absolute directory path- Returns:
- true if the path exists and is a directory, false otherwise
- Throws:
java.io.IOException
-
isFile
boolean isFile(java.lang.String path) throws java.io.IOException
Checks if a file exists in under file system.- Parameters:
path
- the absolute file path- Returns:
- true if the path exists and is a file, false otherwise
- Throws:
java.io.IOException
-
isObjectStorage
boolean isObjectStorage()
- Returns:
- true if under storage is an object store, false otherwise
-
isSeekable
boolean isSeekable()
Denotes if the under storage supports seeking. Note, the under file system subclass that returns true for this method should return the input stream extendingSeekableUnderFileInputStream
in theopen(String, OpenOptions)
method.- Returns:
- true if under storage is seekable, false otherwise
-
listStatus
@Nullable UfsStatus[] listStatus(java.lang.String path) throws java.io.IOException
Returns an array of statuses of the files and directories in the directory denoted by this abstract pathname.If this abstract pathname does not denote a directory, then this method returns
null
. Otherwise an array of statuses is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
- Parameters:
path
- the abstract pathname to list- Returns:
- An array with the statuses of the files and directories in the directory denoted by
this abstract pathname. The array will be empty if the directory is empty. Returns
null
if this abstract pathname does not denote a directory. - Throws:
java.io.IOException
-
listStatus
@Nullable UfsStatus[] listStatus(java.lang.String path, ListOptions options) throws java.io.IOException
Returns an array of statuses of the files and directories in the directory denoted by this abstract pathname, with options.If this abstract pathname does not denote a directory, then this method returns
null
. Otherwise an array of statuses is returned, one for each file or directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a path relative to the given directory.There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
- Parameters:
path
- the abstract pathname to listoptions
- for list directory- Returns:
- An array of statuses naming the files and directories in the directory denoted by this
abstract pathname. The array will be empty if the directory is empty. Returns
null
if this abstract pathname does not denote a directory. - Throws:
java.io.IOException
-
listStatusIterable
@Nullable java.util.Iterator<UfsStatus> listStatusIterable(java.lang.String path, ListOptions options, java.lang.String startAfter, int batchSize) throws java.io.IOException
Lists the ufs statuses iteratively.- Parameters:
path
- the abstract pathname to listoptions
- for list directorystartAfter
- the start after tokenbatchSize
- the batch size- Returns:
- An iterator of ufs status. Returns
null
if this abstract pathname does not denote a directory. - Throws:
java.io.IOException
-
listStatuses
default java.util.Optional<UfsStatus[]> listStatuses(java.lang.String path, ListOptions options) throws java.io.IOException
Returns an array of statuses of the files and directories in the directory denoted by this abstract pathname, with options.If this abstract pathname does not denote a directory, meaning it might be a file, then this method would try to call getStatus on the path. An array of statuses is returned, one for each file or directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a path relative to the given directory.
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
- Parameters:
path
- the abstract pathname to listoptions
- for list directory- Returns:
- An array of statuses naming the files and directories in the directory denoted by this
abstract pathname. The array will be empty if the directory is empty.
Or And array of single file if given path is a file.
Returns
Optional.empty()
if this abstract pathname does not denote a valid directory or file not found. - Throws:
java.io.IOException
-
mkdirs
boolean mkdirs(java.lang.String path) throws java.io.IOException
Creates the directory named by this abstract pathname. If the folder already exists, the method returns false. The method creates any necessary but nonexistent parent directories.- Parameters:
path
- the folder to create- Returns:
true
if and only if the directory was created;false
otherwise- Throws:
java.io.IOException
-
mkdirs
boolean mkdirs(java.lang.String path, MkdirsOptions options) throws java.io.IOException
Creates the directory named by this abstract pathname, with specifiedMkdirsOptions
. If the folder already exists, the method returns false.- Parameters:
path
- the folder to createoptions
- the options for mkdirs- Returns:
true
if and only if the directory was created;false
otherwise- Throws:
java.io.IOException
-
open
java.io.InputStream open(java.lang.String path) throws java.io.IOException
Opens anInputStream
for a file in under filesystem at the indicated path.- Parameters:
path
- the file name- Returns:
- The
InputStream
object - Throws:
java.io.IOException
-
open
java.io.InputStream open(java.lang.String path, OpenOptions options) throws java.io.IOException
Opens anInputStream
for a file in under filesystem at the indicated path.- Parameters:
path
- the file nameoptions
- to open input stream- Returns:
- The
InputStream
object - Throws:
java.io.IOException
-
openExistingFile
java.io.InputStream openExistingFile(java.lang.String path) throws java.io.IOException
Opens anInputStream
for a file in under filesystem at the indicated path. Similar toopen(String)
but deals with the write-then-read eventual consistency issue.- Parameters:
path
- the file name- Returns:
- The
InputStream
object - Throws:
java.io.IOException
-
openExistingFile
java.io.InputStream openExistingFile(java.lang.String path, OpenOptions options) throws java.io.IOException
Opens anInputStream
for a file in under filesystem at the indicated path. Similar toopen(String, OpenOptions)
but deals with the write-then-read eventual consistency issue.- Parameters:
path
- the file nameoptions
- to open input stream- Returns:
- The
InputStream
object - Throws:
java.io.IOException
-
openPositionRead
PositionReader openPositionRead(java.lang.String path, long fileLength)
Opens a file for position read.- Parameters:
path
- the path to readfileLength
- the file length- Returns:
- the position reader
-
renameDirectory
boolean renameDirectory(java.lang.String src, java.lang.String dst) throws java.io.IOException
Renames a directory fromsrc
todst
in under file system.- Parameters:
src
- the source directory pathdst
- the destination directory path- Returns:
- true if succeed, false otherwise
- Throws:
java.io.IOException
-
renameRenamableDirectory
boolean renameRenamableDirectory(java.lang.String src, java.lang.String dst) throws java.io.IOException
Renames a directory fromsrc
todst
in under file system. Similar torenameDirectory(String, String)
but deals with the write-src-then-rename and delete-dst-then-rename eventual consistency issue.- Parameters:
src
- the source directory pathdst
- the destination directory path- Returns:
- true if succeed, false otherwise
- Throws:
java.io.IOException
-
renameFile
boolean renameFile(java.lang.String src, java.lang.String dst) throws java.io.IOException
Renames a file fromsrc
todst
in under file system.- Parameters:
src
- the source file pathdst
- the destination file path- Returns:
- true if succeed, false otherwise
- Throws:
java.io.IOException
-
renameRenamableFile
boolean renameRenamableFile(java.lang.String src, java.lang.String dst) throws java.io.IOException
Renames a file fromsrc
todst
in under file system. Similar torenameFile(String, String)
but deals with the write-src-then-rename and delete-dst-then-rename eventual consistency issue.- Parameters:
src
- the source file pathdst
- the destination file path- Returns:
- true if succeed, false otherwise
- Throws:
java.io.IOException
-
resolveUri
AlluxioURI resolveUri(AlluxioURI ufsBaseUri, java.lang.String alluxioPath)
Returns anAlluxioURI
representation for theUnderFileSystem
given a base UFS URI, and the Alluxio path from the base. The default implementation simply concatenates the path to the base URI. This should be overridden if a subclass needs alternate functionality.- Parameters:
ufsBaseUri
- the baseAlluxioURI
in the ufsalluxioPath
- the path in Alluxio from the given base- Returns:
- the UFS
AlluxioURI
representing the Alluxio path
-
setAclEntries
void setAclEntries(java.lang.String path, java.util.List<AclEntry> aclEntries) throws java.io.IOException
Sets the access control list of a file or directory in under file system. if the ufs does not support acls, this is a noop. This will overwrite the ACL and defaultACL in the UFS.- Parameters:
path
- the path to the file or directoryaclEntries
- the access control list + default acl represented in a list of acl entries- Throws:
java.io.IOException
-
setMode
void setMode(java.lang.String path, short mode) throws java.io.IOException
Changes posix file mode.- Parameters:
path
- the path of the filemode
- the mode to set in short format, e.g. 0777- Throws:
java.io.IOException
-
setOwner
void setOwner(java.lang.String path, java.lang.String owner, java.lang.String group) throws java.io.IOException
Sets the user and group of the given path. An empty implementation should be provided if unsupported.- Parameters:
path
- the path of the fileowner
- the new owner to set, unchanged if nullgroup
- the new group to set, unchanged if null- Throws:
java.io.IOException
-
supportsFlush
boolean supportsFlush() throws java.io.IOException
Whether this type of UFS supports flush.- Returns:
- true if this type of UFS supports flush, false otherwise
- Throws:
java.io.IOException
-
supportsActiveSync
boolean supportsActiveSync()
Whether this type of UFS supports active sync.- Returns:
- true if this type of UFS supports active sync, false otherwise
-
getActiveSyncInfo
SyncInfo getActiveSyncInfo() throws java.io.IOException
Return the active sync info for the specified syncPoints.- Returns:
- active sync info consisting of what changed for these sync points
- Throws:
java.io.IOException
-
startSync
void startSync(AlluxioURI uri) throws java.io.IOException
Add Sync Point.- Parameters:
uri
- ufs uri to start- Throws:
java.io.IOException
-
stopSync
void stopSync(AlluxioURI uri) throws java.io.IOException
Stop Sync Point.- Parameters:
uri
- ufs uri to stop- Throws:
java.io.IOException
-
startActiveSyncPolling
boolean startActiveSyncPolling(long txId) throws java.io.IOException
Start Active Sync.- Parameters:
txId
- the transaction id to start receiving event- Returns:
- true if active sync started
- Throws:
java.io.IOException
-
stopActiveSyncPolling
boolean stopActiveSyncPolling() throws java.io.IOException
Stop Active Sync.- Returns:
- true if active sync stopped
- Throws:
java.io.IOException
-
getTemporaryToken
default byte[] getTemporaryToken(java.lang.String path, java.lang.String sid, java.lang.String effect, Mode.Bits action) throws java.io.IOException
Gets a temporary token according to path, sid, effect and action.- Parameters:
path
- the resource pathsid
- the user ideffect
- the effectaction
- the action to be done- Returns:
- the byte array of the temporary token
- Throws:
java.io.IOException
-
setTemporaryTokenRefreshContext
default void setTemporaryTokenRefreshContext(UserState userState)
Sets the userState to UFS instance.- Parameters:
userState
- the userState
-
isTemporaryConnectionToken
default boolean isTemporaryConnectionToken()
Denotes if the under storage is in the temporary connection token mode.- Returns:
- true if the under storage is in the temporary connection token mode
-
refreshTemporaryToken
default byte[] refreshTemporaryToken(byte[] oldTemporaryToken) throws java.io.IOException
Refreshes the old temporary token.- Parameters:
oldTemporaryToken
- the old temporary token- Returns:
- the byte array of the temporary token
- Throws:
java.io.IOException
-
-