@NotThreadSafe public class InodeTree extends Object implements DelegatingJournaled
Modifier and Type | Class and Description |
---|---|
static class |
InodeTree.LockPattern
Patterns of inode path locking.
|
Modifier and Type | Field and Description |
---|---|
static long |
NO_PARENT
Value to be used for an inode with no parent.
|
static int |
PATH_TRAVERSAL_RETRIES
Number of retries when trying to lock a path, from a given id.
|
static String |
ROOT_INODE_NAME
Only the root inode should have the empty string as its name.
|
static String |
ROOT_PATH
Path of the root inode.
|
Constructor and Description |
---|
InodeTree(InodeStore inodeStore,
ContainerIdGenerable containerIdGenerator,
InodeDirectoryIdGenerator directoryIdGenerator,
MountTable mountTable,
InodeLockManager lockManager) |
Modifier and Type | Method and Description |
---|---|
void |
cacheOperation(OperationId opId)
Used to mark an operation as complete in retry-cache.
|
void |
close()
Close resources associated with this tree instance.
|
List<Inode> |
createPath(RpcContext rpcContext,
LockedInodePath inodePath,
CreatePathContext<?,?> context)
Creates a file or directory at path.
|
void |
deleteInode(RpcContext rpcContext,
LockedInodePath inodePath,
long opTimeMs)
Deletes a single inode from the inode tree by removing it from the parent inode.
|
void |
ensureFullInodePath(LockedInodePath inodePath)
Attempts to extend an existing
LockedInodePath to reach the target inode (the last
inode for the full path). |
Journaled |
getDelegate() |
LockedInodePathList |
getDescendants(LockedInodePath inodePath)
Returns
LockedInodePath s for all descendants of inodePath. |
Map<Long,Number> |
getFileSizeHistogram() |
long |
getInodeCount() |
InodeLockManager |
getInodeLockManager() |
AlluxioURI |
getPath(InodeView inode)
Returns the path for a particular inode.
|
AlluxioURI |
getPath(long id)
Returns the path for a particular inode id.
|
ArrayList<String> |
getPathInodeNames(InodeView inode)
Computes the path components for the given inode view.
|
ArrayList<String> |
getPathInodeNames(long id)
Computes the path components for the given inode id.
|
Set<Long> |
getPinIdSet() |
int |
getPinnedSize() |
Set<Long> |
getReplicationLimitedFileIds() |
InodeDirectory |
getRoot() |
String |
getRootUserName() |
Set<Long> |
getToBePersistedIds() |
TtlBucketList |
getTtlBuckets() |
void |
initializeRoot(String owner,
String group,
Mode mode,
JournalContext context)
Initializes the root of the inode tree.
|
boolean |
inodeIdExists(long id) |
boolean |
inodePathExists(AlluxioURI uri) |
boolean |
isOperationComplete(OperationId opId)
Whether given operation is still cached in retry-cache.
|
boolean |
isRootId(long fileId) |
LockedInodePath |
lockFullInodePath(AlluxioURI uri,
InodeTree.LockPattern lockPattern,
JournalContext journalContext)
Locks a path and throws an exception if the path does not exist.
|
LockedInodePath |
lockFullInodePath(AlluxioURI uri,
LockingScheme lockScheme,
JournalContext journalContext)
Locks a path and throws an exception if the path does not exist.
|
LockedInodePath |
lockFullInodePath(long id,
InodeTree.LockPattern lockPattern,
JournalContext journalContext)
Locks a path and throws an exception if the path does not exist.
|
LockedInodePath |
lockInodePath(AlluxioURI uri,
InodeTree.LockPattern lockPattern,
boolean tryLock,
JournalContext journalContext)
Locks existing inodes on the specified path, in the specified
InodeTree.LockPattern . |
LockedInodePath |
lockInodePath(AlluxioURI uri,
InodeTree.LockPattern lockPattern,
JournalContext journalContext)
Locks existing inodes on the specified path, in the specified
InodeTree.LockPattern . |
LockedInodePath |
lockInodePath(LockingScheme scheme,
JournalContext journalContext)
Locks existing inodes on the path and with the pattern defined by
LockingScheme.getPath() and LockingScheme.getPattern() . |
InodePathPair |
lockInodePathPair(AlluxioURI path1,
InodeTree.LockPattern lockPattern1,
AlluxioURI path2,
InodeTree.LockPattern lockPattern2,
JournalContext journalContext)
Locks existing inodes on the two specified paths.
|
long |
newBlock(java.util.function.Supplier<JournalContext> context,
File.NewBlockEntry entry) |
void |
rename(java.util.function.Supplier<JournalContext> context,
File.RenameEntry entry) |
void |
setAcl(java.util.function.Supplier<JournalContext> context,
File.SetAclEntry entry) |
void |
setDirectChildrenLoaded(java.util.function.Supplier<JournalContext> context,
InodeDirectory dir)
Marks an inode directory as having its direct children loaded.
|
void |
setDirectChildrenLoaded(java.util.function.Supplier<JournalContext> context,
InodeDirectory dir,
boolean directChildrenLoaded)
Marks an inode directory as having its direct children loaded or not.
|
void |
setPinned(RpcContext rpcContext,
LockedInodePath inodePath,
boolean pinned,
List<String> mediumTypes,
long opTimeMs)
Sets the pinned state of an inode.
|
void |
setReplication(RpcContext rpcContext,
LockedInodePath inodePath,
Integer replicationMax,
Integer replicationMin,
long opTimeMs)
Sets the min and/or max replication level of an inode.
|
void |
syncPersistExistingDirectory(java.util.function.Supplier<JournalContext> context,
InodeDirectoryView dir,
boolean isMetadataLoad)
Synchronously persists an inode directory to the UFS.
|
void |
syncPersistNewDirectory(MutableInodeDirectory dir,
CreatePathContext<?,?> createContext)
Synchronously persists an inode directory to the UFS.
|
LockedInodePath |
tryLockInodePath(LockingScheme scheme,
JournalContext journalContext)
Locks existing inodes on the path and with the pattern defined by
LockingScheme.getPath() and LockingScheme.getPattern() . |
void |
updateInode(java.util.function.Supplier<JournalContext> context,
File.UpdateInodeEntry entry) |
File.UpdateInodeEntry |
updateInodeAccessTimeNoJournal(long inodeId,
long accessTime) |
void |
updateInodeFile(java.util.function.Supplier<JournalContext> context,
File.UpdateInodeFileEntry entry) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyAndJournal, getCheckpointName, getJournalEntryIterator, processJournalEntry, resetState, restoreFromCheckpoint, writeToCheckpoint
public static final long NO_PARENT
public static final String ROOT_INODE_NAME
public static final String ROOT_PATH
public static final int PATH_TRAVERSAL_RETRIES
public InodeTree(InodeStore inodeStore, ContainerIdGenerable containerIdGenerator, InodeDirectoryIdGenerator directoryIdGenerator, MountTable mountTable, InodeLockManager lockManager)
inodeStore
- the inode storecontainerIdGenerator
- the container id generator to use to get new container idsdirectoryIdGenerator
- the directory id generator to use to get new directory idsmountTable
- the mount table to manage the file system mount pointslockManager
- inode lock managerpublic boolean isOperationComplete(@Nullable OperationId opId)
opId
- the operation idtrue
if given op is marked completepublic void cacheOperation(@Nullable OperationId opId)
opId
- the operation idpublic void initializeRoot(String owner, String group, Mode mode, JournalContext context) throws UnavailableException
owner
- the root ownergroup
- the root groupmode
- the root modecontext
- the journal context to journal the initialization toUnavailableException
public TtlBucketList getTtlBuckets()
public long getInodeCount()
public Map<Long,Number> getFileSizeHistogram()
public void setDirectChildrenLoaded(java.util.function.Supplier<JournalContext> context, InodeDirectory dir)
context
- journal context supplierdir
- the inode directorypublic void setDirectChildrenLoaded(java.util.function.Supplier<JournalContext> context, InodeDirectory dir, boolean directChildrenLoaded)
context
- journal context supplierdir
- the inode directorydirectChildrenLoaded
- whether to load the direct children if they were not loaded beforepublic long newBlock(java.util.function.Supplier<JournalContext> context, File.NewBlockEntry entry)
context
- journal context supplierentry
- an entry representing an add block operationpublic void updateInodeFile(java.util.function.Supplier<JournalContext> context, File.UpdateInodeFileEntry entry)
context
- journal context supplierentry
- an entry representing an update inode file operationpublic void updateInode(java.util.function.Supplier<JournalContext> context, File.UpdateInodeEntry entry)
context
- journal context supplierentry
- an entry representing an update inode operationpublic File.UpdateInodeEntry updateInodeAccessTimeNoJournal(long inodeId, long accessTime)
inodeId
- id of inode to be updatedaccessTime
- the new access timepublic void rename(java.util.function.Supplier<JournalContext> context, File.RenameEntry entry)
context
- journal context supplierentry
- an entry representing a rename operationpublic void setAcl(java.util.function.Supplier<JournalContext> context, File.SetAclEntry entry)
context
- journal context supplierentry
- an entry representing a set acl operation@Nullable public String getRootUserName()
public int getPinnedSize()
public boolean inodeIdExists(long id)
id
- the id to get the inode forpublic LockedInodePath tryLockInodePath(LockingScheme scheme, JournalContext journalContext) throws InvalidPathException
LockingScheme.getPath()
and LockingScheme.getPattern()
.
This method uses the Lock.tryLock()
method to gain ownership of the locks. The reason
one might want to use this is to avoid the fairness heuristics within the
ReentrantReadWriteLock
's NonFairSync which may block reader
threads if a writer if the first in the queue.scheme
- the locking scheme to lock the path withjournalContext
- the journal context to flush when the LockedInodePath releasesLockedInodePath
representing the locked path of inodesInvalidPathException
- if the path is invalidpublic LockedInodePath lockInodePath(LockingScheme scheme, JournalContext journalContext) throws InvalidPathException
LockingScheme.getPath()
and LockingScheme.getPattern()
.scheme
- the locking scheme to lock the path withjournalContext
- the journal context to flush when the LockedInodePath releasesLockedInodePath
representing the locked path of inodesInvalidPathException
- if the path is invalidpublic LockedInodePath lockInodePath(AlluxioURI uri, InodeTree.LockPattern lockPattern, JournalContext journalContext) throws InvalidPathException
InodeTree.LockPattern
. The target
inode is not required to exist.uri
- the uri to locklockPattern
- the InodeTree.LockPattern
to lock the inodes withjournalContext
- the journal context to flush when the LockedInodePath releasesLockedInodePath
representing the locked path of inodesInvalidPathException
- if the path is invalidpublic LockedInodePath lockInodePath(AlluxioURI uri, InodeTree.LockPattern lockPattern, boolean tryLock, JournalContext journalContext) throws InvalidPathException
InodeTree.LockPattern
. The target
inode is not required to exist.uri
- the uri to locklockPattern
- the InodeTree.LockPattern
to lock the inodes withtryLock
- true to use Lock.tryLock()
or false to use Lock.lock()
journalContext
- the journal context to flush when the LockedInodePath releasesLockedInodePath
representing the locked path of inodesInvalidPathException
- if the path is invalidpublic boolean inodePathExists(AlluxioURI uri)
uri
- the AlluxioURI
to check for existencepublic LockedInodePath lockFullInodePath(AlluxioURI uri, LockingScheme lockScheme, JournalContext journalContext) throws InvalidPathException, FileDoesNotExistException
uri
- a uri to locklockScheme
- the scheme to lock withjournalContext
- the journal context to flush when the LockedInodePath releasesInvalidPathException
FileDoesNotExistException
public LockedInodePath lockFullInodePath(AlluxioURI uri, InodeTree.LockPattern lockPattern, JournalContext journalContext) throws InvalidPathException, FileDoesNotExistException
uri
- a uri to locklockPattern
- the pattern to lock withjournalContext
- the journal context to flush when the LockedInodePath releasesInvalidPathException
FileDoesNotExistException
public LockedInodePath lockFullInodePath(long id, InodeTree.LockPattern lockPattern, JournalContext journalContext) throws FileDoesNotExistException
id
- the inode id to locklockPattern
- the pattern to lock withjournalContext
- the journal context to flush when the LockedInodePath releasesFileDoesNotExistException
public InodePathPair lockInodePathPair(AlluxioURI path1, InodeTree.LockPattern lockPattern1, AlluxioURI path2, InodeTree.LockPattern lockPattern2, JournalContext journalContext) throws InvalidPathException
path1
- the first path to locklockPattern1
- the locking pattern for the first pathpath2
- the second path to locklockPattern2
- the locking pattern for the second pathjournalContext
- the journal context to flush when the LockedInodePath releasesInodePathPair
representing the two locked pathsInvalidPathException
- if a path is invalidpublic void ensureFullInodePath(LockedInodePath inodePath) throws InvalidPathException, FileDoesNotExistException
LockedInodePath
to reach the target inode (the last
inode for the full path). If the target inode does not exist, an exception will be thrown.inodePath
- the LockedInodePath
to extend to the target inodeInvalidPathException
- if the path is invalidFileDoesNotExistException
- if the target inode does not existpublic ArrayList<String> getPathInodeNames(InodeView inode) throws FileDoesNotExistException
inode
- the inode view to calculate the path forFileDoesNotExistException
- if the path to the inode doesn't existpublic ArrayList<String> getPathInodeNames(long id) throws FileDoesNotExistException
id
- the inode id to calculate the path forFileDoesNotExistException
- if the path to the inode doesn't existpublic AlluxioURI getPath(long id) throws FileDoesNotExistException
id
- the inode id to get the path forAlluxioURI
for the path of the inodeFileDoesNotExistException
- if the path does not existpublic AlluxioURI getPath(InodeView inode) throws FileDoesNotExistException
inode
- the inode to get the path forAlluxioURI
for the path of the inodeFileDoesNotExistException
- if the path does not existpublic InodeDirectory getRoot()
public List<Inode> createPath(RpcContext rpcContext, LockedInodePath inodePath, CreatePathContext<?,?> context) throws FileAlreadyExistsException, BlockInfoException, InvalidPathException, IOException, FileDoesNotExistException
rpcContext
- the rpc contextinodePath
- the pathcontext
- method contextFileAlreadyExistsException
- when there is already a file at path if we want to create a
directory thereBlockInfoException
- when blockSizeBytes is invalidInvalidPathException
- when path is invalid, for example, (1) when there is nonexistent
necessary parent directories and recursive is false, (2) when one of the necessary
parent directories is actually a fileFileDoesNotExistException
- if the parent of the path does not exist and the recursive
option is falseIOException
public LockedInodePathList getDescendants(LockedInodePath inodePath)
LockedInodePath
s for all descendants of inodePath.inodePath
- a locked inode path. It must be write-lockedpublic void deleteInode(RpcContext rpcContext, LockedInodePath inodePath, long opTimeMs) throws FileDoesNotExistException
rpcContext
- the rpc contextinodePath
- the LockedInodePath
to deleteopTimeMs
- the operation timeFileDoesNotExistException
- if the Inode cannot be retrievedpublic void setPinned(RpcContext rpcContext, LockedInodePath inodePath, boolean pinned, List<String> mediumTypes, long opTimeMs) throws FileDoesNotExistException, InvalidPathException
rpcContext
- the rpc contextinodePath
- the LockedInodePath
to set the pinned state forpinned
- the pinned state to set for the inode (and possible descendants)mediumTypes
- the list of pinned media that that the file can reside inopTimeMs
- the operation timeFileDoesNotExistException
- if inode does not existInvalidPathException
public void setReplication(RpcContext rpcContext, LockedInodePath inodePath, Integer replicationMax, Integer replicationMin, long opTimeMs) throws FileDoesNotExistException, InvalidPathException
rpcContext
- the rpc contextinodePath
- the LockedInodePath
to set the pinned state forreplicationMax
- the max replication level to set for the inode (and possible descendants)replicationMin
- the min replication level to set for the inode (and possible descendants)opTimeMs
- the operation timeFileDoesNotExistException
- if inode does not existInvalidPathException
public Set<Long> getReplicationLimitedFileIds()
public Set<Long> getToBePersistedIds()
PersistenceState.TO_BE_PERSISTED
public InodeLockManager getInodeLockManager()
public boolean isRootId(long fileId)
fileId
- the file id to checkpublic Journaled getDelegate()
getDelegate
in interface DelegatingJournaled
public void syncPersistExistingDirectory(java.util.function.Supplier<JournalContext> context, InodeDirectoryView dir, boolean isMetadataLoad) throws IOException, InvalidPathException, FileDoesNotExistException
context
- journal context supplierdir
- the inode directory to persistisMetadataLoad
- if this operation is the result of a metadata loadInvalidPathException
- if the path for the inode is invalidFileDoesNotExistException
- if the path for the inode is invalidIOException
public void syncPersistNewDirectory(MutableInodeDirectory dir, CreatePathContext<?,?> createContext) throws InvalidPathException, FileDoesNotExistException, IOException
dir
- the inode directory to persistcreateContext
- the create directory contextInvalidPathException
FileDoesNotExistException
IOException
public void close() throws IOException
IOException
Copyright © 2023. All Rights Reserved.