@NotThreadSafe public class LockedInodePath extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
protected InodeLockList |
mLockList
Lock list locking some portion of the path according to mLockPattern.
|
protected InodeTree.LockPattern |
mLockPattern
The locking pattern.
|
protected String[] |
mPathComponents
The components of mUri.
|
protected AlluxioURI |
mUri
Uri for the path represented.
|
Constructor and Description |
---|
LockedInodePath(AlluxioURI uri,
ReadOnlyInodeStore inodeStore,
InodeLockManager inodeLockManager,
InodeDirectory root,
InodeTree.LockPattern lockPattern,
boolean tryLock,
JournalContext journalContext)
Creates a new locked inode path.
|
Modifier and Type | Method and Description |
---|---|
void |
addNextInode(Inode inode)
Adds the next inode to the path.
|
void |
close() |
void |
downgradeToRead()
Downgrades all locks in this list to read locks.
|
boolean |
fullPathExists() |
Inode |
getAncestorInode()
Returns the closest ancestor of the target inode (last inode in the full path).
|
int |
getExistingInodeCount() |
Inode |
getInode() |
InodeFile |
getInodeFile() |
List<Inode> |
getInodeList() |
Inode |
getInodeOrNull() |
List<InodeView> |
getInodeViewList() |
Inode |
getLastExistingInode() |
InodeTree.LockPattern |
getLockPattern() |
InodeDirectory |
getParentInodeDirectory() |
Inode |
getParentInodeOrNull() |
AlluxioURI |
getUri() |
LockedInodePath |
lockChild(Inode child,
InodeTree.LockPattern lockPattern)
Returns a new locked inode path composed of the current path plus the child inode.
|
LockedInodePath |
lockChild(Inode child,
InodeTree.LockPattern lockPattern,
String[] childComponentsHint)
Efficient version of
#lockChild(Inode, LockPattern) for when the child path
components are already known. |
LockedInodePath |
lockChildByName(String childName,
InodeTree.LockPattern lockPattern,
String[] childComponentsHint)
Efficient version of
#lockChild(Inode, LockPattern) for when the child path
components are already known. |
LockedInodePath |
lockDescendant(AlluxioURI descendantUri,
InodeTree.LockPattern lockPattern)
Locks a descendant of the current path and returns a new locked inode path.
|
LockedInodePath |
lockFinalEdgeWrite()
Returns a copy of the path with the final edge write locked.
|
void |
removeLastInode()
Removes the last inode from the list.
|
int |
size() |
String |
toString() |
void |
traverse()
Traverses the inode path according to its lock pattern.
|
protected final AlluxioURI mUri
protected final String[] mPathComponents
protected final InodeLockList mLockList
protected InodeTree.LockPattern mLockPattern
public LockedInodePath(AlluxioURI uri, ReadOnlyInodeStore inodeStore, InodeLockManager inodeLockManager, InodeDirectory root, InodeTree.LockPattern lockPattern, boolean tryLock, JournalContext journalContext) throws InvalidPathException
uri
- the uri for the pathinodeStore
- the inode store for looking up inode childreninodeLockManager
- the inode lock managerroot
- the root inodelockPattern
- the pattern to lock intryLock
- whether or not use Lock.tryLock()
or Lock.lock()
journalContext
- the journal context to flush when the lock is releasedInvalidPathException
public AlluxioURI getUri()
public Inode getInode() throws FileDoesNotExistException
FileDoesNotExistException
- if the target inode does not exist@Nullable public Inode getInodeOrNull()
public InodeFile getInodeFile() throws FileDoesNotExistException
MutableInodeFile
FileDoesNotExistException
- if the target inode does not exist, or it is not a filepublic InodeDirectory getParentInodeDirectory() throws InvalidPathException, FileDoesNotExistException
InvalidPathException
- if the parent inode is not a directoryFileDoesNotExistException
- if the parent of the target does not exist@Nullable public Inode getParentInodeOrNull()
public Inode getLastExistingInode()
public List<Inode> getInodeList()
public List<InodeView> getInodeViewList()
public int getExistingInodeCount()
public int size()
public boolean fullPathExists()
public InodeTree.LockPattern getLockPattern()
InodeTree.LockPattern
of this pathpublic void removeLastInode()
public void addNextInode(Inode inode)
inode
- the inode to addpublic void downgradeToRead()
public Inode getAncestorInode() throws FileDoesNotExistException
FileDoesNotExistException
- if an ancestor does not existpublic LockedInodePath lockDescendant(AlluxioURI descendantUri, InodeTree.LockPattern lockPattern) throws InvalidPathException
descendantUri
- the full descendent uri starting from the rootlockPattern
- the lock pattern to lock inInvalidPathException
public LockedInodePath lockChild(Inode child, InodeTree.LockPattern lockPattern) throws InvalidPathException
child
- the child inodelockPattern
- the lock patternInvalidPathException
public LockedInodePath lockChild(Inode child, InodeTree.LockPattern lockPattern, String[] childComponentsHint) throws InvalidPathException
#lockChild(Inode, LockPattern)
for when the child path
components are already known.child
- the child inodelockPattern
- the lock patternchildComponentsHint
- path components for the new pathInvalidPathException
public LockedInodePath lockChildByName(String childName, InodeTree.LockPattern lockPattern, String[] childComponentsHint) throws InvalidPathException
#lockChild(Inode, LockPattern)
for when the child path
components are already known.childName
- the name of the child inodelockPattern
- the lock patternchildComponentsHint
- path components for the new pathInvalidPathException
public LockedInodePath lockFinalEdgeWrite() throws InvalidPathException
InvalidPathException
public void traverse() throws InvalidPathException
InodeTree.LockPattern
.
Journals are not flushed in this method because:
1. When a LockedInodePath is created, it will be traversed first before any journal is written
2. The only use cases that call this method independently are in metadata sync
InodeSyncStream
. Where traverse() is called right before the
lock is released, where the journals will be flushed anyway.InvalidPathException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2023. All Rights Reserved.