public class InodeSyncStream extends Object
ExecutorService
which we submit inode paths to using
processSyncPath(AlluxioURI)
. The processing of inode paths will discover new paths to
sync depending on the mDescendantType
. Syncing is finished when all submitted tasks
are completed and there are no new inodes left in the queue.
Syncing inode metadata requires making calls to the UFS. This implementation will schedule UFS
RPCs with the UfsStatusCache.prefetchChildren(AlluxioURI, MountTable)
. Then, once the
inode begins processing, it can retrieve the results. After processing, it can then remove its
UfsStatus
from the cache. This strategy helps reduce memory pressure on the master
while performing a sync for a large tree. Additionally, by using a prefetch mechanism we can
concurrently process other inodes while waiting for UFS RPCs to complete.
With regards to locking, this class expects to be able to take a write lock on any inode, and
then subsequently downgrades or unlocks after the sync is finished. Even though we use
ReentrantReadWriteLock
, because we concurrently process
inodes on separate threads, we cannot utilize the reetrnant behavior. The implications of
that mean the caller of this class must not hold a write while calling sync()
.
A user of this class is expected to create a new instance for each path that they would like
to process. This is because the Lock on the mRootScheme
may be changed after calling
sync()
.Modifier and Type | Class and Description |
---|---|
static class |
InodeSyncStream.SyncStatus
Return status of a sync result.
|
Constructor and Description |
---|
InodeSyncStream(LockingScheme rootScheme,
DefaultFileSystemMaster fsMaster,
RpcContext rpcContext,
DescendantType descendantType,
FileSystemMasterCommonPOptions options,
boolean isGetFileInfo,
boolean forceSync,
boolean loadOnly,
boolean loadAlways)
Create a new instance of
InodeSyncStream without any audit or permission checks. |
InodeSyncStream(LockingScheme rootPath,
DefaultFileSystemMaster fsMaster,
RpcContext rpcContext,
DescendantType descendantType,
FileSystemMasterCommonPOptions options,
FileSystemMasterAuditContext auditContext,
java.util.function.Function<LockedInodePath,Inode> auditContextSrcInodeFunc,
alluxio.master.file.DefaultFileSystemMaster.PermissionCheckFunction permissionCheckOperation,
boolean isGetFileInfo,
boolean forceSync,
boolean loadOnly,
boolean loadAlways)
Create a new instance of
InodeSyncStream . |
Modifier and Type | Method and Description |
---|---|
InodeSyncStream.SyncStatus |
sync()
Sync the metadata according the the root path the stream was created with.
|
String |
toString() |
public InodeSyncStream(LockingScheme rootPath, DefaultFileSystemMaster fsMaster, RpcContext rpcContext, DescendantType descendantType, FileSystemMasterCommonPOptions options, @Nullable FileSystemMasterAuditContext auditContext, @Nullable java.util.function.Function<LockedInodePath,Inode> auditContextSrcInodeFunc, @Nullable alluxio.master.file.DefaultFileSystemMaster.PermissionCheckFunction permissionCheckOperation, boolean isGetFileInfo, boolean forceSync, boolean loadOnly, boolean loadAlways)
InodeSyncStream
.
The root path should be already locked with InodeTree.LockPattern.WRITE_EDGE
unless the user is
only planning on loading metadata. The desired pattern should always be
InodeTree.LockPattern.READ
.
It is an error to initiate sync without a WRITE_EDGE lock when loadOnly is false
.
If loadOnly is set to true
, then the the root path may have a read lock.rootPath
- The root path to begin syncingfsMaster
- the FileSystemMaster
calling this methodrpcContext
- the caller's RpcContext
descendantType
- determines the number of descendant inodes to syncoptions
- the RPC's FileSystemMasterCommonPOptions
auditContext
- the audit context to use when loadingauditContextSrcInodeFunc
- the inode to set as the audit context sourcepermissionCheckOperation
- the operation to use to check permissionsisGetFileInfo
- whether the caller is FileSystemMaster.getFileInfo(long)
forceSync
- whether to sync inode metadata no matter whatloadOnly
- whether to only load new metadata, rather than update existing metadataloadAlways
- whether to always load new metadata from the ufs, even if a file or
directory has been previous found to not existpublic InodeSyncStream(LockingScheme rootScheme, DefaultFileSystemMaster fsMaster, RpcContext rpcContext, DescendantType descendantType, FileSystemMasterCommonPOptions options, boolean isGetFileInfo, boolean forceSync, boolean loadOnly, boolean loadAlways)
InodeSyncStream
without any audit or permission checks.rootScheme
- The root path to begin syncingfsMaster
- the FileSystemMaster
calling this methodrpcContext
- the caller's RpcContext
descendantType
- determines the number of descendant inodes to syncoptions
- the RPC's FileSystemMasterCommonPOptions
isGetFileInfo
- whether the caller is FileSystemMaster.getFileInfo(long)
forceSync
- whether to sync inode metadata no matter whatloadOnly
- whether to only load new metadata, rather than update existing metadataloadAlways
- whether to always load new metadata from the ufs, even if a file or
directory has been previous found to not existpublic InodeSyncStream.SyncStatus sync() throws AccessControlException, InvalidPathException
AccessControlException
InvalidPathException
Copyright © 2023. All Rights Reserved.