@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() |
Set<TtlBucket> |
getExpiredBuckets(long time)
Retrieves 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).
|
int |
getNumBuckets() |
long |
getNumInodes() |
void |
insert(Inode inode)
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. |
void |
remove(InodeView inode)
Removes a inode from the bucket containing it if the inode is in one of the buckets, otherwise,
do nothing.
|
void |
removeBuckets(Set<TtlBucket> buckets)
Removes all buckets in the set.
|
void |
restoreFromCheckpoint(CheckpointInputStream input)
Restores state from a checkpoint.
|
void |
writeToCheckpoint(OutputStream output)
Writes a checkpoint of all state to the given output stream.
|
public TtlBucketList(ReadOnlyInodeStore inodeStore)
TtlBucket
s.inodeStore
- the inode storepublic int getNumBuckets()
public long getNumInodes()
public void insert(Inode inode)
Constants.NO_TTL
, the inode won't be inserted to any
buckets and nothing will happen.inode
- the inode to be insertedpublic void remove(InodeView inode)
Assume that no inode in the buckets has ttl value that equals Constants.NO_TTL
.
If a 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> getExpiredBuckets(long time)
time
- the expiration timepublic void removeBuckets(Set<TtlBucket> buckets)
buckets
- a set of buckets to be removedpublic 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.