Class CacheManager
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.CacheManager
The Cache Manager handles caching on DataNodes.
This class is instantiated by the FSNamesystem.
It maintains the mapping of cached blocks to datanodes via processing
datanode cache reports. Based on these reports and addition and removal of
caching directives, we will schedule caching and uncaching work.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.hdfs.protocol.CachePoolInfoaddCachePool(org.apache.hadoop.hdfs.protocol.CachePoolInfo info) Create a cache pool.org.apache.hadoop.hdfs.protocol.CacheDirectiveInfoaddDirective(org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo info, FSPermissionChecker pc, EnumSet<org.apache.hadoop.fs.CacheFlag> flags) voidorg.apache.hadoop.util.GSet<CachedBlock,CachedBlock> longlongbooleanbooleanorg.apache.hadoop.fs.BatchedRemoteIterator.BatchedListEntries<org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry>listCacheDirectives(long prevId, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo filter, FSPermissionChecker pc) org.apache.hadoop.fs.BatchedRemoteIterator.BatchedListEntries<org.apache.hadoop.hdfs.protocol.CachePoolEntry>listCachePools(FSPermissionChecker pc, String prevKey) voidvoidReloads CacheManager state from the passed DataInput.voidmodifyCachePool(org.apache.hadoop.hdfs.protocol.CachePoolInfo info) Modify a cache pool.voidmodifyDirective(org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo info, FSPermissionChecker pc, EnumSet<org.apache.hadoop.fs.CacheFlag> flags) final voidprocessCacheReport(org.apache.hadoop.hdfs.protocol.DatanodeID datanodeID, List<Long> blockIds) voidremoveCachePool(String poolName) Remove a cache pool.voidremoveDirective(long id, FSPermissionChecker pc) voidsaveStateCompat(DataOutputStream out, String sdPath) Saves the current state of the CacheManager to the DataOutput.voidsetCachedLocations(org.apache.hadoop.hdfs.protocol.LocatedBlocks locations) voidvoidvoid
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Method Details
-
isEnabled
public boolean isEnabled() -
isCheckLockTimeEnable
public boolean isCheckLockTimeEnable() -
getMaxLockTimeMs
public long getMaxLockTimeMs() -
getSleepTimeMs
public long getSleepTimeMs() -
startMonitorThread
public void startMonitorThread() -
stopMonitorThread
public void stopMonitorThread() -
clearDirectiveStats
public void clearDirectiveStats() -
getCachePools
- Returns:
- Unmodifiable view of the collection of CachePools.
-
getCacheDirectives
- Returns:
- Unmodifiable view of the collection of CacheDirectives.
-
getCachedBlocks
-
addDirective
public org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo addDirective(org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo info, FSPermissionChecker pc, EnumSet<org.apache.hadoop.fs.CacheFlag> flags) throws IOException - Throws:
IOException
-
modifyDirective
public void modifyDirective(org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo info, FSPermissionChecker pc, EnumSet<org.apache.hadoop.fs.CacheFlag> flags) throws IOException - Throws:
IOException
-
removeDirective
- Throws:
IOException
-
listCacheDirectives
public org.apache.hadoop.fs.BatchedRemoteIterator.BatchedListEntries<org.apache.hadoop.hdfs.protocol.CacheDirectiveEntry> listCacheDirectives(long prevId, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo filter, FSPermissionChecker pc) throws IOException - Throws:
IOException
-
addCachePool
public org.apache.hadoop.hdfs.protocol.CachePoolInfo addCachePool(org.apache.hadoop.hdfs.protocol.CachePoolInfo info) throws IOException Create a cache pool. Only the superuser should be able to call this function.- Parameters:
info- The info for the cache pool to create.- Returns:
- Information about the cache pool we created.
- Throws:
IOException
-
modifyCachePool
Modify a cache pool. Only the superuser should be able to call this function.- Parameters:
info- The info for the cache pool to modify.- Throws:
IOException
-
removeCachePool
Remove a cache pool. Only the superuser should be able to call this function.- Parameters:
poolName- The name for the cache pool to remove.- Throws:
IOException
-
listCachePools
public org.apache.hadoop.fs.BatchedRemoteIterator.BatchedListEntries<org.apache.hadoop.hdfs.protocol.CachePoolEntry> listCachePools(FSPermissionChecker pc, String prevKey) -
setCachedLocations
public void setCachedLocations(org.apache.hadoop.hdfs.protocol.LocatedBlocks locations) -
processCacheReport
public final void processCacheReport(org.apache.hadoop.hdfs.protocol.DatanodeID datanodeID, List<Long> blockIds) throws IOException - Throws:
IOException
-
saveStateCompat
Saves the current state of the CacheManager to the DataOutput. Used to persist CacheManager state in the FSImage.- Parameters:
out- DataOutput to persist statesdPath- path of the storage directory- Throws:
IOException
-
saveState
- Throws:
IOException
-
loadStateCompat
Reloads CacheManager state from the passed DataInput. Used during namenode startup to restore CacheManager state from an FSImage.- Parameters:
in- DataInput from which to restore state- Throws:
IOException
-
loadState
- Throws:
IOException
-
waitForRescanIfNeeded
public void waitForRescanIfNeeded() -
getCacheReplicationMonitor
-