HADOOP-15789. DistCp does not clean staging folder if class extends DistCp. Contributed by Lawrence Andrews. (#4534)

Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
Ayush Saxena 2022-07-08 17:04:20 +05:30 committed by GitHub
parent 8e39e35bea
commit 96f8e5b6f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -473,13 +473,18 @@ public class DistCp extends Configured implements Tool {
return config;
}
private synchronized void cleanup() {
/**
* Clean the staging folder created by distcp.
*/
protected synchronized void cleanup() {
try {
if (metaFolder != null) {
if (jobFS != null) {
jobFS.delete(metaFolder, true);
synchronized (this) {
if (jobFS != null) {
jobFS.delete(metaFolder, true);
}
metaFolder = null;
}
metaFolder = null;
}
} catch (IOException e) {
LOG.error("Unable to cleanup meta folder: " + metaFolder, e);