@ThreadSafe public final class FileSystemUtils extends Object
FileSystem
related objects.Modifier and Type | Method and Description |
---|---|
static List<AlluxioURI> |
checkConsistency(AlluxioURI path,
CheckConsistencyOptions options)
Checks the consistency of Alluxio metadata against the under storage for all files and
directories in a given subtree.
|
static void |
persistFile(FileSystem fs,
AlluxioURI uri)
Persists the given file to the under file system.
|
static boolean |
waitCompleted(FileSystem fs,
AlluxioURI uri)
Shortcut for
waitCompleted(fs, uri, -1, TimeUnit.MILLISECONDS) , i.e., wait for an
indefinite amount of time. |
static boolean |
waitCompleted(FileSystem fs,
AlluxioURI uri,
long timeout,
TimeUnit tunit)
Waits for a file to be marked as completed.
|
public static boolean waitCompleted(FileSystem fs, AlluxioURI uri) throws IOException, AlluxioException, InterruptedException
waitCompleted(fs, uri, -1, TimeUnit.MILLISECONDS)
, i.e., wait for an
indefinite amount of time. Note that if a file is never completed, the thread will block
forever, so use with care.fs
- a FileSystem
instanceuri
- the URI of the file on which the thread should waitInterruptedException
- if the thread receives an interrupt while waiting for file
completionIOException
AlluxioException
waitCompleted(FileSystem, AlluxioURI, long, TimeUnit)
public static boolean waitCompleted(FileSystem fs, AlluxioURI uri, long timeout, TimeUnit tunit) throws IOException, AlluxioException, InterruptedException
timeout
time units (as specified via
tunit
or until the file is reported as complete by the master. The method will return
the last known completion status of the file (hence, false only if the method has timed out). A
zero value on the timeout
parameter will make the calling thread check once and return;
a negative value will make it block indefinitely. Note that, in this last case, if a file is
never completed, the thread will block forever, so use with care.
Note that the file whose uri is specified, might not exist at the moment this method this call.
The method will deliberately block anyway for the specified amount of time, waiting for the
file to be created and eventually completed. Note also that the file might be moved or deleted
while it is waited upon. In such cases the method will throw the a AlluxioException
IMPLEMENTATION NOTES This method is implemented by periodically polling the master about
the file status. The polling period is controlled by the
PropertyKey.USER_FILE_WAITCOMPLETED_POLL_MS
java property and defaults to a generous 1
second.fs
- an instance of FileSystem
uri
- the URI of the file whose completion status is to be watied fortimeout
- maximum time the calling thread should be blocked on this calltunit
- the @{link TimeUnit} instance describing the timeout
parameterInterruptedException
- if the thread receives an interrupt while waiting for file
completionIOException
AlluxioException
public static void persistFile(FileSystem fs, AlluxioURI uri) throws IOException
fs
- FileSystem
to carry out Alluxio operationsuri
- the uri of the file to persistIOException
public static List<AlluxioURI> checkConsistency(AlluxioURI path, CheckConsistencyOptions options) throws IOException
path
- the root of the subtree to checkoptions
- method optionsIOException
Copyright © 2023. All Rights Reserved.