HBASE-26720 ExportSnapshot should validate the source snapshot before copying files (#4216)
Signed-off-by: Andrew Purtell <apurtell@apache.org> Signed-off-by: Xiaolin Ha <haxiaolin@apache.org>
This commit is contained in:
parent
b9c59438a4
commit
ef280d4d8d
|
@ -143,6 +143,8 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
|
||||||
"Do not verify checksum, use name+length only.");
|
"Do not verify checksum, use name+length only.");
|
||||||
static final Option NO_TARGET_VERIFY = new Option(null, "no-target-verify", false,
|
static final Option NO_TARGET_VERIFY = new Option(null, "no-target-verify", false,
|
||||||
"Do not verify the integrity of the exported snapshot.");
|
"Do not verify the integrity of the exported snapshot.");
|
||||||
|
static final Option NO_SOURCE_VERIFY = new Option(null, "no-source-verify", false,
|
||||||
|
"Do not verify the source of the snapshot.");
|
||||||
static final Option OVERWRITE = new Option(null, "overwrite", false,
|
static final Option OVERWRITE = new Option(null, "overwrite", false,
|
||||||
"Rewrite the snapshot manifest if already exists.");
|
"Rewrite the snapshot manifest if already exists.");
|
||||||
static final Option CHUSER = new Option(null, "chuser", true,
|
static final Option CHUSER = new Option(null, "chuser", true,
|
||||||
|
@ -915,6 +917,7 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean verifyTarget = true;
|
private boolean verifyTarget = true;
|
||||||
|
private boolean verifySource = true;
|
||||||
private boolean verifyChecksum = true;
|
private boolean verifyChecksum = true;
|
||||||
private String snapshotName = null;
|
private String snapshotName = null;
|
||||||
private String targetName = null;
|
private String targetName = null;
|
||||||
|
@ -946,6 +949,7 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
|
||||||
// And verifyChecksum and verifyTarget with values read from old args in processOldArgs(...).
|
// And verifyChecksum and verifyTarget with values read from old args in processOldArgs(...).
|
||||||
verifyChecksum = !cmd.hasOption(Options.NO_CHECKSUM_VERIFY.getLongOpt());
|
verifyChecksum = !cmd.hasOption(Options.NO_CHECKSUM_VERIFY.getLongOpt());
|
||||||
verifyTarget = !cmd.hasOption(Options.NO_TARGET_VERIFY.getLongOpt());
|
verifyTarget = !cmd.hasOption(Options.NO_TARGET_VERIFY.getLongOpt());
|
||||||
|
verifySource = !cmd.hasOption(Options.NO_SOURCE_VERIFY.getLongOpt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -996,6 +1000,13 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
|
||||||
LOG.debug("outputFs={}, outputRoot={}, skipTmp={}, initialOutputSnapshotDir={}",
|
LOG.debug("outputFs={}, outputRoot={}, skipTmp={}, initialOutputSnapshotDir={}",
|
||||||
outputFs, outputRoot.toString(), skipTmp, initialOutputSnapshotDir);
|
outputFs, outputRoot.toString(), skipTmp, initialOutputSnapshotDir);
|
||||||
|
|
||||||
|
// Verify snapshot source before copying files
|
||||||
|
if (verifySource) {
|
||||||
|
LOG.info("Verify snapshot source, inputFs={}, inputRoot={}, snapshotDir={}.",
|
||||||
|
inputFs.getUri(), inputRoot, snapshotDir);
|
||||||
|
verifySnapshot(srcConf, inputFs, inputRoot, snapshotDir);
|
||||||
|
}
|
||||||
|
|
||||||
// Find the necessary directory which need to change owner and group
|
// Find the necessary directory which need to change owner and group
|
||||||
Path needSetOwnerDir = SnapshotDescriptionUtils.getSnapshotRootDir(outputRoot);
|
Path needSetOwnerDir = SnapshotDescriptionUtils.getSnapshotRootDir(outputRoot);
|
||||||
if (outputFs.exists(needSetOwnerDir)) {
|
if (outputFs.exists(needSetOwnerDir)) {
|
||||||
|
@ -1146,6 +1157,7 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
|
||||||
addOption(Options.TARGET_NAME);
|
addOption(Options.TARGET_NAME);
|
||||||
addOption(Options.NO_CHECKSUM_VERIFY);
|
addOption(Options.NO_CHECKSUM_VERIFY);
|
||||||
addOption(Options.NO_TARGET_VERIFY);
|
addOption(Options.NO_TARGET_VERIFY);
|
||||||
|
addOption(Options.NO_SOURCE_VERIFY);
|
||||||
addOption(Options.OVERWRITE);
|
addOption(Options.OVERWRITE);
|
||||||
addOption(Options.CHUSER);
|
addOption(Options.CHUSER);
|
||||||
addOption(Options.CHGROUP);
|
addOption(Options.CHGROUP);
|
||||||
|
|
Loading…
Reference in New Issue