@InterfaceAudience.Private public class HRegionFileSystem extends Object
Modifier and Type | Field and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanupMergedRegion(RegionInfo mergedRegion)
Remove merged region
|
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.
|
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.
|
void |
createMergesDir()
Create the region merges directory.
|
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.
|
org.apache.hadoop.fs.Path |
createTempName()
Generate a unique temporary Path.
|
org.apache.hadoop.fs.Path |
createTempName(String suffix)
Generate a unique temporary Path.
|
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.
|
Collection<String> |
getFamilies() |
org.apache.hadoop.fs.FileSystem |
getFileSystem() |
org.apache.hadoop.fs.Path |
getMergesDir() |
org.apache.hadoop.fs.Path |
getRegionDir() |
RegionInfo |
getRegionInfo() |
RegionInfo |
getRegionInfoForFS() |
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
|
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() |
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. |
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.
|
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.
|
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.
|
void |
setStoragePolicy(String familyName,
String policyName)
Set the directory of CF to the specified storage policy.
|
org.apache.hadoop.fs.Path |
splitStoreFile(RegionInfo hri,
String familyName,
HStoreFile f,
byte[] splitRow,
boolean top,
RegionSplitPolicy splitPolicy)
Write out a split reference.
|
public static final String REGION_INFO_FILE
public static final String REGION_MERGES_DIR
public static final String REGION_SPLITS_DIR
public org.apache.hadoop.fs.FileSystem getFileSystem()
FileSystem
public 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.public org.apache.hadoop.fs.Path getStoreDir(String familyName)
familyName
- Column Family NamePath
to the directory of the specified familypublic 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.IOException
public Collection<StoreFileInfo> getStoreFiles(String familyName) throws IOException
IOException
public Collection<StoreFileInfo> getStoreFiles(String familyName, boolean validate) throws IOException
familyName
- Column Family NameStoreFileInfo
for the specified family.IOException
public static List<org.apache.hadoop.fs.LocatedFileStatus> getStoreFilesLocatedStatus(HRegionFileSystem regionfs, String familyName, boolean validate) throws IOException
familyName
- Column Family NameIOException
public boolean hasReferences(String familyName) throws IOException
familyName
- Column Family NameIOException
public boolean hasReferences(TableDescriptor htd) throws IOException
htd
- table desciptor of the regionIOException
public Collection<String> getFamilies() throws IOException
IOException
public void deleteFamily(String familyName) throws IOException
familyName
- Column Family NameIOException
- if an error occours during the archivingpublic 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 fileIOException
public 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 failspublic org.apache.hadoop.fs.Path getSplitsDir(RegionInfo hri)
public org.apache.hadoop.fs.Path commitDaughterRegion(RegionInfo regionInfo) throws IOException
regionInfo
- daughter RegionInfo
IOException
public void createSplitsDir(RegionInfo daughterA, RegionInfo daughterB) throws IOException
IOException
public 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.IOException
public org.apache.hadoop.fs.Path getMergesDir()
Path
to the temp directory used during merge operationspublic void cleanupMergedRegion(RegionInfo mergedRegion) throws IOException
mergedRegion
- RegionInfo
IOException
public 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
- IOException
public void commitMergedRegion(RegionInfo mergedRegionInfo) throws IOException
mergedRegionInfo
- merged region RegionInfo
IOException
public 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.public 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 completedCopyright © 2007–2019 Cloudera. All rights reserved.