org.apache.hadoop.hbase.regionserver
Class HRegionFileSystem

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.HRegionFileSystem

@InterfaceAudience.Private
public class HRegionFileSystem
extends Object

View to an on-disk Region. Provides the set of methods necessary to interact with the on-disk region data.


Field Summary
static org.apache.commons.logging.Log 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.
 
Method Summary
 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.
static HRegionFileSystem createRegionOnFileSystem(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, HRegionInfo regionInfo)
          Create a new Region on file-system.
 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, HRegionInfo 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 getRegionDir()
           
 HRegionInfo getRegionInfo()
           
 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.
 org.apache.hadoop.fs.Path getTableDir()
           
 boolean hasReferences(HTableDescriptor htd)
          Check whether region has Reference file
 boolean hasReferences(String familyName)
          Returns true if the specified family has reference files
static HRegionInfo loadRegionInfoFileContent(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path regionDir)
          Create a HRegionInfo from the serialized version on-disk.
static HRegionFileSystem openRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir, HRegionInfo 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<StoreFile> storeFiles)
          Closes and archives the specified store files from the specified family.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

REGION_INFO_FILE

public static final String REGION_INFO_FILE
Name of the region info file that resides just under the region directory.

See Also:
Constant Field Values

REGION_MERGES_DIR

public static final String REGION_MERGES_DIR
Temporary subdirectory of the region directory used for merges.

See Also:
Constant Field Values

REGION_SPLITS_DIR

public static final String REGION_SPLITS_DIR
Temporary subdirectory of the region directory used for splits.

See Also:
Constant Field Values
Method Detail

getFileSystem

public org.apache.hadoop.fs.FileSystem getFileSystem()
Returns:
the underlying FileSystem

getRegionInfo

public HRegionInfo getRegionInfo()
Returns:
the HRegionInfo that describe this on-disk region view

getTableDir

public org.apache.hadoop.fs.Path getTableDir()
Returns:
Path to the region's root directory.

getRegionDir

public org.apache.hadoop.fs.Path getRegionDir()
Returns:
Path to the region directory.

getStoreDir

public org.apache.hadoop.fs.Path getStoreDir(String familyName)
Returns the directory path of the specified family

Parameters:
familyName - Column Family Name
Returns:
Path to the directory of the specified family

getStoreFiles

public Collection<StoreFileInfo> getStoreFiles(byte[] familyName)
                                        throws IOException
Returns the store files available for the family. This methods performs the filtering based on the valid store files.

Parameters:
familyName - Column Family Name
Returns:
a set of StoreFileInfo for the specified family.
Throws:
IOException

getStoreFiles

public Collection<StoreFileInfo> getStoreFiles(String familyName)
                                        throws IOException
Throws:
IOException

getStoreFiles

public Collection<StoreFileInfo> getStoreFiles(String familyName,
                                               boolean validate)
                                        throws IOException
Returns the store files available for the family. This methods performs the filtering based on the valid store files.

Parameters:
familyName - Column Family Name
Returns:
a set of StoreFileInfo for the specified family.
Throws:
IOException

hasReferences

public boolean hasReferences(String familyName)
                      throws IOException
Returns true if the specified family has reference files

Parameters:
familyName - Column Family Name
Returns:
true if family contains reference files
Throws:
IOException

hasReferences

public boolean hasReferences(HTableDescriptor htd)
                      throws IOException
Check whether region has Reference file

Parameters:
htd - table desciptor of the region
Returns:
true if region has reference file
Throws:
IOException

getFamilies

public Collection<String> getFamilies()
                               throws IOException
Returns:
the set of families present on disk
Throws:
IOException

deleteFamily

public void deleteFamily(String familyName)
                  throws IOException
Remove the region family from disk, archiving the store files.

Parameters:
familyName - Column Family Name
Throws:
IOException - if an error occours during the archiving

createTempName

public org.apache.hadoop.fs.Path createTempName()
Generate a unique temporary Path. Used in conjuction with commitStoreFile() to get a safer file creation. Path file = fs.createTempName(); ...StoreFile.Writer(file)... fs.commitStoreFile("family", file);

Returns:
Unique Path of the temporary file

createTempName

public org.apache.hadoop.fs.Path createTempName(String suffix)
Generate a unique temporary Path. Used in conjuction with commitStoreFile() to get a safer file creation. Path file = fs.createTempName(); ...StoreFile.Writer(file)... fs.commitStoreFile("family", file);

Parameters:
suffix - extra information to append to the generated name
Returns:
Unique Path of the temporary file

commitStoreFile

public org.apache.hadoop.fs.Path commitStoreFile(String familyName,
                                                 org.apache.hadoop.fs.Path buildPath)
                                          throws IOException
Move the file from a build/temp location to the main family store directory.

Parameters:
familyName - Family that will gain the file
buildPath - Path to the file to commit.
Returns:
The new Path of the committed file
Throws:
IOException

removeStoreFile

public void removeStoreFile(String familyName,
                            org.apache.hadoop.fs.Path filePath)
                     throws IOException
Archives the specified store file from the specified family.

Parameters:
familyName - Family that contains the store files
filePath - Path to the store file to remove
Throws:
IOException - if the archiving fails

removeStoreFiles

public void removeStoreFiles(String familyName,
                             Collection<StoreFile> storeFiles)
                      throws IOException
Closes and archives the specified store files from the specified family.

Parameters:
familyName - Family that contains the store files
storeFiles - set of store files to remove
Throws:
IOException - if the archiving fails

loadRegionInfoFileContent

public static HRegionInfo loadRegionInfoFileContent(org.apache.hadoop.fs.FileSystem fs,
                                                    org.apache.hadoop.fs.Path regionDir)
                                             throws IOException
Create a HRegionInfo from the serialized version on-disk.

Parameters:
fs - FileSystem that contains the Region Info file
regionDir - Path to the Region Directory that contains the Info file
Returns:
An HRegionInfo instance gotten from the Region Info file.
Throws:
IOException - if an error occurred during file open/read operation.

createRegionOnFileSystem

public static HRegionFileSystem createRegionOnFileSystem(org.apache.hadoop.conf.Configuration conf,
                                                         org.apache.hadoop.fs.FileSystem fs,
                                                         org.apache.hadoop.fs.Path tableDir,
                                                         HRegionInfo regionInfo)
                                                  throws IOException
Create a new Region on file-system.

Parameters:
conf - the Configuration to use
fs - FileSystem from which to add the region
tableDir - Path to where the table is being stored
regionInfo - HRegionInfo for region to be added
Throws:
IOException - if the region creation fails due to a FileSystem exception.

openRegionFromFileSystem

public static HRegionFileSystem openRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf,
                                                         org.apache.hadoop.fs.FileSystem fs,
                                                         org.apache.hadoop.fs.Path tableDir,
                                                         HRegionInfo regionInfo,
                                                         boolean readOnly)
                                                  throws IOException
Open Region from file-system.

Parameters:
conf - the Configuration to use
fs - FileSystem from which to add the region
tableDir - Path to where the table is being stored
regionInfo - HRegionInfo for region to be added
readOnly - True if you don't want to edit the region data
Throws:
IOException - if the region creation fails due to a FileSystem exception.

deleteRegionFromFileSystem

public static void deleteRegionFromFileSystem(org.apache.hadoop.conf.Configuration conf,
                                              org.apache.hadoop.fs.FileSystem fs,
                                              org.apache.hadoop.fs.Path tableDir,
                                              HRegionInfo regionInfo)
                                       throws IOException
Remove the region from the table directory, archiving the region's hfiles.

Parameters:
conf - the Configuration to use
fs - FileSystem from which to remove the region
tableDir - Path to where the table is being stored
regionInfo - HRegionInfo for region to be deleted
Throws:
IOException - if the request cannot be completed


Copyright © 2015 The Apache Software Foundation. All rights reserved.