@ThreadSafe public final class CachingInodeStore extends Object implements InodeStore, Closeable
We call the other inode store the backing store. Backing store operations are much slower than on-heap operations, so we aim to serve as many requests as possible from the cache.
When the inode tree fits completely within the cache, we never interact with the backing store,
so performance should be similar to HeapInodeStore
. Once the cache reaches the high
watermark, we begin evicting metadata to the backing store, and performance becomes dependent on
cache hit rate and backing store performance.
The CachingInodeStore uses 3 caches: an inode cache, and edge cache, and a listing cache. The inode cache stores inode metadata such as inode names, permissions, and sizes. The edge cache stores edge metadata, i.e. which inodes are children of which other inodes. The listing cache caches the results of calling getChildren.
See the javadoc for InodeCache
, EdgeCache
, and ListingCache
for details
about their inner workings.
InodeStore.Factory, InodeStore.WriteBatch
Constructor and Description |
---|
CachingInodeStore(InodeStore backingStore,
InodeLockManager lockManager) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(long parentId,
String childName,
Long childId)
Makes an inode the child of the specified parent.
|
Set<EdgeEntry> |
allEdges() |
Set<MutableInode<?>> |
allInodes() |
void |
clear()
Removes all inodes and edges.
|
void |
close() |
CheckpointName |
getCheckpointName() |
Optional<Inode> |
getChild(Long inodeId,
String name,
ReadOption option) |
Optional<Long> |
getChildId(Long inodeId,
String name,
ReadOption option) |
CloseableIterator<Long> |
getChildIds(Long inodeId,
ReadOption option)
Returns an iterable for the ids of the children of the given directory.
|
Optional<MutableInode<?>> |
getMutable(long id,
ReadOption option)
Gets a mutable representation of the specified inode.
|
boolean |
hasChildren(InodeDirectoryView inode,
ReadOption option) |
void |
remove(Long inodeId)
Removes an inode from the inode store.
|
void |
removeChild(long parentId,
String name)
Removes a child from a parent inode.
|
void |
restoreFromCheckpoint(CheckpointInputStream input)
Restores state from a checkpoint.
|
void |
writeInode(MutableInode<?> inode)
Adds the given inode, or overwrites it if it already exists.
|
void |
writeNewInode(MutableInode<?> inode)
Adds a new inode.
|
void |
writeToCheckpoint(OutputStream output)
Writes a checkpoint of all state to the given output stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChild, createWriteBatch, get, getInodePathString, getMutable, remove, removeInodeAndParentEdge, supportsBatchWrite
get, getChild, getChild, getChild, getChildId, getChildId, getChildIds, getChildIds, getChildren, getChildren, getChildren, getChildren, getChildrenFrom, getChildrenPrefix, getChildrenPrefixFrom, hasChildren
public CachingInodeStore(InodeStore backingStore, InodeLockManager lockManager)
backingStore
- the backing inode storelockManager
- inode lock managerpublic Optional<MutableInode<?>> getMutable(long id, ReadOption option)
InodeStore
getMutable
in interface InodeStore
id
- an inode idoption
- read optionspublic void remove(Long inodeId)
InodeStore
remove
in interface InodeStore
inodeId
- an inode to removepublic void writeInode(MutableInode<?> inode)
InodeStore
InodeStore.writeNewInode(MutableInode)
.
This method requires an inode lock manager read or write lock on the written inode.writeInode
in interface InodeStore
inode
- the inode to writepublic void writeNewInode(MutableInode<?> inode)
InodeStore
InodeStore.writeInode(MutableInode)
, but with an added information that
the inode is new. This allows some inode stores to perform extra optimizations.
This method requires an inode lock manager read or write lock on the written inode.writeNewInode
in interface InodeStore
inode
- the inode to writepublic void clear()
InodeStore
clear
in interface InodeStore
public void addChild(long parentId, String childName, Long childId)
InodeStore
addChild
in interface InodeStore
parentId
- the parent idchildName
- the child namechildId
- the child inode idpublic void removeChild(long parentId, String name)
InodeStore
removeChild
in interface InodeStore
parentId
- the parent inode idname
- the child namepublic CloseableIterator<Long> getChildIds(Long inodeId, ReadOption option)
ReadOnlyInodeStore
getChildIds
in interface ReadOnlyInodeStore
inodeId
- an inode id to list child ids foroption
- the optionspublic Optional<Long> getChildId(Long inodeId, String name, ReadOption option)
getChildId
in interface ReadOnlyInodeStore
inodeId
- an inode idname
- an inode nameoption
- the optionspublic Optional<Inode> getChild(Long inodeId, String name, ReadOption option)
getChild
in interface ReadOnlyInodeStore
inodeId
- an inode idname
- an inode nameoption
- the optionspublic boolean hasChildren(InodeDirectoryView inode, ReadOption option)
hasChildren
in interface ReadOnlyInodeStore
inode
- an inode directoryoption
- the optionspublic Set<EdgeEntry> allEdges()
allEdges
in interface ReadOnlyInodeStore
public Set<MutableInode<?>> allInodes()
allInodes
in interface ReadOnlyInodeStore
public void close()
close
in interface InodeStore
close
in interface Closeable
close
in interface AutoCloseable
public CheckpointName getCheckpointName()
getCheckpointName
in interface Checkpointed
public void writeToCheckpoint(OutputStream output) throws IOException, InterruptedException
Checkpointed
InterruptedException
if they get
interrupted while running.writeToCheckpoint
in interface Checkpointed
output
- the output stream to write toIOException
InterruptedException
public void restoreFromCheckpoint(CheckpointInputStream input) throws IOException
Checkpointed
restoreFromCheckpoint
in interface Checkpointed
input
- an input stream with checkpoint dataIOException
Copyright © 2023. All Rights Reserved.