Class HFileLink
Searches for hfiles in the following order and locations:
- /hbase/table/region/cf/hfile
- /hbase/.archive/table/region/cf/hfile
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.io.FileLink
FileLink.FileLinkInputStream
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.fs.Path
static final Pattern
Define the HFile Link name parser in the form of: table=region-hfilestatic final String
A non-capture group, for HFileLink, so that this can be embedded.private static final org.slf4j.Logger
private final org.apache.hadoop.fs.Path
private final org.apache.hadoop.fs.Path
private static final Pattern
The pattern should be used for hfile and reference links that can be found in /hbase/table/region/family/private final org.apache.hadoop.fs.Path
Fields inherited from class org.apache.hadoop.hbase.io.FileLink
BACK_REFERENCES_DIRECTORY_PREFIX
-
Constructor Summary
ConstructorDescriptionHFileLink
(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 Summary
Modifier and TypeMethodDescriptionstatic HFileLink
build
(org.apache.hadoop.conf.Configuration conf, TableName table, String region, String family, String hfile) Create an HFileLink instance from table/region/family/hfile locationstatic final HFileLink
buildFromHFileLinkPattern
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path hFileLinkPattern) static final HFileLink
buildFromHFileLinkPattern
(org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path archiveDir, org.apache.hadoop.fs.Path hFileLinkPattern) static String
create
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, String familyName, String dstTableName, String dstRegionName, TableName linkedTable, String linkedRegion, String hfileName, boolean createBackRef) Create a new HFileLinkstatic String
create
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, RegionInfo hfileRegionInfo, String hfileName) Create a new HFileLinkstatic String
create
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, RegionInfo hfileRegionInfo, String hfileName, boolean createBackRef) Create a new HFileLinkstatic String
create
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, TableName linkedTable, String linkedRegion, String hfileName) Create a new HFileLinkstatic String
create
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, TableName linkedTable, String linkedRegion, String hfileName, boolean createBackRef) Create a new HFileLink.static String
createBackReferenceName
(String tableNameStr, String regionName) Create the back reference namestatic String
createFromHFileLink
(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, String hfileLinkName, boolean createBackRef) Create a new HFileLink starting from a hfileLink namestatic String
createHFileLinkName
(RegionInfo hfileRegionInfo, String hfileName) Create a new HFileLink namestatic String
createHFileLinkName
(TableName tableName, String regionName, String hfileName) Create a new HFileLink namestatic 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 locationorg.apache.hadoop.fs.Path
Returns the path of the archived hfile.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 referencestatic 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 referenceprivate static org.apache.hadoop.fs.Path
getHFileLinkPatternRelativePath
(org.apache.hadoop.fs.Path path) Convert a HFileLink path to a table relative path.org.apache.hadoop.fs.Path
Returns the path of the mob hfiles.org.apache.hadoop.fs.Path
Returns the origin path of the hfile.static String
getReferencedHFileName
(String fileName) Get the HFile name of the referenced linkstatic String
getReferencedRegionName
(String fileName) Get the Region name of the referenced linkstatic TableName
getReferencedTableName
(String fileName) Get the Table name of the referenced linkstatic boolean
isHFileLink
(String fileName) static boolean
isHFileLink
(org.apache.hadoop.fs.Path path) parseBackReferenceName
(String name) Methods inherited from class org.apache.hadoop.hbase.io.FileLink
equals, exists, getAvailablePath, getBackReferenceFileName, getBackReferencesDir, getFileStatus, getLocations, getUnderlyingFileLinkInputStream, hashCode, isBackReferencesDir, open, open, setLocations, toString
-
Field Details
-
LOG
-
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 ([\p{IsAlphabetic}\p{Digit}][\p{IsAlphabetic}\p{Digit}.-]*), 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.
Here is an example name: /hbase/test/0123/cf/testtb=4567-abcd where 'testtb' is table name and '4567' is region name and 'abcd' is filename.
-
LINK_NAME_PATTERN
Define the HFile Link name parser in the form of: table=region-hfile -
REF_OR_HFILE_LINK_PATTERN
The pattern should be used for hfile and reference links that can be found in /hbase/table/region/family/ -
archivePath
-
originPath
-
mobPath
-
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 locationshFileLinkPattern
- 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 storedarchiveDir
- Path to the hbase archive directoryhFileLinkPattern
- 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 nameregion
- Region Namefamily
- Family Namehfile
- 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 locationstable
- Table nameregion
- Region Namefamily
- Family Namehfile
- HFile Name- Returns:
- Link to the file with the specified table/region/family/hfile location
- Throws:
IOException
- on unexpected error.
-
getOriginPath
Returns the origin path of the hfile. -
getArchivePath
Returns the path of the archived hfile. -
getMobPath
Returns the path of the mob hfiles. -
isHFileLink
- Parameters:
path
- Path to check.- Returns:
- True if the path is a HFileLink.
-
isHFileLink
- 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
Get the HFile name of the referenced link- Parameters:
fileName
- HFileLink file name- Returns:
- the name of the referenced HFile
-
getReferencedRegionName
Get the Region name of the referenced link- Parameters:
fileName
- HFileLink file name- Returns:
- the name of the referenced Region
-
getReferencedTableName
Get the Table name of the referenced link- Parameters:
fileName
- HFileLink file name- Returns:
- the name of the referenced Table
-
createHFileLinkName
Create a new HFileLink name- Parameters:
hfileRegionInfo
- - Linked HFile Region InfohfileName
- - Linked HFile name- Returns:
- file name of the HFile Link
-
createHFileLinkName
Create a new HFileLink name- Parameters:
tableName
- - Linked HFile table nameregionName
- - Linked HFile region namehfileName
- - Linked HFile name- Returns:
- file name of the HFile Link
-
create
public static String create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, RegionInfo hfileRegionInfo, String hfileName) throws IOException Create a new HFileLinkIt 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 namefs
-FileSystem
on which to write the HFileLinkdstFamilyPath
- - Destination path (table/region/cf/)hfileRegionInfo
- - Linked HFile Region InfohfileName
- - Linked HFile name- Returns:
- the file link name.
- Throws:
IOException
- on file or parent directory creation failure.
-
create
public static String create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, RegionInfo hfileRegionInfo, String hfileName, boolean createBackRef) throws IOException Create a new HFileLinkIt 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 namefs
-FileSystem
on which to write the HFileLinkdstFamilyPath
- - Destination path (table/region/cf/)hfileRegionInfo
- - Linked HFile Region InfohfileName
- - Linked HFile namecreateBackRef
- - Whether back reference should be created. Defaults to true.- Returns:
- the file link name.
- Throws:
IOException
- on file or parent directory creation failure.
-
create
public static String create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, TableName linkedTable, String linkedRegion, String hfileName) throws IOException Create a new HFileLinkIt 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 namefs
-FileSystem
on which to write the HFileLinkdstFamilyPath
- - Destination path (table/region/cf/)linkedTable
- - Linked Table NamelinkedRegion
- - Linked Region NamehfileName
- - Linked HFile name- Returns:
- the file link name.
- Throws:
IOException
- on file or parent directory creation failure.
-
create
public static String create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, TableName linkedTable, String linkedRegion, String hfileName, boolean createBackRef) throws IOException Create a new HFileLink. In the event of link creation failure, this method throws an IOException, so that the calling upper laying can decide on how to proceed with this.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 namefs
-FileSystem
on which to write the HFileLinkdstFamilyPath
- - Destination path (table/region/cf/)linkedTable
- - Linked Table NamelinkedRegion
- - Linked Region NamehfileName
- - Linked HFile namecreateBackRef
- - Whether back reference should be created. Defaults to true.- Returns:
- the file link name.
- Throws:
IOException
- on file or parent directory creation failure.
-
create
public static String create(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, String familyName, String dstTableName, String dstRegionName, TableName linkedTable, String linkedRegion, String hfileName, boolean createBackRef) throws IOException Create a new HFileLinkIt 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 namefs
-FileSystem
on which to write the HFileLinkdstFamilyPath
- - Destination path (table/region/cf/)dstTableName
- - Destination table namedstRegionName
- - Destination region namelinkedTable
- - Linked Table NamelinkedRegion
- - Linked Region NamehfileName
- - Linked HFile namecreateBackRef
- - Whether back reference should be created. Defaults to true.- Returns:
- the file link name.
- Throws:
IOException
- on file or parent directory creation failure
-
createFromHFileLink
public static String createFromHFileLink(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dstFamilyPath, String hfileLinkName, boolean createBackRef) throws IOException Create a new HFileLink starting from a hfileLink nameIt 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 namefs
-FileSystem
on which to write the HFileLinkdstFamilyPath
- - Destination path (table/region/cf/)hfileLinkName
- - HFileLink name (it contains hfile-region-table)createBackRef
- - Whether back reference should be created. Defaults to true.- Returns:
- the file link name.
- Throws:
IOException
- on file or parent directory creation failure.
-
createBackReferenceName
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 directorylinkRefPath
- 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 namelinkRefPath
- Link Back Reference path- Returns:
- full path of the referenced hfile
- Throws:
IOException
- on unexpected error.
-