@ThreadSafe public final class TtlBucketList extends Object
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()
Creates a new list of
TtlBucket s. |
Modifier and Type | Method and Description |
---|---|
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).
|
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(Inode<?> 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.
|
public TtlBucketList()
TtlBucket
s.public void insert(Inode<?> inode)
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
- the inode to be insertedpublic void remove(Inode<?> 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 timeCopyright © 2023. All Rights Reserved.