From 3f4221ec343614ed36fcf1285040f375ed642da4 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Wed, 7 Jul 2021 09:08:15 +0530 Subject: [PATCH] MAPREDUCE-7351 - CleanupJob during handle of SIGTERM signal (#3176) Co-authored-by: Shubham Gupta --- .../apache/hadoop/mapreduce/v2/app/MRAppMaster.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java index dfde6b4227..38884c901b 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/MRAppMaster.java @@ -1714,6 +1714,19 @@ public void run() { } appMaster.notifyIsLastAMRetry(appMaster.isLastAMRetry); appMaster.stop(); + try { + JobContext jobContext = appMaster + .getJobContextFromConf(appMaster.getConfig()); + appMaster.committer.abortJob(jobContext, State.KILLED); + } catch (FileNotFoundException e) { + System.out.println("Previous job temporary " + + "files do not exist, no clean up was necessary."); + } catch (Exception e) { + // the clean up of a previous attempt is not critical to the success + // of this job - only logging the error + System.err.println("Error while trying to " + + "clean up previous job's temporary files" + e); + } } }