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 a5e774870e..e88d2b4dd5 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 @@ -947,6 +947,13 @@ public void updateApplicationState(ApplicationStateData appState) { 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 0a6220bb67..a43d43ef03 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 4ff7aeaf86..c21d8d4e0b 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 @@ -1037,7 +1037,7 @@ public void transition(RMAppImpl app, RMAppEvent event) { 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(); app.rmContext.getSystemMetricsPublisher().appLaunched( app, app.launchTime); 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 57bdac42ea..8cff8fcfa8 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 @@ -109,6 +109,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; @@ -486,8 +487,12 @@ private void assertAppFinalStateNotSaved(RMApp application){ 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) {