@ThreadSafe
public final class FileSystemUtils
extends java.lang.Object
FileSystem related objects.| Modifier and Type | Method and Description |
|---|---|
static void |
persistAndWait(FileSystem fs,
AlluxioURI uri,
long persistenceWaitTime)
Convenience method for
#persistAndWait(fs, uri, persistenceWaitTime, -1). |
static void |
persistAndWait(FileSystem fs,
AlluxioURI uri,
long persistenceWaitTime,
int timeoutMs)
Persists the given path to the under file system and returns once the persist is complete.
|
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,
java.util.concurrent.TimeUnit tunit)
Waits for a file to be marked as completed.
|
static void |
waitForAlluxioPercentage(FileSystem fs,
AlluxioURI uri,
int expectedPercentage)
Waits until the specified file has the desired percentage in Alluxio.
|
public static boolean waitCompleted(FileSystem fs, AlluxioURI uri) throws java.io.IOException, AlluxioException
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 waitjava.io.IOExceptionAlluxioExceptionwaitCompleted(FileSystem, AlluxioURI, long, TimeUnit)public static boolean waitCompleted(FileSystem fs, AlluxioURI uri, long timeout, java.util.concurrent.TimeUnit tunit) throws java.io.IOException, AlluxioException
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 FileSystemuri - 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 parameterjava.io.IOExceptionAlluxioExceptionpublic static void persistAndWait(FileSystem fs, AlluxioURI uri, long persistenceWaitTime) throws FileDoesNotExistException, java.io.IOException, AlluxioException, java.util.concurrent.TimeoutException, java.lang.InterruptedException
#persistAndWait(fs, uri, persistenceWaitTime, -1).
i.e. wait for an indefinite period of time to persist. This will block
for an indefinite period of time if the path is never persisted. Use with care.fs - FileSystem to carry out Alluxio operationsuri - the uri of the file to persistpersistenceWaitTime - the persistence wait timeFileDoesNotExistExceptionjava.io.IOExceptionAlluxioExceptionjava.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionpublic static void persistAndWait(FileSystem fs, AlluxioURI uri, long persistenceWaitTime, int timeoutMs) throws FileDoesNotExistException, java.io.IOException, AlluxioException, java.util.concurrent.TimeoutException, java.lang.InterruptedException
fs - FileSystem to carry out Alluxio operationsuri - the uri of the file to persistpersistenceWaitTime - the initial persistence wait timetimeoutMs - max amount of time to wait for persist in milliseconds. -1 to wait
indefinitelyjava.util.concurrent.TimeoutException - if the persist takes longer than the timeoutFileDoesNotExistExceptionjava.io.IOExceptionAlluxioExceptionjava.lang.InterruptedExceptionpublic static void waitForAlluxioPercentage(FileSystem fs, AlluxioURI uri, int expectedPercentage) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException
fs - the file systemuri - the uri to check the percentage forexpectedPercentage - the desired percentagejava.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionCopyright © 2022. All Rights Reserved.