org.apache.hadoop.hbase.io
Class HFileLink

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

@InterfaceAudience.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:

The link checks first in the original path if it is not present it fallbacks to the archived path.


Field Summary
static String LINK_NAME_REGEX
          A non-capture group, for HFileLink, so that this can be embedded.
 
Fields inherited from class org.apache.hadoop.hbase.io.FileLink
BACK_REFERENCES_DIRECTORY_PREFIX
 
Constructor Summary
HFileLink(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path path)
           
HFileLink(org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path archiveDir, org.apache.hadoop.fs.Path path)
           
 
Method Summary
static boolean create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, HRegionInfo hfileRegionInfo, String hfileName)
          Create a new HFileLink
static boolean create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, String linkedTable, String linkedRegion, String hfileName)
          Create a new HFileLink
static boolean createFromHFileLink(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, String hfileLinkName)
          Create a new HFileLink starting from a hfileLink name
static String createHFileLinkName(HRegionInfo hfileRegionInfo, String hfileName)
          Create a new HFileLink name
static String createHFileLinkName(String tableName, String regionName, String hfileName)
          Create a new HFileLink name
 org.apache.hadoop.fs.Path getArchivePath()
           
static org.apache.hadoop.fs.Path getHFileFromBackReference(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path linkRefPath)
          Get the full path of the HFile referenced by the back reference
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
 org.apache.hadoop.fs.Path getOriginPath()
           
static String getReferencedHFileName(String fileName)
          Get the HFile name of the referenced link
static String getReferencedRegionName(String fileName)
          Get the Region name of the referenced link
static String getReferencedTableName(String fileName)
          Get the Table name of the referenced link
static boolean isHFileLink(org.apache.hadoop.fs.Path path)
           
static boolean isHFileLink(String fileName)
           
 
Methods inherited from class org.apache.hadoop.hbase.io.FileLink
getAvailablePath, getBackReferenceFileName, getBackReferencesDir, getFileStatus, getLocations, isBackReferencesDir, open, open, setLocations, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LINK_NAME_REGEX

public static final String LINK_NAME_REGEX
A non-capture group, for HFileLink, so that this can be embedded. The HFileLink describe a link to an hfile in a different table/region and the name is in the form: table=region-hfile.

Table name is ([a-zA-Z_0-9][a-zA-Z_0-9.-]*), so '=' is an invalid character for the table name. Region name is ([a-f0-9]+), so '-' is an invalid character for the region name. HFile is ([0-9a-f]+(?:_SeqId_[0-9]+_)?) covering the plain hfiles (uuid) and the bulk loaded (_SeqId_[0-9]+_) hfiles.

Constructor Detail

HFileLink

public HFileLink(org.apache.hadoop.conf.Configuration conf,
                 org.apache.hadoop.fs.Path path)
          throws IOException
Parameters:
conf - Configuration from which to extract specific archive locations
path - The path of the HFile Link.
Throws:
IOException - on unexpected error.

HFileLink

public HFileLink(org.apache.hadoop.fs.Path rootDir,
                 org.apache.hadoop.fs.Path archiveDir,
                 org.apache.hadoop.fs.Path path)
Parameters:
rootDir - Path to the root directory where hbase files are stored
archiveDir - Path to the hbase archive directory
path - The path of the HFile Link.
Method Detail

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.

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.

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 String 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(HRegionInfo 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(String 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

create

public static boolean create(org.apache.hadoop.conf.Configuration conf,
                             org.apache.hadoop.fs.FileSystem fs,
                             org.apache.hadoop.fs.Path dstFamilyPath,
                             HRegionInfo hfileRegionInfo,
                             String hfileName)
                      throws IOException
Create a new HFileLink

It also adds a back-reference to the hfile back-reference directory to simplify the reference-count and the cleaning process.

Parameters:
conf - Configuration to read for the archive directory name
fs - FileSystem on which to write the HFileLink
dstFamilyPath - - Destination path (table/region/cf/)
hfileRegionInfo - - Linked HFile Region Info
hfileName - - Linked HFile name
Returns:
true if the file is created, otherwise the file exists.
Throws:
IOException - on file or parent directory creation failure

create

public static boolean create(org.apache.hadoop.conf.Configuration conf,
                             org.apache.hadoop.fs.FileSystem fs,
                             org.apache.hadoop.fs.Path dstFamilyPath,
                             String linkedTable,
                             String linkedRegion,
                             String hfileName)
                      throws IOException
Create a new HFileLink

It also adds a back-reference to the hfile back-reference directory to simplify the reference-count and the cleaning process.

Parameters:
conf - Configuration to read for the archive directory name
fs - FileSystem on which to write the HFileLink
dstFamilyPath - - Destination path (table/region/cf/)
linkedTable - - Linked Table Name
linkedRegion - - Linked Region Name
hfileName - - Linked HFile name
Returns:
true if the file is created, otherwise the file exists.
Throws:
IOException - on file or parent directory creation failure

createFromHFileLink

public static boolean createFromHFileLink(org.apache.hadoop.conf.Configuration conf,
                                          org.apache.hadoop.fs.FileSystem fs,
                                          org.apache.hadoop.fs.Path dstFamilyPath,
                                          String hfileLinkName)
                                   throws IOException
Create a new HFileLink starting from a hfileLink name

It also adds a back-reference to the hfile back-reference directory to simplify the reference-count and the cleaning process.

Parameters:
conf - Configuration to read for the archive directory name
fs - FileSystem on which to write the HFileLink
dstFamilyPath - - Destination path (table/region/cf/)
hfileLinkName - - HFileLink name (it contains hfile-region-table)
Returns:
true if the file is created, otherwise the file exists.
Throws:
IOException - on file or parent directory creation failure

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
Throws:
IOException - on unexpected error.

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.


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.