java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.LocalCacheDirectoryManager

public class LocalCacheDirectoryManager extends Object
LocalCacheDirectoryManager is used for managing hierarchical directories for local cache. It will allow to restrict the number of files in a directory to YarnConfiguration.NM_LOCAL_CACHE_MAX_FILES_PER_DIRECTORY which includes 36 sub-directories (named from 0 to 9 and a to z). Root directory is represented by an empty string. It internally maintains a vacant directory queue. As soon as the file count for the directory reaches its limit; new files will not be created in it until at least one file is deleted from it. New sub directories are not created unless a getRelativePathForLocalization() request is made and nonFullDirectories are empty. Note : this structure only returns relative localization path but doesn't create one on disk.
  • Field Details

  • Constructor Details

    • LocalCacheDirectoryManager

      public LocalCacheDirectoryManager(org.apache.hadoop.conf.Configuration conf)
  • Method Details

    • getRelativePathForLocalization

      public String getRelativePathForLocalization()
      This method will return relative path from the first available vacant directory.
      Returns:
      String relative path for localization
    • decrementFileCountForPath

      public void decrementFileCountForPath(String relPath)
      This method will reduce the file count for the directory represented by path. The root directory of this Local cache directory manager is represented by an empty string.
    • incrementFileCountForPath

      public void incrementFileCountForPath(String relPath)
      Increment the file count for a relative directory within the cache
      Parameters:
      relPath - the relative path
    • getCacheDirectoryRoot

      public static org.apache.hadoop.fs.Path getCacheDirectoryRoot(org.apache.hadoop.fs.Path path)
      Given a path to a directory within a local cache tree return the root of the cache directory.
      Parameters:
      path - the directory within a cache directory
      Returns:
      the local cache directory root or null if not found