java.lang.Object
org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.PmemVolumeManager

@Private @Unstable public final class PmemVolumeManager extends Object
Manage the persistent memory volumes.
  • Field Details

  • Method Details

    • init

      public static void init(String[] pmemVolumesConfig, boolean cacheRecoveryEnabled) throws IOException
      Throws:
      IOException
    • getInstance

      public static PmemVolumeManager getInstance()
    • reset

      @VisibleForTesting public static void reset()
    • setMaxBytes

      @VisibleForTesting public static void setMaxBytes(long maxBytes)
    • getCacheUsed

      public long getCacheUsed()
    • getCacheCapacity

      public long getCacheCapacity()
    • recoverCache

      public Map<org.apache.hadoop.hdfs.ExtendedBlockId,MappableBlock> recoverCache(String bpid, MappableBlockLoader cacheLoader) throws IOException
      Recover cache from the cached files in the configured pmem volumes.
      Throws:
      IOException
    • recoverBlockKeyToVolume

      public void recoverBlockKeyToVolume(org.apache.hadoop.hdfs.ExtendedBlockId key, byte volumeIndex)
    • createBlockPoolDir

      public void createBlockPoolDir(String bpid) throws IOException
      Create cache subdirectory specified with blockPoolId.
      Throws:
      IOException
    • getRealPmemDir

      public static String getRealPmemDir(String rawPmemDir)
    • idToCacheFileName

      public String idToCacheFileName(org.apache.hadoop.hdfs.ExtendedBlockId key)
      A cache file is named after the corresponding BlockId. Thus, cache file name can be inferred according to BlockId.
    • idToCacheFilePath

      public String idToCacheFilePath(Byte volumeIndex, org.apache.hadoop.hdfs.ExtendedBlockId key) throws IOException
      Create and get the directory where a cache file with this key and volumeIndex should be stored. Use hierarchical strategy of storing blocks to avoid keeping cache files under one directory.
      Parameters:
      volumeIndex - The index of pmem volume where a replica will be cached to or has been cached to.
      key - The replica's ExtendedBlockId.
      Returns:
      A path to which the block replica is mapped.
      Throws:
      IOException
    • getCachePath

      public String getCachePath(org.apache.hadoop.hdfs.ExtendedBlockId key) throws IOException
      The cache file path is pmemVolume/BlockPoolId/subdir#/subdir#/BlockId.
      Throws:
      IOException