From 9da9b6d58e3cf9322a68eb261deab6a1be3e98c3 Mon Sep 17 00:00:00 2001 From: Szilard Nemeth Date: Mon, 12 Aug 2019 15:15:43 +0200 Subject: [PATCH] YARN-9723. ApplicationPlacementContext is not required for terminated jobs during recovery. Contributed by Prabhu Joseph (cherry picked from commit e4b538bbda6dc25d7f45bffd6a4ce49f3f84acdc) --- .../server/resourcemanager/RMAppManager.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java index 7f9f51cbec0..46e92e39015 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java @@ -63,6 +63,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRecoverEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl; +import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue; @@ -322,7 +323,7 @@ public class RMAppManager implements EventHandler, // Passing start time as -1. It will be eventually set in RMAppImpl // constructor. RMAppImpl application = createAndPopulateNewRMApp( - submissionContext, submitTime, user, false, -1); + submissionContext, submitTime, user, false, -1, null); try { if (UserGroupInformation.isSecurityEnabled()) { this.rmContext.getDelegationTokenRenewer() @@ -359,18 +360,22 @@ public class RMAppManager implements EventHandler, // create and recover app. RMAppImpl application = createAndPopulateNewRMApp(appContext, appState.getSubmitTime(), - appState.getUser(), true, appState.getStartTime()); + appState.getUser(), true, appState.getStartTime(), + appState.getState()); application.handle(new RMAppRecoverEvent(appId, rmState)); } private RMAppImpl createAndPopulateNewRMApp( ApplicationSubmissionContext submissionContext, long submitTime, - String user, boolean isRecovery, long startTime) throws YarnException { + String user, boolean isRecovery, long startTime, + RMAppState recoveredFinalState) throws YarnException { - ApplicationPlacementContext placementContext = - placeApplication(rmContext.getQueuePlacementManager(), - submissionContext, user, isRecovery); + ApplicationPlacementContext placementContext = null; + if (recoveredFinalState == null) { + placementContext = placeApplication(rmContext.getQueuePlacementManager(), + submissionContext, user, isRecovery); + } // We only replace the queue when it's a new application if (!isRecovery) {