@InterfaceAudience.Private public class HRegionFileSystem extends Object
| Modifier and Type | Field and Description |
|---|---|
private int |
baseSleepBeforeRetries |
(package private) org.apache.hadoop.conf.Configuration |
conf |
private static int |
DEFAULT_BASE_SLEEP_BEFORE_RETRIES |
private static int |
DEFAULT_HDFS_CLIENT_RETRIES_NUMBER |
(package private) org.apache.hadoop.fs.FileSystem |
fs |
private int |
hdfsClientRetriesNumber
In order to handle NN connectivity hiccups, one need to retry non-idempotent operation at the
client level.
|
private static org.slf4j.Logger |
LOG |
static String |
REGION_INFO_FILE
Name of the region info file that resides just under the region directory.
|
static String |
REGION_MERGES_DIR
Temporary subdirectory of the region directory used for merges.
|
static String |
REGION_SPLITS_DIR
Temporary subdirectory of the region directory used for splits.
|
(package private) static String |
REGION_TEMP_DIR
Temporary subdirectory of the region directory used for compaction output.
|
private org.apache.hadoop.fs.Path |
regionDir |
private RegionInfo |
regionInfo |
(package private) RegionInfo |
regionInfoForFs |
private org.apache.hadoop.fs.Path |
tableDir |
| Constructor and Description |
|---|
HRegionFileSystem(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
RegionInfo regionInfo)
Create a view to the on-disk region
|
| Modifier and Type | Method and Description |
|---|---|
(package private) Pair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> |
bulkLoadStoreFile(String familyName,
org.apache.hadoop.fs.Path srcPath,
long seqNum)
Bulk load: Add a specified store file to the specified family.
|
(package private) void |
checkRegionInfoOnFilesystem()
Write out an info file under the stored region directory.
|
(package private) void |
cleanupAnySplitDetritus()
Clean up any split detritus that may have been left around from previous
split attempts.
|
(package private) void |
cleanupDaughterRegion(RegionInfo regionInfo)
Remove daughter region
|
void |
cleanupMergedRegion(RegionInfo mergedRegion)
Remove merged region
|
(package private) void |
cleanupMergesDir()
Clean up any merge detritus that may have been left around from previous merge attempts.
|
(package private) void |
cleanupSplitsDir()
Clean up any split detritus that may have been left around from previous split attempts.
|
(package private) void |
cleanupTempDir()
Clean up any temp detritus that may have been left around from previous operation attempts.
|
org.apache.hadoop.fs.Path |
commitDaughterRegion(RegionInfo regionInfo)
Commit a daughter region, moving it from the split temporary directory
to the proper location in the filesystem.
|
void |
commitMergedRegion(RegionInfo mergedRegionInfo)
Commit a merged region, moving it from the merges temporary directory to
the proper location in the filesystem.
|
(package private) org.apache.hadoop.fs.Path |
commitStoreFile(org.apache.hadoop.fs.Path buildPath,
org.apache.hadoop.fs.Path dstPath) |
org.apache.hadoop.fs.Path |
commitStoreFile(String familyName,
org.apache.hadoop.fs.Path buildPath)
Move the file from a build/temp location to the main family store directory.
|
(package private) boolean |
createDir(org.apache.hadoop.fs.Path dir)
Creates a directory.
|
private static boolean |
createDirOnFileSystem(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.Path dir)
Creates a directory for a filesystem and configuration object.
|
void |
createMergesDir()
Create the region merges directory, a temporary directory to accumulate
merges in.
|
static HRegionFileSystem |
createRegionOnFileSystem(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
RegionInfo regionInfo)
Create a new Region on file-system.
|
void |
createSplitsDir(RegionInfo daughterA,
RegionInfo daughterB)
Create the region splits directory.
|
(package private) org.apache.hadoop.fs.Path |
createStoreDir(String familyName)
Create the store directory for the specified family name
|
org.apache.hadoop.fs.Path |
createTempName()
Generate a unique temporary Path.
|
org.apache.hadoop.fs.Path |
createTempName(String suffix)
Generate a unique temporary Path.
|
(package private) boolean |
deleteDir(org.apache.hadoop.fs.Path dir)
Deletes a directory.
|
void |
deleteFamily(String familyName)
Remove the region family from disk, archiving the store files.
|
static void |
deleteRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
RegionInfo regionInfo)
Remove the region from the table directory, archiving the region's hfiles.
|
private static String |
generateUniqueName(String suffix)
Generate a unique file name, used by createTempName() and commitStoreFile()
|
Collection<String> |
getFamilies() |
org.apache.hadoop.fs.FileSystem |
getFileSystem() |
org.apache.hadoop.fs.Path |
getMergesDir() |
(package private) org.apache.hadoop.fs.Path |
getMergesDir(RegionInfo hri) |
org.apache.hadoop.fs.Path |
getRegionDir() |
RegionInfo |
getRegionInfo() |
private static byte[] |
getRegionInfoFileContent(RegionInfo hri) |
RegionInfo |
getRegionInfoForFS() |
(package private) org.apache.hadoop.fs.Path |
getSplitsDir() |
org.apache.hadoop.fs.Path |
getSplitsDir(RegionInfo hri) |
String |
getStoragePolicyName(String familyName)
Get the storage policy of the directory of CF.
|
org.apache.hadoop.fs.Path |
getStoreDir(String familyName)
Returns the directory path of the specified family
|
(package private) StoreFileInfo |
getStoreFileInfo(String familyName,
String fileName)
Return the store file information of the specified family/file.
|
(package private) org.apache.hadoop.fs.Path |
getStoreFilePath(String familyName,
String fileName)
Return Qualified Path of the specified family/file
|
Collection<StoreFileInfo> |
getStoreFiles(byte[] familyName)
Returns the store files available for the family.
|
Collection<StoreFileInfo> |
getStoreFiles(String familyName) |
Collection<StoreFileInfo> |
getStoreFiles(String familyName,
boolean validate)
Returns the store files available for the family.
|
static List<org.apache.hadoop.fs.LocatedFileStatus> |
getStoreFilesLocatedStatus(HRegionFileSystem regionfs,
String familyName,
boolean validate)
Returns the store files' LocatedFileStatus which available for the family.
|
org.apache.hadoop.fs.Path |
getTableDir() |
(package private) org.apache.hadoop.fs.Path |
getTempDir() |
boolean |
hasReferences(String familyName)
Returns true if the specified family has reference files
|
boolean |
hasReferences(TableDescriptor htd)
Check whether region has Reference file
|
static RegionInfo |
loadRegionInfoFileContent(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path regionDir)
Create a
RegionInfo from the serialized version on-disk. |
(package private) void |
logFileSystemState(org.slf4j.Logger LOG)
Log the current state of the region
|
org.apache.hadoop.fs.Path |
mergeStoreFile(RegionInfo mergedRegion,
String familyName,
HStoreFile f,
org.apache.hadoop.fs.Path mergedDir)
Write out a merge reference under the given merges directory.
|
(package private) static boolean |
mkdirs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.Path dir) |
static HRegionFileSystem |
openRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
RegionInfo regionInfo,
boolean readOnly)
Open Region from file-system.
|
private org.apache.hadoop.fs.Path |
preCommitStoreFile(String familyName,
org.apache.hadoop.fs.Path buildPath,
long seqNum,
boolean generateNewName)
Generate the filename in the main family store directory for moving the file from a build/temp
location.
|
void |
removeStoreFile(String familyName,
org.apache.hadoop.fs.Path filePath)
Archives the specified store file from the specified family.
|
void |
removeStoreFiles(String familyName,
Collection<HStoreFile> storeFiles)
Closes and archives the specified store files from the specified family.
|
(package private) boolean |
rename(org.apache.hadoop.fs.Path srcpath,
org.apache.hadoop.fs.Path dstPath)
Renames a directory.
|
void |
setStoragePolicy(String familyName,
String policyName)
Set the directory of CF to the specified storage policy.
|
private void |
sleepBeforeRetry(String msg,
int sleepMultiplier)
sleeping logic; handles the interrupt exception.
|
private static void |
sleepBeforeRetry(String msg,
int sleepMultiplier,
int baseSleepBeforeRetries,
int hdfsClientRetriesNumber)
sleeping logic for static methods; handles the interrupt exception.
|
org.apache.hadoop.fs.Path |
splitStoreFile(RegionInfo hri,
String familyName,
HStoreFile f,
byte[] splitRow,
boolean top,
RegionSplitPolicy splitPolicy)
Write out a split reference.
|
private static void |
writeRegionInfoFileContent(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path regionInfoFile,
byte[] content)
Write the .regioninfo file on-disk.
|
private void |
writeRegionInfoOnFilesystem(boolean useTempDir)
Write out an info file under the region directory.
|
private void |
writeRegionInfoOnFilesystem(byte[] regionInfoContent,
boolean useTempDir)
Write out an info file under the region directory.
|
private static final org.slf4j.Logger LOG
public static final String REGION_INFO_FILE
public static final String REGION_MERGES_DIR
public static final String REGION_SPLITS_DIR
static final String REGION_TEMP_DIR
private final RegionInfo regionInfo
final RegionInfo regionInfoForFs
final org.apache.hadoop.conf.Configuration conf
private final org.apache.hadoop.fs.Path tableDir
final org.apache.hadoop.fs.FileSystem fs
private final org.apache.hadoop.fs.Path regionDir
private final int hdfsClientRetriesNumber
private final int baseSleepBeforeRetries
private static final int DEFAULT_HDFS_CLIENT_RETRIES_NUMBER
private static final int DEFAULT_BASE_SLEEP_BEFORE_RETRIES
HRegionFileSystem(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo regionInfo)
conf - the Configuration to usefs - FileSystem that contains the regiontableDir - Path to where the table is being storedregionInfo - RegionInfo for regionpublic org.apache.hadoop.fs.FileSystem getFileSystem()
FileSystempublic RegionInfo getRegionInfo()
RegionInfo that describe this on-disk region viewpublic RegionInfo getRegionInfoForFS()
public org.apache.hadoop.fs.Path getTableDir()
Path to the region's root directory.public org.apache.hadoop.fs.Path getRegionDir()
Path to the region directory.org.apache.hadoop.fs.Path getTempDir()
Path to the region's temp directory, used for file creationsvoid cleanupTempDir() throws IOException
IOExceptionpublic org.apache.hadoop.fs.Path getStoreDir(String familyName)
familyName - Column Family NamePath to the directory of the specified familyorg.apache.hadoop.fs.Path createStoreDir(String familyName) throws IOException
familyName - Column Family NamePath to the directory of the specified familyIOException - if the directory creation fails.public void setStoragePolicy(String familyName, String policyName)
HdfsConstants for more details.familyName - The name of column family.policyName - The name of the storage policy: 'HOT', 'COLD', etc.
See see hadoop 2.6+ org.apache.hadoop.hdfs.protocol.HdfsConstants for possible list e.g
'COLD', 'WARM', 'HOT', 'ONE_SSD', 'ALL_SSD', 'LAZY_PERSIST'.@Nullable public String getStoragePolicyName(String familyName)
familyName - The name of column family.null if not using HFileSystem or exception
thrown when trying to get policypublic Collection<StoreFileInfo> getStoreFiles(byte[] familyName) throws IOException
familyName - Column Family NameStoreFileInfo for the specified family.IOExceptionpublic Collection<StoreFileInfo> getStoreFiles(String familyName) throws IOException
IOExceptionpublic Collection<StoreFileInfo> getStoreFiles(String familyName, boolean validate) throws IOException
familyName - Column Family NameStoreFileInfo for the specified family.IOExceptionpublic static List<org.apache.hadoop.fs.LocatedFileStatus> getStoreFilesLocatedStatus(HRegionFileSystem regionfs, String familyName, boolean validate) throws IOException
familyName - Column Family NameIOExceptionorg.apache.hadoop.fs.Path getStoreFilePath(String familyName, String fileName)
familyName - Column Family NamefileName - File NameStoreFileInfo getStoreFileInfo(String familyName, String fileName) throws IOException
familyName - Column Family NamefileName - File NameStoreFileInfo for the specified family/fileIOExceptionpublic boolean hasReferences(String familyName) throws IOException
familyName - Column Family NameIOExceptionpublic boolean hasReferences(TableDescriptor htd) throws IOException
htd - table desciptor of the regionIOExceptionpublic Collection<String> getFamilies() throws IOException
IOExceptionpublic void deleteFamily(String familyName) throws IOException
familyName - Column Family NameIOException - if an error occours during the archivingprivate static String generateUniqueName(String suffix)
suffix - extra information to append to the generated namepublic org.apache.hadoop.fs.Path createTempName()
Path file = fs.createTempName();
...StoreFile.Writer(file)...
fs.commitStoreFile("family", file);
Path of the temporary filepublic org.apache.hadoop.fs.Path createTempName(String suffix)
Path file = fs.createTempName();
...StoreFile.Writer(file)...
fs.commitStoreFile("family", file);
suffix - extra information to append to the generated namePath of the temporary filepublic org.apache.hadoop.fs.Path commitStoreFile(String familyName, org.apache.hadoop.fs.Path buildPath) throws IOException
familyName - Family that will gain the filebuildPath - Path to the file to commit.Path of the committed fileIOExceptionprivate org.apache.hadoop.fs.Path preCommitStoreFile(String familyName, org.apache.hadoop.fs.Path buildPath, long seqNum, boolean generateNewName) throws IOException
familyName - Family that will gain the filebuildPath - Path to the file to commit.seqNum - Sequence Number to append to the file name (less then 0 if no sequence number)generateNewName - False if you want to keep the buildPath namePath of the to be committed fileIOExceptionorg.apache.hadoop.fs.Path commitStoreFile(org.apache.hadoop.fs.Path buildPath, org.apache.hadoop.fs.Path dstPath) throws IOException
IOExceptionpublic void removeStoreFile(String familyName, org.apache.hadoop.fs.Path filePath) throws IOException
familyName - Family that contains the store filesfilePath - Path to the store file to removeIOException - if the archiving failspublic void removeStoreFiles(String familyName, Collection<HStoreFile> storeFiles) throws IOException
familyName - Family that contains the store filesstoreFiles - set of store files to removeIOException - if the archiving failsPair<org.apache.hadoop.fs.Path,org.apache.hadoop.fs.Path> bulkLoadStoreFile(String familyName, org.apache.hadoop.fs.Path srcPath, long seqNum) throws IOException
familyName - Family that will gain the filesrcPath - Path to the file to importseqNum - Bulk Load sequence numberPath of the bulk loaded fileIOExceptionorg.apache.hadoop.fs.Path getSplitsDir()
Path to the temp directory used during split operationspublic org.apache.hadoop.fs.Path getSplitsDir(RegionInfo hri)
void cleanupSplitsDir() throws IOException
IOExceptionvoid cleanupAnySplitDetritus() throws IOException
IOExceptionvoid cleanupDaughterRegion(RegionInfo regionInfo) throws IOException
regionInfo - daughter RegionInfoIOExceptionpublic org.apache.hadoop.fs.Path commitDaughterRegion(RegionInfo regionInfo) throws IOException
regionInfo - daughter RegionInfoIOExceptionpublic void createSplitsDir(RegionInfo daughterA, RegionInfo daughterB) throws IOException
IOExceptionpublic org.apache.hadoop.fs.Path splitStoreFile(RegionInfo hri, String familyName, HStoreFile f, byte[] splitRow, boolean top, RegionSplitPolicy splitPolicy) throws IOException
hri - RegionInfo of the destinationfamilyName - Column Family Namef - File to split.splitRow - Split Rowtop - True if we are referring to the top half of the hfile.splitPolicy - A split policy instance; be careful! May not be full populated; e.g. if
this method is invoked on the Master side, then the RegionSplitPolicy will
NOT have a reference to a Region.IOExceptionpublic org.apache.hadoop.fs.Path getMergesDir()
Path to the temp directory used during merge operationsorg.apache.hadoop.fs.Path getMergesDir(RegionInfo hri)
void cleanupMergesDir() throws IOException
IOExceptionpublic void cleanupMergedRegion(RegionInfo mergedRegion) throws IOException
mergedRegion - RegionInfoIOExceptionstatic boolean mkdirs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path dir) throws IOException
IOExceptionpublic void createMergesDir() throws IOException
IOException - If merges dir already exists or we fail to create it.cleanupMergesDir()public org.apache.hadoop.fs.Path mergeStoreFile(RegionInfo mergedRegion, String familyName, HStoreFile f, org.apache.hadoop.fs.Path mergedDir) throws IOException
mergedRegion - RegionInfo of the merged regionfamilyName - Column Family Namef - File to create reference.mergedDir - IOExceptionpublic void commitMergedRegion(RegionInfo mergedRegionInfo) throws IOException
mergedRegionInfo - merged region RegionInfoIOExceptionvoid logFileSystemState(org.slf4j.Logger LOG) throws IOException
LOG - log to output informationIOException - if an unexpected exception occursprivate static byte[] getRegionInfoFileContent(RegionInfo hri) throws IOException
hri - IOExceptionpublic static RegionInfo loadRegionInfoFileContent(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path regionDir) throws IOException
RegionInfo from the serialized version on-disk.fs - FileSystem that contains the Region Info fileregionDir - Path to the Region Directory that contains the Info fileRegionInfo instance gotten from the Region Info file.IOException - if an error occurred during file open/read operation.private static void writeRegionInfoFileContent(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path regionInfoFile, byte[] content) throws IOException
IOExceptionvoid checkRegionInfoOnFilesystem() throws IOException
IOExceptionprivate void writeRegionInfoOnFilesystem(boolean useTempDir) throws IOException
useTempDir - indicate whether or not using the region .tmp dir for a safer file creation.IOExceptionprivate void writeRegionInfoOnFilesystem(byte[] regionInfoContent, boolean useTempDir) throws IOException
regionInfoContent - serialized version of the RegionInfouseTempDir - indicate whether or not using the region .tmp dir for a safer file creation.IOExceptionpublic static HRegionFileSystem createRegionOnFileSystem(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo regionInfo) throws IOException
conf - the Configuration to usefs - FileSystem from which to add the regiontableDir - Path to where the table is being storedregionInfo - RegionInfo for region to be addedIOException - if the region creation fails due to a FileSystem exception.public static HRegionFileSystem openRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo regionInfo, boolean readOnly) throws IOException
conf - the Configuration to usefs - FileSystem from which to add the regiontableDir - Path to where the table is being storedregionInfo - RegionInfo for region to be addedreadOnly - True if you don't want to edit the region dataIOException - if the region creation fails due to a FileSystem exception.public static void deleteRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, RegionInfo regionInfo) throws IOException
conf - the Configuration to usefs - FileSystem from which to remove the regiontableDir - Path to where the table is being storedregionInfo - RegionInfo for region to be deletedIOException - if the request cannot be completedboolean createDir(org.apache.hadoop.fs.Path dir) throws IOException
dir - IOExceptionboolean rename(org.apache.hadoop.fs.Path srcpath, org.apache.hadoop.fs.Path dstPath) throws IOException
srcpath - dstPath - IOExceptionboolean deleteDir(org.apache.hadoop.fs.Path dir) throws IOException
dir - IOExceptionprivate void sleepBeforeRetry(String msg, int sleepMultiplier) throws InterruptedException
InterruptedExceptionprivate static boolean createDirOnFileSystem(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path dir) throws IOException
fs - conf - dir - IOExceptionprivate static void sleepBeforeRetry(String msg, int sleepMultiplier, int baseSleepBeforeRetries, int hdfsClientRetriesNumber) throws InterruptedException
InterruptedExceptionCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.