T
- the concrete subclass of this object@NotThreadSafe public abstract class Inode<T> extends Object implements JournalEntryRepresentable
Inode
is an abstract class, with information shared by all types of Inodes. The inode
must be locked (lockRead()
or lockWrite()
) before methods are called.Modifier and Type | Field and Description |
---|---|
protected long |
mCreationTimeMs |
protected boolean |
mDirectory |
protected long |
mId |
protected long |
mTtl |
protected TtlAction |
mTtlAction |
Modifier | Constructor and Description |
---|---|
protected |
Inode(long id,
boolean isDirectory) |
Modifier and Type | Method and Description |
---|---|
boolean |
compareAndSwap(PersistenceState oldState,
PersistenceState newState)
Compare-and-swaps the persistence state.
|
boolean |
equals(Object o) |
abstract FileInfo |
generateClientFileInfo(String path)
Generates a
FileInfo of the file or folder. |
long |
getCreationTimeMs() |
String |
getGroup() |
long |
getId() |
long |
getLastModificationTimeMs() |
short |
getMode() |
String |
getName() |
String |
getOwner() |
long |
getParentId() |
PersistenceState |
getPersistenceState() |
protected abstract T |
getThis() |
long |
getTtl() |
TtlAction |
getTtlAction() |
String |
getUfsFingerprint() |
int |
hashCode() |
boolean |
isDeleted() |
boolean |
isDirectory() |
boolean |
isFile() |
boolean |
isPersisted() |
boolean |
isPinned() |
boolean |
isReadLocked() |
boolean |
isWriteLocked() |
void |
lockRead()
Obtains a read lock on the inode.
|
void |
lockReadAndCheckNameAndParent(Inode parent,
String name)
Obtains a read lock on the inode.
|
void |
lockReadAndCheckParent(Inode parent)
Obtains a read lock on the inode.
|
void |
lockWrite()
Obtains a write lock on the inode.
|
void |
lockWriteAndCheckNameAndParent(Inode parent,
String name)
Obtains a write lock on the inode.
|
void |
lockWriteAndCheckParent(Inode parent)
Obtains a write lock on the inode.
|
T |
setCreationTimeMs(long creationTimeMs) |
T |
setDeleted(boolean deleted) |
T |
setGroup(String group) |
T |
setLastModificationTimeMs(long lastModificationTimeMs)
Sets the last modification time of the inode to the new time if the new time is more recent.
|
T |
setLastModificationTimeMs(long lastModificationTimeMs,
boolean override) |
T |
setMode(short mode) |
T |
setName(String name) |
T |
setOwner(String owner) |
T |
setParentId(long parentId) |
T |
setPersistenceState(PersistenceState persistenceState) |
T |
setPinned(boolean pinned) |
T |
setTtl(long ttl) |
T |
setTtlAction(TtlAction ttlAction) |
T |
setUfsFingerprint(String ufsFingerprint) |
protected com.google.common.base.Objects.ToStringHelper |
toStringHelper() |
void |
unlockRead()
Releases the read lock for this inode.
|
void |
unlockWrite()
Releases the write lock for this inode.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
toJournalEntry
protected long mCreationTimeMs
protected final boolean mDirectory
protected final long mId
protected long mTtl
protected TtlAction mTtlAction
public long getCreationTimeMs()
public String getGroup()
public long getId()
public long getTtl()
public long getLastModificationTimeMs()
public String getName()
public short getMode()
public PersistenceState getPersistenceState()
PersistenceState
of the inodepublic boolean compareAndSwap(PersistenceState oldState, PersistenceState newState)
oldState
- the old PersistenceState
newState
- the new PersistenceState
to setpublic long getParentId()
public String getOwner()
public boolean isDeleted()
public boolean isDirectory()
public boolean isFile()
public boolean isPinned()
public boolean isPersisted()
public String getUfsFingerprint()
public T setCreationTimeMs(long creationTimeMs)
creationTimeMs
- the creation time to use (in milliseconds)public T setDeleted(boolean deleted)
deleted
- the deleted flag to usepublic T setGroup(String group)
group
- the group of the inodepublic T setLastModificationTimeMs(long lastModificationTimeMs)
lastModificationTimeMs
- the last modification time to usepublic T setLastModificationTimeMs(long lastModificationTimeMs, boolean override)
lastModificationTimeMs
- the last modification time to useoverride
- if true, sets the value regardless of the previous last modified time,
should be set to true for journal replaypublic T setName(String name)
name
- the name to usepublic T setParentId(long parentId)
parentId
- the parent id to usepublic T setTtl(long ttl)
ttl
- the TTL to use, in millisecondspublic T setTtlAction(TtlAction ttlAction)
ttlAction
- the TtlAction
to usepublic T setPersistenceState(PersistenceState persistenceState)
persistenceState
- the PersistenceState
to usepublic T setPinned(boolean pinned)
pinned
- the pinned flag value to usepublic T setOwner(String owner)
owner
- the owner name of the inodepublic T setMode(short mode)
mode
- the mode of the inodepublic T setUfsFingerprint(String ufsFingerprint)
ufsFingerprint
- the ufs fingerprint to usepublic abstract FileInfo generateClientFileInfo(String path)
FileInfo
of the file or folder.path
- the path of the fileFileInfo
protected abstract T getThis()
this
so that the abstract class can use the fluent builder patternpublic void lockRead()
public void lockReadAndCheckParent(Inode parent) throws InvalidPathException
parent
- the expected parent inodeInvalidPathException
- if the parent is not as expectedpublic void lockReadAndCheckNameAndParent(Inode parent, String name) throws InvalidPathException
parent
- the expected parent inodename
- the expected name of the inode to be lockedInvalidPathException
- if the parent and/or name is not as expectedpublic void lockWrite()
public void lockWriteAndCheckParent(Inode parent) throws InvalidPathException
parent
- the expected parent inodeInvalidPathException
- if the parent is not as expectedpublic void lockWriteAndCheckNameAndParent(Inode parent, String name) throws InvalidPathException
parent
- the expected parent inodename
- the expected name of the inode to be lockedInvalidPathException
- if the parent and/or name is not as expectedpublic void unlockRead()
public void unlockWrite()
public boolean isWriteLocked()
public boolean isReadLocked()
protected com.google.common.base.Objects.ToStringHelper toStringHelper()
Copyright © 2023. All Rights Reserved.