From 81ba30211e0185e7045c0ddac5d56e1852563fa3 Mon Sep 17 00:00:00 2001 From: Jian He Date: Thu, 13 Nov 2014 15:33:20 -0800 Subject: [PATCH] YARN-2856. Fixed RMAppImpl to handle ATTEMPT_KILLED event at ACCEPTED state on app recovery. Contributed by Rohith Sharmaks (cherry picked from commit d005404ef7211fe96ce1801ed267a249568540fd) (cherry picked from commit beb184ac580b0d89351a3f3a7201da34a26db1c1) (cherry picked from commit 325bb33988743d60cb333002f9da60314241632e) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../resourcemanager/rmapp/RMAppImpl.java | 3 +++ .../rmapp/TestRMAppTransitions.java | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 46a91d0ea82..6691f6e5474 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -12,6 +12,9 @@ Release 2.6.1 - UNRELEASED BUG FIXES + YARN-2856. Fixed RMAppImpl to handle ATTEMPT_KILLED event at ACCEPTED state + on app recovery. (Rohith Sharmaks via jianhe) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java index aeb2cda6930..751dbe44be5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java @@ -229,6 +229,9 @@ public class RMAppImpl implements RMApp, Recoverable { new FinalSavingTransition(FINISHED_TRANSITION, RMAppState.FINISHED)) .addTransition(RMAppState.ACCEPTED, RMAppState.KILLING, RMAppEventType.KILL, new KillAttemptTransition()) + .addTransition(RMAppState.ACCEPTED, RMAppState.FINAL_SAVING, + RMAppEventType.ATTEMPT_KILLED, + new FinalSavingTransition(new AppKilledTransition(), RMAppState.KILLED)) .addTransition(RMAppState.ACCEPTED, RMAppState.ACCEPTED, RMAppEventType.APP_RUNNING_ON_NODE, new AppRunningOnNodeTransition()) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java index e68d074122b..0a2f0d446e6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java @@ -714,6 +714,29 @@ public class TestRMAppTransitions { verifyApplicationFinished(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED); } + + @Test + public void testAppAcceptedAttemptKilled() throws IOException, + InterruptedException { + LOG.info("--- START: testAppAcceptedAttemptKilled ---"); + RMApp application = testCreateAppAccepted(null); + + // ACCEPTED => FINAL_SAVING event RMAppEventType.ATTEMPT_KILLED + // When application recovery happens for attempt is KILLED but app is + // RUNNING. + RMAppEvent event = + new RMAppEvent(application.getApplicationId(), + RMAppEventType.ATTEMPT_KILLED); + application.handle(event); + rmDispatcher.await(); + + assertAppState(RMAppState.FINAL_SAVING, application); + sendAppUpdateSavedEvent(application); + assertKilled(application); + assertAppFinalStateSaved(application); + verifyApplicationFinished(RMAppState.KILLED); + verifyAppRemovedSchedulerEvent(RMAppState.KILLED); + } @Test public void testAppRunningKill() throws IOException {