@ThreadSafe public class UfsStatusCache extends Object
AlluxioURI
, i.e. /path/to/inode) to
UFS statuses.
It also allows associating a path with child inodes, so that the statuses for a specific path can
be searched for later.Constructor and Description |
---|
UfsStatusCache(ExecutorService prefetchExecutor,
UfsAbsentPathCache absentPathCache,
long cacheValidTime)
Create a new instance of
UfsStatusCache . |
Modifier and Type | Method and Description |
---|---|
Collection<UfsStatus> |
addChildren(AlluxioURI path,
Collection<UfsStatus> children)
Add a parent-child mapping to the status cache.
|
UfsStatus |
addStatus(AlluxioURI path,
UfsStatus status)
Add a new status to the cache.
|
void |
cancelAllPrefetch()
Interrupts and cancels any currently running prefetch jobs.
|
Collection<UfsStatus> |
fetchChildrenIfAbsent(RpcContext rpcContext,
AlluxioURI path,
MountTable mountTable)
Fetches children of a given alluxio path stores them in the cache, then returns them.
|
Collection<UfsStatus> |
fetchChildrenIfAbsent(RpcContext rpcContext,
AlluxioURI path,
MountTable mountTable,
boolean useFallback)
Fetches children of a given alluxio path, stores them in the cache, then returns them.
|
UfsStatus |
fetchStatusIfAbsent(AlluxioURI path,
MountTable mountTable)
Attempts to return a status from the cache.
|
Collection<UfsStatus> |
getChildren(AlluxioURI path)
Get the child
UfsStatus es from a given AlluxioURI . |
UfsStatus |
getStatus(AlluxioURI path)
Get the UfsStatus from a given AlluxioURI.
|
Future<Collection<UfsStatus>> |
prefetchChildren(AlluxioURI path,
MountTable mountTable)
Submit a request to asynchronously fetch the statuses corresponding to a given directory.
|
UfsStatus |
remove(AlluxioURI path)
Remove a status from the cache.
|
public UfsStatusCache(@Nullable ExecutorService prefetchExecutor, UfsAbsentPathCache absentPathCache, long cacheValidTime)
UfsStatusCache
.prefetchExecutor
- the executor service used to prefetch statuses. If set to null, then
calls to prefetchChildren(AlluxioURI, MountTable)
will not
schedule any tasks.absentPathCache
- the absent cache that ufsStatusCache should consultcacheValidTime
- the time when the absent cache entry would be considered valid@Nullable public UfsStatus addStatus(AlluxioURI path, UfsStatus status)
AlluxioURI
must match the result of
UfsStatus.getName()
. This method overrides any status currently cached for the same
URI.path
- the Alluxio path to key onstatus
- the ufs status to storeIllegalArgumentException
- if the status name doesn't match the final URI path component@Nullable public Collection<UfsStatus> addChildren(AlluxioURI path, Collection<UfsStatus> children)
getStatus(AlluxioURI)
.path
- the directory inode path which contains the childrenchildren
- the children of the path
@Nullable public UfsStatus remove(AlluxioURI path)
UfsStatus
.path
- the path corresponding to the UfsStatus
to remove@Nullable public UfsStatus getStatus(AlluxioURI path) throws FileNotFoundException
path
- the path the retrieveUfsStatus
or null
if there is none storedFileNotFoundException
- if the UFS does not contain the file@Nullable public UfsStatus fetchStatusIfAbsent(AlluxioURI path, MountTable mountTable) throws InvalidPathException, IOException
path
- the path the retrievemountTable
- the Alluxio mount tableUfsStatus
or null
if there is none storedInvalidPathException
IOException
@Nullable public Collection<UfsStatus> fetchChildrenIfAbsent(RpcContext rpcContext, AlluxioURI path, MountTable mountTable, boolean useFallback) throws InterruptedException, InvalidPathException
rpcContext
- the rpcContext of the source of this callpath
- the Alluxio path to get the children ofmountTable
- the Alluxio mount tableuseFallback
- whether or not to fall back to calling the UFSInvalidPathException
- if the alluxio path can't be resolved to a UFS mountInterruptedException
@Nullable public Collection<UfsStatus> fetchChildrenIfAbsent(RpcContext rpcContext, AlluxioURI path, MountTable mountTable) throws InterruptedException, InvalidPathException
rpcContext
- the rpcContext of the source of this callpath
- the Alluxio pathmountTable
- the Alluxio mount tableInvalidPathException
- if the alluxio path can't be resolved to a UFS mountInterruptedException
@Nullable public Collection<UfsStatus> getChildren(AlluxioURI path)
UfsStatus
es from a given AlluxioURI
.path
- the path the retrieveUfsStatus
or null
if there is none stored@Nullable public Future<Collection<UfsStatus>> prefetchChildren(AlluxioURI path, MountTable mountTable)
fetchChildrenIfAbsent(RpcContext, AlluxioURI, MountTable)
with the same Alluxio path.
If no ExecutorService
was provided to this object before instantiation, this method is
a no-op.path
- the path to prefetchmountTable
- the Alluxio mount tablepublic void cancelAllPrefetch()
Copyright © 2023. All Rights Reserved.