@ThreadSafe public final class FileSystemUtils extends Object
FileSystem
related objects.Modifier and Type | Method and Description |
---|---|
static boolean |
metadataEnabled(AlluxioConfiguration conf) |
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,
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 metadataEnabled(AlluxioConfiguration conf)
conf
- the configuration to get info frompublic static boolean waitCompleted(FileSystem fs, AlluxioURI uri) throws 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 waitIOException
AlluxioException
waitCompleted(FileSystem, AlluxioURI, long, TimeUnit)
public static boolean waitCompleted(FileSystem fs, AlluxioURI uri, long timeout, TimeUnit tunit) throws 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 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
parameterIOException
AlluxioException
public static void persistAndWait(FileSystem fs, AlluxioURI uri, long persistenceWaitTime) throws FileDoesNotExistException, IOException, AlluxioException, TimeoutException, 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 timeFileDoesNotExistException
IOException
AlluxioException
TimeoutException
InterruptedException
public static void persistAndWait(FileSystem fs, AlluxioURI uri, long persistenceWaitTime, int timeoutMs) throws FileDoesNotExistException, IOException, AlluxioException, TimeoutException, 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
indefinitelyTimeoutException
- if the persist takes longer than the timeoutFileDoesNotExistException
IOException
AlluxioException
InterruptedException
public static void waitForAlluxioPercentage(FileSystem fs, AlluxioURI uri, int expectedPercentage) throws TimeoutException, InterruptedException
fs
- the file systemuri
- the uri to check the percentage forexpectedPercentage
- the desired percentageTimeoutException
InterruptedException
Copyright © 2023. All Rights Reserved.