Package org.apache.hadoop.hbase.snapshot
Class ExportSnapshot
java.lang.Object
org.apache.hadoop.hbase.util.AbstractHBaseTool
org.apache.hadoop.hbase.snapshot.ExportSnapshot
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable,org.apache.hadoop.util.Tool
- Direct Known Subclasses:
MapReduceBackupCopyJob.SnapshotCopy
@Public
public class ExportSnapshot
extends AbstractHBaseTool
implements org.apache.hadoop.util.Tool
Export the specified snapshot to a given FileSystem. The .snapshot/name folder is copied to the
destination cluster and then all the hfiles/wals are copied using a Map-Reduce Job in the
.archive/ location. When everything is done, the second cluster can restore the snapshot.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumprivate static classprivate static class(package private) static final class(package private) static classNested classes/interfaces inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
AbstractHBaseTool.OptionsOrderComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringstatic final StringConfiguration prefix for overrides for the destination filesystemprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprotected static final Stringprivate static final Stringprivate static final Stringstatic final StringConfiguration prefix for overrides for the source filesystemprivate static final intprivate Stringprivate intprivate Stringprivate org.apache.hadoop.fs.Pathprivate static final org.slf4j.Loggerprivate intprivate static final Stringstatic final Stringprivate org.apache.hadoop.fs.Pathprivate booleanprivate booleanprivate Stringprivate Stringprivate booleanprivate booleanprivate booleanFields inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidOverride this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)and similar methods.intdoWork()Execute the export snapshot by copying the snapshot metadata, hfiles and wals.(package private) static List<List<Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo,Long>>> getBalancedSplits(List<Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo, Long>> files, int ngroups) Given a list of file paths and sizes, create around ngroups in as balanced a way as possible.private static Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo,Long> getSnapshotFileAndSize(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, TableName table, String region, String family, String hfile, long size) private static List<Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo,Long>> getSnapshotFiles(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir) Extract the list of files (HFiles/WALs) to copy using Map-Reduce.static voidprotected voidprotected voidprocessOptions(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd) This method is called to process the options after they have been parsed.private voidrunCopyJob(org.apache.hadoop.fs.Path inputRoot, org.apache.hadoop.fs.Path outputRoot, String snapshotName, org.apache.hadoop.fs.Path snapshotDir, boolean verifyChecksum, String filesUser, String filesGroup, int filesMode, int mappers, int bandwidthMB) Run Map-Reduce Job to perform the files copy.private voidsetConfigParallel(org.apache.hadoop.fs.FileSystem outputFs, List<org.apache.hadoop.fs.Path> traversedPath, BiConsumer<org.apache.hadoop.fs.FileSystem, org.apache.hadoop.fs.Path> task, org.apache.hadoop.conf.Configuration conf) private voidsetOwnerParallel(org.apache.hadoop.fs.FileSystem outputFs, String filesUser, String filesGroup, org.apache.hadoop.conf.Configuration conf, List<org.apache.hadoop.fs.Path> traversedPath) private voidsetPermissionParallel(org.apache.hadoop.fs.FileSystem outputFs, short filesMode, List<org.apache.hadoop.fs.Path> traversedPath, org.apache.hadoop.conf.Configuration conf) private voidverifySnapshot(org.apache.hadoop.conf.Configuration baseConf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path snapshotDir) Methods inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
addOption, addOptNoArg, addOptNoArg, addOptWithArg, addOptWithArg, addRequiredOption, addRequiredOptWithArg, addRequiredOptWithArg, doStaticMain, getConf, getOptionAsDouble, getOptionAsInt, getOptionAsInt, getOptionAsLong, getOptionAsLong, newParser, parseArgs, parseInt, parseLong, printUsage, processOldArgs, run, setConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConfMethods inherited from interface org.apache.hadoop.util.Tool
run
-
Field Details
-
NAME
- See Also:
-
CONF_SOURCE_PREFIX
Configuration prefix for overrides for the source filesystem- See Also:
-
CONF_DEST_PREFIX
Configuration prefix for overrides for the destination filesystem- See Also:
-
LOG
-
MR_NUM_MAPS
- See Also:
-
CONF_NUM_SPLITS
- See Also:
-
CONF_SNAPSHOT_NAME
- See Also:
-
CONF_SNAPSHOT_DIR
- See Also:
-
CONF_FILES_USER
- See Also:
-
CONF_FILES_GROUP
- See Also:
-
CONF_FILES_MODE
- See Also:
-
CONF_CHECKSUM_VERIFY
- See Also:
-
CONF_OUTPUT_ROOT
- See Also:
-
CONF_INPUT_ROOT
- See Also:
-
CONF_BUFFER_SIZE
- See Also:
-
CONF_MAP_GROUP
- See Also:
-
CONF_BANDWIDTH_MB
- See Also:
-
CONF_MR_JOB_NAME
- See Also:
-
CONF_SKIP_TMP
- See Also:
-
CONF_COPY_MANIFEST_THREADS
- See Also:
-
DEFAULT_COPY_MANIFEST_THREADS
-
verifyTarget
-
verifySource
-
verifyChecksum
-
snapshotName
-
targetName
-
overwrite
-
filesGroup
-
filesUser
-
outputRoot
-
inputRoot
-
bandwidthMB
-
filesMode
-
mappers
-
resetTtl
-
-
Constructor Details
-
ExportSnapshot
public ExportSnapshot()
-
-
Method Details
-
getSnapshotFiles
private static List<Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo,Long>> getSnapshotFiles(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path snapshotDir) throws IOException Extract the list of files (HFiles/WALs) to copy using Map-Reduce.- Returns:
- list of files referenced by the snapshot (pair of path and size)
- Throws:
IOException
-
getSnapshotFileAndSize
private static Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo,Long> getSnapshotFileAndSize(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, TableName table, String region, String family, String hfile, long size) throws IOException - Throws:
IOException
-
getBalancedSplits
static List<List<Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo,Long>>> getBalancedSplits(List<Pair<org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotFileInfo, Long>> files, int ngroups) Given a list of file paths and sizes, create around ngroups in as balanced a way as possible. The groups created will have similar amounts of bytes.The algorithm used is pretty straightforward; the file list is sorted by size, and then each group fetch the bigger file available, iterating through groups alternating the direction.
-
runCopyJob
private void runCopyJob(org.apache.hadoop.fs.Path inputRoot, org.apache.hadoop.fs.Path outputRoot, String snapshotName, org.apache.hadoop.fs.Path snapshotDir, boolean verifyChecksum, String filesUser, String filesGroup, int filesMode, int mappers, int bandwidthMB) throws IOException, InterruptedException, ClassNotFoundException Run Map-Reduce Job to perform the files copy. -
verifySnapshot
private void verifySnapshot(org.apache.hadoop.conf.Configuration baseConf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path snapshotDir) throws IOException - Throws:
IOException
-
setConfigParallel
private void setConfigParallel(org.apache.hadoop.fs.FileSystem outputFs, List<org.apache.hadoop.fs.Path> traversedPath, BiConsumer<org.apache.hadoop.fs.FileSystem, org.apache.hadoop.fs.Path> task, org.apache.hadoop.conf.Configuration conf) throws IOException- Throws:
IOException
-
setOwnerParallel
private void setOwnerParallel(org.apache.hadoop.fs.FileSystem outputFs, String filesUser, String filesGroup, org.apache.hadoop.conf.Configuration conf, List<org.apache.hadoop.fs.Path> traversedPath) throws IOException - Throws:
IOException
-
setPermissionParallel
private void setPermissionParallel(org.apache.hadoop.fs.FileSystem outputFs, short filesMode, List<org.apache.hadoop.fs.Path> traversedPath, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
processOptions
Description copied from class:AbstractHBaseToolThis method is called to process the options after they have been parsed.- Specified by:
processOptionsin classAbstractHBaseTool
-
doWork
Execute the export snapshot by copying the snapshot metadata, hfiles and wals.- Specified by:
doWorkin classAbstractHBaseTool- Returns:
- 0 on success, and != 0 upon failure.
- Throws:
IOException
-
printUsage
- Overrides:
printUsagein classAbstractHBaseTool
-
addOptions
Description copied from class:AbstractHBaseToolOverride this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)and similar methods.- Specified by:
addOptionsin classAbstractHBaseTool
-
main
-