@NotThreadSafe public class InodeTree extends Object implements JournalEntryIterable
Modifier and Type | Class and Description |
---|---|
static class |
InodeTree.CreatePathResult
Represents the results of creating a path in the inode tree.
|
static class |
InodeTree.LockMode
The type of lock to lock inode paths with.
|
Modifier and Type | Field and Description |
---|---|
static long |
NO_PARENT
Value to be used for an inode with no parent.
|
Constructor and Description |
---|
InodeTree(ContainerIdGenerable containerIdGenerator,
InodeDirectoryIdGenerator directoryIdGenerator,
MountTable mountTable) |
Modifier and Type | Method and Description |
---|---|
void |
addInodeDirectoryFromJournal(File.InodeDirectoryEntry entry)
Adds the directory represented by the entry parameter into the inode tree.
|
void |
addInodeFileFromJournal(File.InodeFileEntry entry)
Adds the file represented by the entry parameter into the inode tree.
|
InodeTree.CreatePathResult |
createPath(RpcContext rpcContext,
LockedInodePath inodePath,
CreatePathOptions<?> options)
Creates a file or directory at path.
|
void |
deleteInode(RpcContext rpcContext,
LockedInodePath inodePath,
long opTimeMs,
DeleteOptions deleteOptions)
Deletes a single inode from the inode tree by removing it from the parent inode.
|
void |
ensureFullInodePath(LockedInodePath inodePath,
InodeTree.LockMode lockMode)
Attempts to extend an existing
LockedInodePath to reach the target inode (the last
inode for the full path). |
boolean |
equals(Object o) |
Iterator<Journal.JournalEntry> |
getJournalEntryIterator() |
AlluxioURI |
getPath(Inode<?> inode)
Returns the path for a particular inode.
|
Set<Long> |
getPinIdSet() |
int |
getPinnedSize() |
InodeDirectory |
getRoot() |
String |
getRootUserName() |
int |
getSize() |
int |
hashCode() |
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 |
isRootId(long fileId) |
LockedInodePath |
lockChildPath(LockedInodePath inodePath,
InodeTree.LockMode lockMode,
Inode<?> childInode,
String[] pathComponents)
Lock from a specific poiint in the tree to the immediate child, and return a lockedInodePath.
|
LockedInodePath |
lockDescendantPath(LockedInodePath inodePath,
InodeTree.LockMode lockMode,
AlluxioURI descendantUri)
Locks from a specific point in the tree to the descendant, and return a lockedInodePath.
|
LockedInodePathList |
lockDescendants(LockedInodePath inodePath,
InodeTree.LockMode lockMode)
Locks all descendants of a particular
LockedInodePath . |
LockedInodePath |
lockFullInodePath(AlluxioURI path,
InodeTree.LockMode lockMode)
Locks existing inodes on the specified path, in the specified
InodeTree.LockMode . |
LockedInodePath |
lockFullInodePath(long id,
InodeTree.LockMode lockMode)
Locks existing inodes on the path to the inode specified by an id, in the specified
InodeTree.LockMode . |
LockedInodePath |
lockInodePath(AlluxioURI path,
InodeTree.LockMode lockMode)
Locks existing inodes on the specified path, in the specified
InodeTree.LockMode . |
InodePathPair |
lockInodePathPair(AlluxioURI path1,
InodeTree.LockMode lockMode1,
AlluxioURI path2,
InodeTree.LockMode lockMode2)
Locks existing inodes on the two specified paths.
|
long |
reinitializeFile(LockedInodePath inodePath,
long blockSizeBytes,
long ttl,
TtlAction ttlAction)
Reinitializes the block size and TTL of an existing open file.
|
void |
reset()
Resets the inode tree.
|
void |
setPinned(LockedInodePath inodePath,
boolean pinned)
Sets the pinned state of an inode.
|
void |
setPinned(LockedInodePath inodePath,
boolean pinned,
long opTimeMs)
Sets the pinned state of an inode.
|
void |
syncPersistDirectory(RpcContext rpcContext,
InodeDirectory dir)
Synchronously persists an
InodeDirectory to the UFS. |
public static final long NO_PARENT
public InodeTree(ContainerIdGenerable containerIdGenerator, InodeDirectoryIdGenerator directoryIdGenerator, MountTable mountTable)
containerIdGenerator
- 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 pointspublic 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
@Nullable public String getRootUserName()
public int getSize()
public int getPinnedSize()
public boolean inodeIdExists(long id)
id
- the id to get the inode forpublic boolean inodePathExists(AlluxioURI uri)
uri
- the AlluxioURI
to check for existencepublic LockedInodePath lockInodePath(AlluxioURI path, InodeTree.LockMode lockMode) throws InvalidPathException
InodeTree.LockMode
. The target
inode is not required to exist.path
- the path to locklockMode
- the InodeTree.LockMode
to lock the inodes withLockedInodePath
representing the locked path of inodesInvalidPathException
- if the path is invalidpublic InodePathPair lockInodePathPair(AlluxioURI path1, InodeTree.LockMode lockMode1, AlluxioURI path2, InodeTree.LockMode lockMode2) throws InvalidPathException
path1
- the first path to locklockMode1
- the InodeTree.LockMode
of the first pathpath2
- the second path to locklockMode2
- the InodeTree.LockMode
of the second pathInodePathPair
representing the two locked pathsInvalidPathException
- if a path is invalidpublic LockedInodePath lockFullInodePath(AlluxioURI path, InodeTree.LockMode lockMode) throws InvalidPathException, FileDoesNotExistException
InodeTree.LockMode
. The target
inode must exist.path
- the AlluxioURI
path to locklockMode
- the InodeTree.LockMode
to lock the inodes withLockedInodePath
representing the locked path of inodesInvalidPathException
- if the path is invalidFileDoesNotExistException
- if the target inode does not existpublic LockedInodePath lockFullInodePath(long id, InodeTree.LockMode lockMode) throws FileDoesNotExistException
InodeTree.LockMode
. The target inode must exist. This may require multiple traversals of the
tree, so may be inefficient.id
- the inode idlockMode
- the InodeTree.LockMode
to lock the inodes withLockedInodePath
representing the locked path of inodesFileDoesNotExistException
- if the target inode does not existpublic void ensureFullInodePath(LockedInodePath inodePath, InodeTree.LockMode lockMode) 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 inodelockMode
- the InodeTree.LockMode
to lock the inodes withInvalidPathException
- if the path is invalidFileDoesNotExistException
- if the target inode does not existpublic AlluxioURI getPath(Inode<?> 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 InodeTree.CreatePathResult createPath(RpcContext rpcContext, LockedInodePath inodePath, CreatePathOptions<?> options) throws FileAlreadyExistsException, BlockInfoException, InvalidPathException, IOException, FileDoesNotExistException
rpcContext
- the rpc contextinodePath
- the pathoptions
- method optionsInodeTree.CreatePathResult
representing the modified inodes and created inodes during
path creationFileAlreadyExistsException
- 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 long reinitializeFile(LockedInodePath inodePath, long blockSizeBytes, long ttl, TtlAction ttlAction) throws InvalidPathException, FileDoesNotExistException
inodePath
- the path to the fileblockSizeBytes
- the new block sizettl
- the ttlttlAction
- action to perform after TTL expiryInvalidPathException
- if the path is invalidFileDoesNotExistException
- if the path does not existpublic LockedInodePath lockDescendantPath(LockedInodePath inodePath, InodeTree.LockMode lockMode, AlluxioURI descendantUri) throws InvalidPathException
inodePath
- the root to start lockinglockMode
- the lock type to usedescendantUri
- the path to the descendant that we are lockingInodeLockList
representing the list of descendants that got locked as
a result of this call.FileDoesNotExistException
- if inode does not existInvalidPathException
public LockedInodePath lockChildPath(LockedInodePath inodePath, InodeTree.LockMode lockMode, Inode<?> childInode, String[] pathComponents) throws FileDoesNotExistException, InvalidPathException
inodePath
- the root to start lockinglockMode
- the lock type to usechildInode
- the inode of the child that we are lockingpathComponents
- the array of pre-parsed path components, or null to parse pathComponents
from the uriInodeLockList
representing the list of descendants that got locked as
a result of this call.FileDoesNotExistException
- if the inode does not existInvalidPathException
- if the path is invalidpublic LockedInodePathList lockDescendants(LockedInodePath inodePath, InodeTree.LockMode lockMode)
LockedInodePath
. Any directory inode
precedes its descendants in the list.inodePath
- the root LockedInodePath
to retrieve all descendants fromlockMode
- the lock type to useInodeLockList
representing the list of all descendantspublic void deleteInode(RpcContext rpcContext, LockedInodePath inodePath, long opTimeMs, DeleteOptions deleteOptions) throws FileDoesNotExistException
rpcContext
- the rpc contextinodePath
- the LockedInodePath
to deleteopTimeMs
- the operation timedeleteOptions
- the delete optionsFileDoesNotExistException
- if the Inode cannot be retrievedpublic void setPinned(LockedInodePath inodePath, boolean pinned, long opTimeMs) throws FileDoesNotExistException
inodePath
- the LockedInodePath
to set the pinned state forpinned
- the pinned state to set for the inode (and possible descendants)opTimeMs
- the operation timeFileDoesNotExistException
- if inode does not existpublic void setPinned(LockedInodePath inodePath, boolean pinned) throws FileDoesNotExistException, InvalidPathException
inodePath
- the LockedInodePath
to set the pinned state forpinned
- the pinned state to set for the inode (and possible descendants)FileDoesNotExistException
- if inode does not existInvalidPathException
public boolean isRootId(long fileId)
fileId
- the file id to checkpublic Iterator<Journal.JournalEntry> getJournalEntryIterator()
getJournalEntryIterator
in interface JournalEntryIterable
Iterator
that iterates all the journal entriespublic void addInodeFileFromJournal(File.InodeFileEntry entry)
entry
- the journal entry representing an inodepublic void addInodeDirectoryFromJournal(File.InodeDirectoryEntry entry) throws AccessControlException
entry
- the journal entry representing an inodeAccessControlException
- when owner of mRoot is not the owner of root journal entrypublic void reset()
public void syncPersistDirectory(RpcContext rpcContext, InodeDirectory dir) throws IOException, InvalidPathException, FileDoesNotExistException
InodeDirectory
to the UFS. If concurrent calls are made, only
one thread will persist to UFS, and the others will wait until it is persisted.rpcContext
- the rpc contextdir
- the InodeDirectory
to persistInvalidPathException
- if the path for the inode is invalidFileDoesNotExistException
- if the path for the inode is invalidIOException
Copyright © 2023. All Rights Reserved.