Class CacheManager

java.lang.Object
org.apache.hadoop.hdfs.server.namenode.CacheManager

@LimitedPrivate("HDFS") public class CacheManager extends Object
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.
  • 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

      public Collection<CachePool> getCachePools()
      Returns:
      Unmodifiable view of the collection of CachePools.
    • getCacheDirectives

      public Collection<CacheDirective> getCacheDirectives()
      Returns:
      Unmodifiable view of the collection of CacheDirectives.
    • getCachedBlocks

      @VisibleForTesting public org.apache.hadoop.util.GSet<CachedBlock,CachedBlock> 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

      public void removeDirective(long id, FSPermissionChecker pc) throws IOException
      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

      public void modifyCachePool(org.apache.hadoop.hdfs.protocol.CachePoolInfo info) throws IOException
      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

      public void removeCachePool(String poolName) throws IOException
      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

      public void saveStateCompat(DataOutputStream out, String sdPath) throws IOException
      Saves the current state of the CacheManager to the DataOutput. Used to persist CacheManager state in the FSImage.
      Parameters:
      out - DataOutput to persist state
      sdPath - path of the storage directory
      Throws:
      IOException
    • saveState

      public CacheManager.PersistState saveState() throws IOException
      Throws:
      IOException
    • loadStateCompat

      public void loadStateCompat(DataInput in) throws IOException
      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

      public void loadState(CacheManager.PersistState s) throws IOException
      Throws:
      IOException
    • waitForRescanIfNeeded

      public void waitForRescanIfNeeded()
    • getCacheReplicationMonitor

      @VisibleForTesting public Thread getCacheReplicationMonitor()