@ThreadSafe public class UfsBaseFileSystem extends Object implements FileSystem
FileSystem
interface that directly interacts with a target
UFS. No Alluxio server is involved.FileSystem.Factory
Modifier and Type | Field and Description |
---|---|
protected boolean |
mClosed |
protected FileSystemContext |
mFsContext |
protected AlluxioURI |
mRootUFS |
protected CloseableResource<UnderFileSystem> |
mUfs |
Constructor and Description |
---|
UfsBaseFileSystem(FileSystemContext fsContext,
UfsFileSystemOptions options)
Constructs a new base file system.
|
Modifier and Type | Method and Description |
---|---|
void |
checkAccess(AlluxioURI path,
CheckAccessPOptions options)
Checks access to a path.
|
void |
close()
Shuts down the FileSystem.
|
void |
createDirectory(AlluxioURI path,
CreateDirectoryPOptions options)
Creates a directory.
|
FileOutStream |
createFile(AlluxioURI path,
CreateFilePOptions options)
Creates a file.
|
void |
delete(AlluxioURI path,
DeletePOptions options)
Deletes a file or a directory.
|
boolean |
exists(AlluxioURI path,
ExistsPOptions options)
Checks whether a path exists in Alluxio space.
|
void |
free(AlluxioURI path,
FreePOptions options)
Evicts any data under the given path from Alluxio space, but does not delete the data from the
UFS.
|
List<BlockLocationInfo> |
getBlockLocations(AlluxioURI path)
Builds a list of
BlockLocationInfo for the given file. |
List<BlockLocationInfo> |
getBlockLocations(URIStatus status)
Builds a list of
BlockLocationInfo for the given file. |
AlluxioConfiguration |
getConf() |
String |
getJobProgress(JobDescription jobDescription,
JobProgressReportFormat format,
boolean verbose)
Get progress of a job.
|
Map<String,MountPointInfo> |
getMountTable(boolean checkUfs)
Lists all mount points and their corresponding under storage addresses.
|
URIStatus |
getStatus(AlluxioURI path)
Convenience method for
FileSystem.getStatus(AlluxioURI, GetStatusPOptions) with default options. |
URIStatus |
getStatus(AlluxioURI path,
GetStatusPOptions options)
Gets the
URIStatus object that represents the metadata of an Alluxio path. |
List<SyncPointInfo> |
getSyncPathList()
Lists all the actively synced paths.
|
boolean |
isClosed()
If there are operations currently running and close is called concurrently the behavior is
undefined.
|
void |
iterateStatus(AlluxioURI path,
ListStatusPOptions options,
java.util.function.Consumer<? super URIStatus> action)
Performs a specific action on each
URIStatus in the result of FileSystem.listStatus(alluxio.AlluxioURI) . |
List<URIStatus> |
listStatus(AlluxioURI path,
ListStatusPOptions options)
If the path is a directory, returns the
URIStatus of all the direct entries in it. |
ListStatusPartialResult |
listStatusPartial(AlluxioURI path,
ListStatusPartialPOptions options)
Same as
FileSystem.listStatus(AlluxioURI, ListStatusPOptions) except may
only return a subset of the results as determined by the options parameter. |
void |
loadMetadata(AlluxioURI path,
ListStatusPOptions options)
Loads metadata about a path in the UFS to Alluxio.
|
void |
mount(AlluxioURI alluxioPath,
AlluxioURI ufsPath,
MountPOptions options)
Mounts a UFS subtree to the given Alluxio path.
|
void |
needsSync(AlluxioURI path)
Marks the path in Alluxio as needing sync with the UFS.
|
FileInStream |
openFile(AlluxioURI path,
OpenFilePOptions options)
Opens a file for reading.
|
FileInStream |
openFile(URIStatus status,
OpenFilePOptions options)
Opens a file for reading.
|
void |
persist(AlluxioURI path,
ScheduleAsyncPersistencePOptions options)
Schedules the given path to be asynchronously persisted to the under file system.
|
void |
rename(AlluxioURI src,
AlluxioURI dst,
RenamePOptions options)
Renames an existing Alluxio path to another Alluxio path in Alluxio.
|
AlluxioURI |
reverseResolve(AlluxioURI ufsUri)
Reverse resolve a ufs uri.
|
void |
setAcl(AlluxioURI path,
SetAclAction action,
List<AclEntry> entries,
SetAclPOptions options)
Sets the ACL for a path.
|
void |
setAttribute(AlluxioURI path,
SetAttributePOptions options)
Sets any number of a path's attributes, such as TTL and pin status.
|
void |
startSync(AlluxioURI path)
Starts the active syncing process on an Alluxio path.
|
boolean |
stopJob(JobDescription jobDescription)
Stop a job in scheduler.
|
void |
stopSync(AlluxioURI path)
Stops the active syncing process on an Alluxio path.
|
Optional<String> |
submitJob(JobRequest jobRequest)
Submit a job to scheduler.
|
void |
unmount(AlluxioURI path,
UnmountPOptions options)
Unmounts a UFS subtree identified by the given Alluxio path.
|
void |
updateMount(AlluxioURI alluxioPath,
MountPOptions options)
Updates the options for an existing mount point.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDirectory, createFile, delete, exists, free, getMountTable, iterateStatus, listStatus, loadMetadata, mount, openFile, persist, rename, setAcl, setAttribute, unmount
protected final FileSystemContext mFsContext
protected final CloseableResource<UnderFileSystem> mUfs
protected final AlluxioURI mRootUFS
protected volatile boolean mClosed
public UfsBaseFileSystem(FileSystemContext fsContext, UfsFileSystemOptions options)
fsContext
- file system contextoptions
- the ufs file system optionspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public boolean isClosed()
FileSystem
isClosed
in interface FileSystem
public void checkAccess(AlluxioURI path, CheckAccessPOptions options)
FileSystem
checkAccess
in interface FileSystem
path
- the path of the directory to create in Alluxio spaceoptions
- options to associate with this operationpublic void createDirectory(AlluxioURI path, CreateDirectoryPOptions options)
FileSystem
createDirectory
in interface FileSystem
path
- the path of the directory to create in Alluxio spaceoptions
- options to associate with this operationpublic FileOutStream createFile(AlluxioURI path, CreateFilePOptions options)
FileSystem
createFile
in interface FileSystem
path
- the path of the file to create in Alluxio spaceoptions
- options to associate with this operationFileOutStream
which will write data to the newly created filepublic void delete(AlluxioURI path, DeletePOptions options)
FileSystem
delete
in interface FileSystem
path
- the path to delete in Alluxio spaceoptions
- options to associate with this operationpublic boolean exists(AlluxioURI path, ExistsPOptions options)
FileSystem
exists
in interface FileSystem
path
- the path in questionoptions
- options to associate with this operationpublic void free(AlluxioURI path, FreePOptions options)
FileSystem
free
in interface FileSystem
path
- the path to free in Alluxio spaceoptions
- options to associate with this operationpublic List<BlockLocationInfo> getBlockLocations(AlluxioURI path)
FileSystem
BlockLocationInfo
for the given file. Each list item contains a list
of WorkerNetAddress
which allows a user to determine the physical location of a block
of the given file stored within Alluxio. In the case where data is stored in a UFS, but not in
Alluxio this function will only include a WorkerNetAddress
if the block stored in the
UFS is co-located with an Alluxio worker.
However if there are no co-located Alluxio workers for the block, then the behavior is
controlled by the PropertyKey.USER_UFS_BLOCK_LOCATION_ALL_FALLBACK_ENABLED
. If
this property is set to true
then every Alluxio worker will be returned.
Blocks which are stored in the UFS and are *not* co-located with any Alluxio worker will return
an empty list. If the file block is within Alluxio *and* the UFS then this will only return
Alluxio workers which currently store the block.getBlockLocations
in interface FileSystem
path
- the path to get block info forpublic List<BlockLocationInfo> getBlockLocations(URIStatus status)
FileSystem
BlockLocationInfo
for the given file.getBlockLocations
in interface FileSystem
status
- the path statuspublic AlluxioConfiguration getConf()
getConf
in interface FileSystem
public URIStatus getStatus(AlluxioURI path)
FileSystem
FileSystem.getStatus(AlluxioURI, GetStatusPOptions)
with default options.getStatus
in interface FileSystem
path
- the path to obtain information aboutURIStatus
of the filepublic URIStatus getStatus(AlluxioURI path, GetStatusPOptions options)
FileSystem
URIStatus
object that represents the metadata of an Alluxio path.getStatus
in interface FileSystem
path
- the path to obtain information aboutoptions
- options to associate with this operationURIStatus
of the filepublic List<URIStatus> listStatus(AlluxioURI path, ListStatusPOptions options)
FileSystem
URIStatus
of all the direct entries in it.
Otherwise returns a list with a single URIStatus
element for the file.listStatus
in interface FileSystem
path
- the path to list information aboutoptions
- options to associate with this operationURIStatus
s containing information about the files and directories
which are children of the given pathpublic void iterateStatus(AlluxioURI path, ListStatusPOptions options, java.util.function.Consumer<? super URIStatus> action)
FileSystem
URIStatus
in the result of FileSystem.listStatus(alluxio.AlluxioURI)
.
This method is preferred when iterating over directories with a large number of files or
sub-directories inside. The caller can proceed with partial result without waiting for all
result returned.iterateStatus
in interface FileSystem
path
- the path to list information aboutoptions
- options to associate with this operationaction
- action to apply on each URIStatus
public ListStatusPartialResult listStatusPartial(AlluxioURI path, ListStatusPartialPOptions options)
FileSystem
FileSystem.listStatus(AlluxioURI, ListStatusPOptions)
except may
only return a subset of the results as determined by the options parameter.listStatusPartial
in interface FileSystem
path
- the path to list information aboutoptions
- options to associate with this operationURIStatus
s containing information about the files and directories
which are children of the given pathpublic void loadMetadata(AlluxioURI path, ListStatusPOptions options)
FileSystem
loadMetadata
in interface FileSystem
path
- the path for which to load metadata from UFSoptions
- options to associate with this operationpublic void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, MountPOptions options)
FileSystem
AlluxioException
will be thrown.
This method does not transfer any data or metadata from the UFS. It simply establishes the
connection between the given Alluxio path and UFS path.mount
in interface FileSystem
alluxioPath
- an Alluxio path to mount the data toufsPath
- a UFS path to mount the data fromoptions
- options to associate with this operationpublic void updateMount(AlluxioURI alluxioPath, MountPOptions options)
FileSystem
updateMount
in interface FileSystem
alluxioPath
- the Alluxio path of the mount pointoptions
- options for this mount pointpublic Map<String,MountPointInfo> getMountTable(boolean checkUfs)
FileSystem
getMountTable
in interface FileSystem
checkUfs
- whether to get UFS usage infoMountPointInfo
public List<SyncPointInfo> getSyncPathList()
FileSystem
getSyncPathList
in interface FileSystem
public void persist(AlluxioURI path, ScheduleAsyncPersistencePOptions options)
FileSystem
FileSystemUtils.persistAndWait(FileSystem, AlluxioURI, long)
.persist
in interface FileSystem
path
- the uri of the file to persistoptions
- the options to use when submitting persist the pathpublic FileInStream openFile(AlluxioURI path, OpenFilePOptions options)
FileSystem
openFile
in interface FileSystem
path
- the file to read fromoptions
- options to associate with this operationFileInStream
for the given pathpublic FileInStream openFile(URIStatus status, OpenFilePOptions options)
FileSystem
openFile
in interface FileSystem
status
- status of the file to read fromoptions
- options to associate with this operationFileInStream
for the given pathpublic void rename(AlluxioURI src, AlluxioURI dst, RenamePOptions options)
FileSystem
rename
in interface FileSystem
src
- the path of the source, this must already existdst
- the path of the destination, this path should not existoptions
- options to associate with this operationpublic AlluxioURI reverseResolve(AlluxioURI ufsUri)
FileSystem
reverseResolve
in interface FileSystem
ufsUri
- the ufs uripublic void setAcl(AlluxioURI path, SetAclAction action, List<AclEntry> entries, SetAclPOptions options)
FileSystem
setAcl
in interface FileSystem
path
- the path to set the ACL foraction
- the set action to performentries
- the ACL entriesoptions
- options to associate with this operationpublic void setAttribute(AlluxioURI path, SetAttributePOptions options)
FileSystem
setAttribute
in interface FileSystem
path
- the path to set attributes foroptions
- options to associate with this operationpublic void startSync(AlluxioURI path)
startSync
in interface FileSystem
path
- the path to syncpublic void stopSync(AlluxioURI path)
stopSync
in interface FileSystem
path
- the path to stop syncingpublic void unmount(AlluxioURI path, UnmountPOptions options)
FileSystem
unmount
in interface FileSystem
path
- an Alluxio path, this must be a mount pointoptions
- options to associate with this operationpublic void needsSync(AlluxioURI path) throws IOException, AlluxioException
FileSystem
needsSync
in interface FileSystem
path
- the path needing synchronizationIOException
AlluxioException
public Optional<String> submitJob(JobRequest jobRequest)
FileSystem
submitJob
in interface FileSystem
jobRequest
- the job requestpublic boolean stopJob(JobDescription jobDescription)
FileSystem
stopJob
in interface FileSystem
jobDescription
- the job descriptionpublic String getJobProgress(JobDescription jobDescription, JobProgressReportFormat format, boolean verbose)
FileSystem
getJobProgress
in interface FileSystem
jobDescription
- the job descriptionformat
- progress report formatverbose
- whether to return verbose reportCopyright © 2023. All Rights Reserved.