@ThreadSafe public final class TtlBucketList extends Object implements Checkpointed
TtlBucket
s sorted by ttl interval start time of each bucket.
Two adjacent buckets may not have adjacent intervals since there may be no inodes with ttl value in the skipped intervals.
Constructor and Description |
---|
TtlBucketList(ReadOnlyInodeStore inodeStore)
Creates a new list of
TtlBucket s. |
Modifier and Type | Method and Description |
---|---|
CheckpointName |
getCheckpointName() |
int |
getNumBuckets() |
long |
getNumInodes() |
void |
insert(Inode inode)
Insert inode to the ttlbucket with default number of retry attempts.
|
void |
insert(Inode inode,
int numOfRetry)
Inserts an inode to the appropriate bucket where its ttl end time lies in the
bucket's interval, if no appropriate bucket exists, a new bucket will be created to contain
this inode, if ttl value is
Constants.NO_TTL , the inode won't be inserted to any
buckets and nothing will happen. |
Inode |
loadInode(long inodeId)
Load inode from inode store on processing the provided inode id.
|
Set<TtlBucket> |
pollExpiredBuckets(long time)
Polls buckets whose ttl interval has expired before the specified time, that is, the
bucket's interval start time should be less than or equal to (specified time - ttl interval).
|
void |
remove(InodeView inode)
Removes an inode from the bucket containing it if the inode is in one
of the buckets, otherwise, do nothing.
|
void |
restoreFromCheckpoint(CheckpointInputStream input)
Restores state from a checkpoint.
|
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
restoreFromCheckpoint, writeToCheckpoint
public TtlBucketList(ReadOnlyInodeStore inodeStore)
TtlBucket
s.inodeStore
- the inode storepublic Inode loadInode(long inodeId)
inodeId
- public int getNumBuckets()
public long getNumInodes()
public void insert(Inode inode)
inode
- public void insert(Inode inode, int numOfRetry)
Constants.NO_TTL
, the inode won't be inserted to any
buckets and nothing will happen.inode
- the inode to be insertednumOfRetry
- number of retries left to process this inodepublic void remove(InodeView inode)
Assume that no inode in the buckets has ttl value that equals Constants.NO_TTL
.
If an inode with valid ttl value is inserted to the buckets and its ttl value is
going to be set to Constants.NO_TTL
later, be sure to remove the inode
from the buckets first.
inode
- the inode to be removedpublic Set<TtlBucket> pollExpiredBuckets(long time)
insert(Inode)
time
- the expiration timepublic 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.