HBASE-20668 Avoid permission change if ExportSnapshot's copy fails
This commit is contained in:
parent
d3e2248f12
commit
5a200b5902
|
@ -1027,25 +1027,29 @@ public class ExportSnapshot extends AbstractHBaseTool implements Tool {
|
||||||
// The snapshot references must be copied before the hfiles otherwise the cleaner
|
// The snapshot references must be copied before the hfiles otherwise the cleaner
|
||||||
// will remove them because they are unreferenced.
|
// will remove them because they are unreferenced.
|
||||||
List<Path> travesedPaths = new ArrayList<>();
|
List<Path> travesedPaths = new ArrayList<>();
|
||||||
|
boolean copySucceeded = false;
|
||||||
try {
|
try {
|
||||||
LOG.info("Copy Snapshot Manifest");
|
LOG.info("Copy Snapshot Manifest from " + snapshotDir + " to " + initialOutputSnapshotDir);
|
||||||
travesedPaths =
|
travesedPaths =
|
||||||
FSUtils.copyFilesParallel(inputFs, snapshotDir, outputFs, initialOutputSnapshotDir, conf,
|
FSUtils.copyFilesParallel(inputFs, snapshotDir, outputFs, initialOutputSnapshotDir, conf,
|
||||||
conf.getInt(CONF_COPY_MANIFEST_THREADS, DEFAULT_COPY_MANIFEST_THREADS));
|
conf.getInt(CONF_COPY_MANIFEST_THREADS, DEFAULT_COPY_MANIFEST_THREADS));
|
||||||
|
copySucceeded = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ExportSnapshotException("Failed to copy the snapshot directory: from=" +
|
throw new ExportSnapshotException("Failed to copy the snapshot directory: from=" +
|
||||||
snapshotDir + " to=" + initialOutputSnapshotDir, e);
|
snapshotDir + " to=" + initialOutputSnapshotDir, e);
|
||||||
} finally {
|
} finally {
|
||||||
if (filesUser != null || filesGroup != null) {
|
if (copySucceeded) {
|
||||||
LOG.warn((filesUser == null ? "" : "Change the owner of " + needSetOwnerDir + " to "
|
if (filesUser != null || filesGroup != null) {
|
||||||
+ filesUser)
|
LOG.warn((filesUser == null ? "" : "Change the owner of " + needSetOwnerDir + " to "
|
||||||
+ (filesGroup == null ? "" : ", Change the group of " + needSetOwnerDir + " to "
|
+ filesUser)
|
||||||
+ filesGroup));
|
+ (filesGroup == null ? "" : ", Change the group of " + needSetOwnerDir + " to "
|
||||||
setOwnerParallel(outputFs, filesUser, filesGroup, conf, travesedPaths);
|
+ filesGroup));
|
||||||
}
|
setOwnerParallel(outputFs, filesUser, filesGroup, conf, travesedPaths);
|
||||||
if (filesMode > 0) {
|
}
|
||||||
LOG.warn("Change the permission of " + needSetOwnerDir + " to " + filesMode);
|
if (filesMode > 0) {
|
||||||
setPermissionParallel(outputFs, (short)filesMode, travesedPaths, conf);
|
LOG.warn("Change the permission of " + needSetOwnerDir + " to " + filesMode);
|
||||||
|
setPermissionParallel(outputFs, (short)filesMode, travesedPaths, conf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue