public class BlobCacheSizeTracker extends Object
LinkedHashMap
to maintain the LRU order for the files in the
cache. When new files are intended to be put into cache, checkLimit
is called to query
the files should be removed. This tracker maintains a lock to avoid concurrent modification. To
avoid the inconsistency, make sure that hold the READ/WRITE lock in PermanentBlobCache
first and then hold the lock here.Modifier and Type | Field and Description |
---|---|
protected long |
sizeLimit |
Constructor and Description |
---|
BlobCacheSizeTracker(long sizeLimit) |
Modifier and Type | Method and Description |
---|---|
List<Tuple2<JobID,BlobKey>> |
checkLimit(long size)
Check the size limit and return the BLOBs to delete.
|
void |
track(JobID jobId,
BlobKey blobKey,
long size)
Register the BLOB to the tracker.
|
void |
untrack(Tuple2<JobID,BlobKey> key)
Remove the BLOB from the tracker.
|
void |
untrackAll(JobID jobId)
Unregister all the tracked BLOBs related to the given job.
|
void |
update(JobID jobId,
BlobKey blobKey)
Update the least used index for the BLOBs so that the tracker can easily find out the least
recently used BLOBs.
|
public List<Tuple2<JobID,BlobKey>> checkLimit(long size)
size
- size of the BLOB intended to put into the cachepublic void update(JobID jobId, BlobKey blobKey)
public void untrackAll(JobID jobId)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.