Repository: hadoop Updated Branches: refs/heads/feature-YARN-2928 7d124943d -> d0858ac26
YARN-4392. ApplicationCreatedEvent event time resets after RM restart/failover. Contributed by Naganarasimha G R and Xuan Gong (cherry picked from commit 4546c7582b6762c18ba150d80a8976eb51a8290c) Conflicts: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d0858ac2 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d0858ac2 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d0858ac2 Branch: refs/heads/feature-YARN-2928 Commit: d0858ac26cdb2f36586eb3b04ba8b1e6cef4cc42 Parents: 7d12494 Author: Xuan <xg...@apache.org> Authored: Mon Dec 7 12:24:55 2015 -0800 Committer: naganarasimha_gr <naganarasimha...@gmail.com> Committed: Tue Dec 15 01:52:49 2015 +0530 ---------------------------------------------------------------------- hadoop-yarn-project/CHANGES.txt | 3 +++ .../server/resourcemanager/rmapp/RMAppImpl.java | 14 ++++++++--- .../server/resourcemanager/TestRMRestart.java | 25 +++++++++++++++++--- .../rmapp/TestRMAppTransitions.java | 5 +--- 4 files changed, 37 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/d0858ac2/hadoop-yarn-project/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 45faed0..559d9f6 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -1233,6 +1233,9 @@ Release 2.8.0 - UNRELEASED YARN-3840. Resource Manager web ui issue when sorting application by id (with application having id > 9999) (Mohammad Shahid Khan via jianhe) + YARN-4392. ApplicationCreatedEvent event time resets after RM restart/failover. + (Naganarasimha G R and Xuan Gong via xgong) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/d0858ac2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java ---------------------------------------------------------------------- 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 78f534f..c96b826 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 @@ -458,9 +458,6 @@ public class RMAppImpl implements RMApp, Recoverable { this.stateMachine = stateMachineFactory.make(this); - rmContext.getRMApplicationHistoryWriter().applicationStarted(this); - rmContext.getSystemMetricsPublisher().appCreated(this, startTime); - long localLogAggregationStatusTimeout = conf.getLong(YarnConfiguration.LOG_AGGREGATION_STATUS_TIME_OUT_MS, YarnConfiguration.DEFAULT_LOG_AGGREGATION_STATUS_TIME_OUT_MS); @@ -854,6 +851,9 @@ public class RMAppImpl implements RMApp, Recoverable { //TODO recover collector address. //this.collectorAddr = appState.getCollectorAddr(); + // send the ATS create Event + sendATSCreateEvent(this, this.startTime); + for(int i=0; i<appState.getAttemptCount(); ++i) { // create attempt createNewAttempt(); @@ -1142,6 +1142,9 @@ public class RMAppImpl implements RMApp, Recoverable { // communication LOG.info("Storing application with id " + app.applicationId); app.rmContext.getStateStore().storeNewApplication(app); + + // send the ATS create Event + app.sendATSCreateEvent(app, app.startTime); } } @@ -1786,4 +1789,9 @@ public class RMAppImpl implements RMApp, Recoverable { } return amNodeLabelExpression; } + + private void sendATSCreateEvent(RMApp app, long startTime) { + rmContext.getRMApplicationHistoryWriter().applicationStarted(app); + rmContext.getSystemMetricsPublisher().appCreated(app, startTime); + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/d0858ac2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index cd84208..d2b8eee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -18,15 +18,15 @@ package org.apache.hadoop.yarn.server.resourcemanager; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Supplier; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -87,6 +87,7 @@ import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; import org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus; import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; import org.apache.hadoop.yarn.server.api.records.NodeAction; +import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher; import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; @@ -113,7 +114,9 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; @@ -896,7 +899,13 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase { memStore.init(conf); // start RM - MockRM rm1 = createMockRM(conf, memStore); + MockRM rm1 = new MockRM(conf, memStore) { + @Override + protected SystemMetricsPublisher createSystemMetricsPublisher() { + return spy(super.createSystemMetricsPublisher()); + } + }; + rms.add(rm1); rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService()); @@ -925,6 +934,8 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase { rm1.waitForState(app2.getApplicationId(), RMAppState.KILLED); rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.KILLED); + verify(rm1.getRMContext().getSystemMetricsPublisher(),Mockito.times(3)) + .appCreated(any(RMApp.class), anyLong()); // restart rm MockRM rm2 = new MockRM(conf, memStore) { @@ -932,10 +943,18 @@ public class TestRMRestart extends ParameterizedSchedulerTestBase { protected RMAppManager createRMAppManager() { return spy(super.createRMAppManager()); } + + @Override + protected SystemMetricsPublisher createSystemMetricsPublisher() { + return spy(super.createSystemMetricsPublisher()); + } }; rms.add(rm2); rm2.start(); + verify(rm2.getRMContext().getSystemMetricsPublisher(),Mockito.times(3)) + .appCreated(any(RMApp.class), anyLong()); + GetApplicationsRequest request1 = GetApplicationsRequest.newInstance(EnumSet.of( YarnApplicationState.FINISHED, YarnApplicationState.KILLED, http://git-wip-us.apache.org/repos/asf/hadoop/blob/d0858ac2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestRMAppTransitions.java ---------------------------------------------------------------------- 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 600f9c6..e6519e1 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 @@ -18,8 +18,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.rmapp; -import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData; - import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; import static org.mockito.Mockito.doReturn; @@ -65,6 +63,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWri import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState; +import org.apache.hadoop.yarn.server.resourcemanager.recovery.records.ApplicationStateData; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent; @@ -373,8 +372,6 @@ public class TestRMAppTransitions { protected RMApp testCreateAppNewSaving( ApplicationSubmissionContext submissionContext) throws IOException { RMApp application = createNewTestApp(submissionContext); - verify(writer).applicationStarted(any(RMApp.class)); - verify(publisher).appCreated(any(RMApp.class), anyLong()); // NEW => NEW_SAVING event RMAppEventType.START RMAppEvent event = new RMAppEvent(application.getApplicationId(), RMAppEventType.START);