From 0e88bcd8e6b43ed2b3ed2f1e4e68193562eb3b38 Mon Sep 17 00:00:00 2001 From: Jonathan Hung Date: Mon, 9 Sep 2019 00:23:04 -0700 Subject: [PATCH] YARN-9820. RM logs InvalidStateTransitionException when app is submitted. Contributed by Prabhu Joseph --- .../yarn/server/resourcemanager/recovery/RMStateStore.java | 7 +++++++ .../resourcemanager/recovery/RMStateUpdateAppEvent.java | 7 ++++++- .../yarn/server/resourcemanager/rmapp/RMAppImpl.java | 2 +- .../server/resourcemanager/rmapp/TestRMAppTransitions.java | 7 ++++++- 4 files changed, 20 insertions(+), 3 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/recovery/RMStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java index 0fc98df2a04..161e3179e46 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java @@ -852,6 +852,13 @@ public abstract class RMStateStore extends AbstractService { getRMStateStoreEventHandler().handle(new RMStateUpdateAppEvent(appState)); } + @SuppressWarnings("unchecked") + public void updateApplicationState(ApplicationStateData appState, + boolean notifyApp) { + getRMStateStoreEventHandler().handle(new RMStateUpdateAppEvent(appState, + notifyApp)); + } + public void updateApplicationStateSynchronously(ApplicationStateData appState, boolean notifyApp, SettableFuture resultFuture) { handleStoreEvent( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java index 0a6220bb678..a43d43ef031 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateUpdateAppEvent.java @@ -30,9 +30,14 @@ public class RMStateUpdateAppEvent extends RMStateStoreEvent { private SettableFuture future; public RMStateUpdateAppEvent(ApplicationStateData appState) { + this (appState, true); + } + + public RMStateUpdateAppEvent(ApplicationStateData appState, + boolean notifyApplication) { super(RMStateStoreEventType.UPDATE_APP); this.appState = appState; - this.notifyApplication = true; + this.notifyApplication = notifyApplication; this.future = null; } 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 71d0e808963..e725322c519 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 @@ -1036,7 +1036,7 @@ public class RMAppImpl implements RMApp, Recoverable { app.callerContext); appState.setApplicationTimeouts(app.getApplicationTimeouts()); appState.setLaunchTime(event.getTimestamp()); - app.rmContext.getStateStore().updateApplicationState(appState); + app.rmContext.getStateStore().updateApplicationState(appState, false); app.launchTime = event.getTimestamp(); } } 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 f5dcefb7b6a..b32ad1ef5c9 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 @@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.rmapp; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.eq; @@ -472,8 +473,12 @@ public class TestRMAppTransitions { private void assertAppStateLaunchTimeSaved(long expectedLaunchTime) { ArgumentCaptor state = ArgumentCaptor.forClass(ApplicationStateData.class); - verify(store, times(1)).updateApplicationState(state.capture()); + ArgumentCaptor notifyApp = + ArgumentCaptor.forClass(Boolean.class); + verify(store, times(1)).updateApplicationState(state.capture(), + notifyApp.capture()); assertEquals(expectedLaunchTime, state.getValue().getLaunchTime()); + assertFalse(notifyApp.getValue()); } private void assertKilled(RMApp application) {