@InterfaceAudience.Private public class HFileArchiver extends Object
StoreFiles
)
for a HRegion from the FileSystem
. The hfiles will be archived or deleted, depending on
the state of the system.Modifier and Type | Class and Description |
---|---|
private static class |
HFileArchiver.File
Wrapper to handle file operations uniformly
|
private static class |
HFileArchiver.FileablePath
|
private static class |
HFileArchiver.FileableStoreFile
|
private static class |
HFileArchiver.FileConverter<T>
Adapt a type to match the
HFileArchiver.File interface, which is used internally for handling
archival/removal of files |
private static class |
HFileArchiver.FileStatusConverter
Convert a FileStatus to something we can manage in the archiving
|
private static class |
HFileArchiver.StoreToFile
Convert the
HStoreFile into something we can manage in the archive
methods |
Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_RETRIES_NUMBER
Number of retries in case of fs operation failure
|
private static org.apache.hbase.thirdparty.com.google.common.base.Function<HFileArchiver.File,org.apache.hadoop.fs.Path> |
FUNC_FILE_TO_PATH |
private static org.slf4j.Logger |
LOG |
private static String |
SEPARATOR |
Modifier | Constructor and Description |
---|---|
private |
HFileArchiver() |
Modifier and Type | Method and Description |
---|---|
static void |
archiveFamily(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration conf,
RegionInfo parent,
org.apache.hadoop.fs.Path tableDir,
byte[] family)
Remove from the specified region the store files of the specified column family,
either by archiving them or outright deletion
|
static void |
archiveFamilyByFamilyDir(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.conf.Configuration conf,
RegionInfo parent,
org.apache.hadoop.fs.Path familyDir,
byte[] family)
Removes from the specified region the store files of the specified column family,
either by archiving them or outright deletion
|
static void |
archiveRegion(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
RegionInfo info)
Cleans up all the files for a HRegion by archiving the HFiles to the archive directory
|
static boolean |
archiveRegion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
org.apache.hadoop.fs.Path tableDir,
org.apache.hadoop.fs.Path regionDir)
Remove an entire region from the table directory via archiving the region's hfiles.
|
static void |
archiveStoreFile(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
RegionInfo regionInfo,
org.apache.hadoop.fs.Path tableDir,
byte[] family,
org.apache.hadoop.fs.Path storeFile)
Archive the store file
|
static void |
archiveStoreFiles(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
RegionInfo regionInfo,
org.apache.hadoop.fs.Path tableDir,
byte[] family,
Collection<HStoreFile> compactedFiles)
Remove the store files, either by archiving them or outright deletion
|
private static boolean |
deleteRegionWithoutArchiving(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path regionDir)
Without regard for backup, delete a region.
|
private static void |
deleteStoreFilesWithoutArchiving(Collection<HStoreFile> compactedFiles)
Just do a simple delete of the given store files
|
static boolean |
exists(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
RegionInfo info) |
private static List<HFileArchiver.File> |
resolveAndArchive(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path baseArchiveDir,
Collection<HFileArchiver.File> toArchive,
long start)
Resolve any conflict with an existing archive file via timestamp-append
renaming of the existing file and then archive the passed in files.
|
private static boolean |
resolveAndArchiveFile(org.apache.hadoop.fs.Path archiveDir,
HFileArchiver.File currentFile,
String archiveStartTime)
Attempt to archive the passed in file to the archive directory.
|
private static final org.slf4j.Logger LOG
private static final String SEPARATOR
private static final int DEFAULT_RETRIES_NUMBER
private static final org.apache.hbase.thirdparty.com.google.common.base.Function<HFileArchiver.File,org.apache.hadoop.fs.Path> FUNC_FILE_TO_PATH
private HFileArchiver()
public static boolean exists(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, RegionInfo info) throws IOException
IOException
public static void archiveRegion(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, RegionInfo info) throws IOException
conf
- the configuration to usefs
- the file system objectinfo
- RegionInfo for region to be deletedIOException
public static boolean archiveRegion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, org.apache.hadoop.fs.Path tableDir, org.apache.hadoop.fs.Path regionDir) throws IOException
fs
- FileSystem
from which to remove the regionrootdir
- Path
to the root directory where hbase files are stored (for building
the archive path)tableDir
- Path
to where the table is being stored (for building the archive path)regionDir
- Path
to where a region is being stored (for building the archive path)IOException
- if the request cannot be completedpublic static void archiveFamily(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, RegionInfo parent, org.apache.hadoop.fs.Path tableDir, byte[] family) throws IOException
fs
- the filesystem where the store files liveconf
- Configuration
to examine to determine the archive directoryparent
- Parent region hosting the store filestableDir
- Path
to where the table is being stored (for building the archive path)family
- the family hosting the store filesIOException
- if the files could not be correctly disposed.public static void archiveFamilyByFamilyDir(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, RegionInfo parent, org.apache.hadoop.fs.Path familyDir, byte[] family) throws IOException
fs
- the filesystem where the store files liveconf
- Configuration
to examine to determine the archive directoryparent
- Parent region hosting the store filesfamilyDir
- Path
to where the family is being storedfamily
- the family hosting the store filesIOException
- if the files could not be correctly disposed.public static void archiveStoreFiles(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, RegionInfo regionInfo, org.apache.hadoop.fs.Path tableDir, byte[] family, Collection<HStoreFile> compactedFiles) throws IOException, FailedArchiveException
conf
- Configuration
to examine to determine the archive directoryfs
- the filesystem where the store files liveregionInfo
- RegionInfo
of the region hosting the store filesfamily
- the family hosting the store filescompactedFiles
- files to be disposed of. No further reading of these files should be
attempted; otherwise likely to cause an IOException
IOException
- if the files could not be correctly disposed.FailedArchiveException
public static void archiveStoreFile(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, RegionInfo regionInfo, org.apache.hadoop.fs.Path tableDir, byte[] family, org.apache.hadoop.fs.Path storeFile) throws IOException
fs
- the filesystem where the store files liveregionInfo
- region hosting the store filesconf
- Configuration
to examine to determine the archive directorytableDir
- Path
to where the table is being stored (for building the archive path)family
- the family hosting the store filesstoreFile
- file to be archivedIOException
- if the files could not be correctly disposed.private static List<HFileArchiver.File> resolveAndArchive(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path baseArchiveDir, Collection<HFileArchiver.File> toArchive, long start) throws IOException
fs
- FileSystem
on which to archive the filesbaseArchiveDir
- base archive directory to store the files. If any of
the files to archive are directories, will append the name of the
directory to the base archive directory name, creating a parallel
structure.toArchive
- files/directories that need to be archviedstart
- time the archiving started - used for resolving archive
conflicts.IOException
- if an unexpected file operation exception occurredprivate static boolean resolveAndArchiveFile(org.apache.hadoop.fs.Path archiveDir, HFileArchiver.File currentFile, String archiveStartTime) throws IOException
If the same file already exists in the archive, it is moved to a timestamped directory under the archive directory and the new file is put in its place.
archiveDir
- Path
to the directory that stores the archives of the hfilescurrentFile
- Path
to the original HFile that will be archivedarchiveStartTime
- time the archiving started, to resolve naming conflictsIOException
- on failure to complete FileSystem
operations.private static boolean deleteRegionWithoutArchiving(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path regionDir) throws IOException
regionDir
- Path
to the region to be deleted.fs
- FileSystem from which to delete the regionIOException
- on filesystem operation failureprivate static void deleteStoreFilesWithoutArchiving(Collection<HStoreFile> compactedFiles) throws IOException
A best effort is made to delete each of the files, rather than bailing on the first failure.
compactedFiles
- store files to delete from the file system.IOException
- if a file cannot be deleted. All files will be attempted to deleted before
throwing the exception, rather than failing at the first file.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.