Class HFileLink

java.lang.Object
org.apache.hadoop.hbase.io.FileLink
org.apache.hadoop.hbase.io.HFileLink

@Private public class HFileLink extends FileLink
HFileLink describes a link to an hfile. An hfile can be served from a region or from the hfile archive directory (/hbase/.archive) HFileLink allows to access the referenced hfile regardless of the location where it is.

Searches for hfiles in the following order and locations:

  • /hbase/table/region/cf/hfile
  • /hbase/.archive/table/region/cf/hfile
The link checks first in the original path if it is not present it fallbacks to the archived path.
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • archivePath

      private final org.apache.hadoop.fs.Path archivePath
    • originPath

      private final org.apache.hadoop.fs.Path originPath
    • mobPath

      private final org.apache.hadoop.fs.Path mobPath
    • tempPath

      private final org.apache.hadoop.fs.Path tempPath
  • Constructor Details

    • HFileLink

      public HFileLink(org.apache.hadoop.fs.Path originPath, org.apache.hadoop.fs.Path tempPath, org.apache.hadoop.fs.Path mobPath, org.apache.hadoop.fs.Path archivePath)
      Dead simple hfile link constructor
  • Method Details

    • buildFromHFileLinkPattern

      public static final HFileLink buildFromHFileLinkPattern(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path hFileLinkPattern) throws IOException
      Parameters:
      conf - Configuration from which to extract specific archive locations
      hFileLinkPattern - The path ending with a HFileLink pattern. (table=region-hfile)
      Throws:
      IOException - on unexpected error.
    • buildFromHFileLinkPattern

      public static final HFileLink buildFromHFileLinkPattern(org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path archiveDir, org.apache.hadoop.fs.Path hFileLinkPattern)
      Parameters:
      rootDir - Path to the root directory where hbase files are stored
      archiveDir - Path to the hbase archive directory
      hFileLinkPattern - The path of the HFile Link.
    • createPath

      public static org.apache.hadoop.fs.Path createPath(TableName table, String region, String family, String hfile)
      Create an HFileLink relative path for the table/region/family/hfile location
      Parameters:
      table - Table name
      region - Region Name
      family - Family Name
      hfile - HFile Name
      Returns:
      the relative Path to open the specified table/region/family/hfile link
    • build

      public static HFileLink build(org.apache.hadoop.conf.Configuration conf, TableName table, String region, String family, String hfile) throws IOException
      Create an HFileLink instance from table/region/family/hfile location
      Parameters:
      conf - Configuration from which to extract specific archive locations
      table - Table name
      region - Region Name
      family - Family Name
      hfile - HFile Name
      Returns:
      Link to the file with the specified table/region/family/hfile location
      Throws:
      IOException - on unexpected error.
    • getOriginPath

      public org.apache.hadoop.fs.Path getOriginPath()
      Returns the origin path of the hfile.
    • getArchivePath

      public org.apache.hadoop.fs.Path getArchivePath()
      Returns the path of the archived hfile.
    • getMobPath

      public org.apache.hadoop.fs.Path getMobPath()
      Returns the path of the mob hfiles.
    • isHFileLink

      public static boolean isHFileLink(org.apache.hadoop.fs.Path path)
      Parameters:
      path - Path to check.
      Returns:
      True if the path is a HFileLink.
    • isHFileLink

      public static boolean isHFileLink(String fileName)
      Parameters:
      fileName - File name to check.
      Returns:
      True if the path is a HFileLink.
    • getHFileLinkPatternRelativePath

      private static org.apache.hadoop.fs.Path getHFileLinkPatternRelativePath(org.apache.hadoop.fs.Path path)
      Convert a HFileLink path to a table relative path. e.g. the link: /hbase/test/0123/cf/testtb=4567-abcd becomes: /hbase/testtb/4567/cf/abcd
      Parameters:
      path - HFileLink path
      Returns:
      Relative table path
      Throws:
      IOException - on unexpected error.
    • getReferencedHFileName

      public static String getReferencedHFileName(String fileName)
      Get the HFile name of the referenced link
      Parameters:
      fileName - HFileLink file name
      Returns:
      the name of the referenced HFile
    • getReferencedRegionName

      public static String getReferencedRegionName(String fileName)
      Get the Region name of the referenced link
      Parameters:
      fileName - HFileLink file name
      Returns:
      the name of the referenced Region
    • getReferencedTableName

      public static TableName getReferencedTableName(String fileName)
      Get the Table name of the referenced link
      Parameters:
      fileName - HFileLink file name
      Returns:
      the name of the referenced Table
    • createHFileLinkName

      public static String createHFileLinkName(RegionInfo hfileRegionInfo, String hfileName)
      Create a new HFileLink name
      Parameters:
      hfileRegionInfo - - Linked HFile Region Info
      hfileName - - Linked HFile name
      Returns:
      file name of the HFile Link
    • createHFileLinkName

      public static String createHFileLinkName(TableName tableName, String regionName, String hfileName)
      Create a new HFileLink name
      Parameters:
      tableName - - Linked HFile table name
      regionName - - Linked HFile region name
      hfileName - - Linked HFile name
      Returns:
      file name of the HFile Link
    • createBackReferenceName

      public static String createBackReferenceName(String tableNameStr, String regionName)
      Create the back reference name
    • getHFileFromBackReference

      public static org.apache.hadoop.fs.Path getHFileFromBackReference(org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path linkRefPath)
      Get the full path of the HFile referenced by the back reference
      Parameters:
      rootDir - root hbase directory
      linkRefPath - Link Back Reference path
      Returns:
      full path of the referenced hfile
    • parseBackReferenceName

    • getHFileFromBackReference

      public static org.apache.hadoop.fs.Path getHFileFromBackReference(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path linkRefPath) throws IOException
      Get the full path of the HFile referenced by the back reference
      Parameters:
      conf - Configuration to read for the archive directory name
      linkRefPath - Link Back Reference path
      Returns:
      full path of the referenced hfile
      Throws:
      IOException - on unexpected error.