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
Modifier and TypeClassDescriptionstatic enum
private static class
private static class
(package private) static final class
(package private) static class
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
AbstractHBaseTool.OptionsOrderComparator
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private static final String
private static final String
private static final String
private static final String
static final String
Configuration prefix for overrides for the destination filesystemprivate static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
protected static final String
private static final String
private static final String
static final String
Configuration prefix for overrides for the source filesystemprivate static final int
private String
private int
private String
private org.apache.hadoop.fs.Path
private static final org.slf4j.Logger
private int
private static final String
static final String
private org.apache.hadoop.fs.Path
private boolean
private boolean
private String
private String
private boolean
private boolean
private boolean
Fields inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Override this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.int
doWork()
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 void
protected void
protected void
processOptions
(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd) This method is called to process the options after they have been parsed.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) Run Map-Reduce Job to perform the files copy.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) 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) private void
setPermissionParallel
(org.apache.hadoop.fs.FileSystem outputFs, short filesMode, List<org.apache.hadoop.fs.Path> traversedPath, org.apache.hadoop.conf.Configuration conf) 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) 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, setConf
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
Methods 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:AbstractHBaseTool
This method is called to process the options after they have been parsed.- Specified by:
processOptions
in classAbstractHBaseTool
-
doWork
Execute the export snapshot by copying the snapshot metadata, hfiles and wals.- Specified by:
doWork
in classAbstractHBaseTool
- Returns:
- 0 on success, and != 0 upon failure.
- Throws:
IOException
-
printUsage
- Overrides:
printUsage
in classAbstractHBaseTool
-
addOptions
Description copied from class:AbstractHBaseTool
Override this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.- Specified by:
addOptions
in classAbstractHBaseTool
-
main
-