@InterfaceAudience.Private public class MobFileCache extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
MobFileCache.EvictionThread |
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private AtomicLong |
count |
private LongAdder |
evictedFileCount |
private ReentrantLock |
evictionLock |
private float |
evictRemainRatio |
private boolean |
isCacheEnabled |
private IdLock |
keyLock |
private long |
lastAccess |
private long |
lastEvictedFileCount |
private long |
lastMiss |
private static org.slf4j.Logger |
LOG |
private Map<String,CachedMobFile> |
map |
private LongAdder |
miss |
private int |
mobFileMaxCacheSize |
private ScheduledExecutorService |
scheduleThreadPool |
Constructor and Description |
---|
MobFileCache(org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
void |
closeFile(MobFile file)
Closes a mob file.
|
void |
evict()
Evicts the lru cached mob files when the count of the cached files is larger than the
threshold.
|
void |
evictFile(String fileName)
Evicts the cached file by the name.
|
long |
getAccessCount()
Gets the count of accesses to the mob file cache.
|
int |
getCacheSize()
Gets the count of cached mob files.
|
long |
getEvictedFileCount()
Gets the number of items evicted from the mob file cache.
|
double |
getHitRatio()
Gets the hit ratio to the mob file cache.
|
long |
getMissCount()
Gets the count of misses to the mob file cache.
|
MobFile |
openFile(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
CacheConfig cacheConf)
Opens a mob file.
|
void |
printStatistics()
Prints the statistics.
|
void |
shutdown() |
private static final org.slf4j.Logger LOG
private Map<String,CachedMobFile> map
private final AtomicLong count
private long lastAccess
private long lastMiss
private final LongAdder evictedFileCount
private long lastEvictedFileCount
private final ReentrantLock evictionLock
private final ScheduledExecutorService scheduleThreadPool
private final org.apache.hadoop.conf.Configuration conf
private final int mobFileMaxCacheSize
private final boolean isCacheEnabled
private float evictRemainRatio
public MobFileCache(org.apache.hadoop.conf.Configuration conf)
public void evict()
public void evictFile(String fileName)
fileName
- The name of a cached file.public MobFile openFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, CacheConfig cacheConf) throws IOException
fs
- The current file system.path
- The file path.cacheConf
- The current MobCacheConfigIOException
public void closeFile(MobFile file)
file
- The mob file that needs to be closed.public void shutdown()
public int getCacheSize()
public long getAccessCount()
public long getMissCount()
public long getEvictedFileCount()
public double getHitRatio()
public void printStatistics()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.