diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java index ec4ed0e..590c78e 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java @@ -46,7 +46,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState; import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; -import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.junit.Assert; import org.junit.Test; @@ -57,8 +57,6 @@ public void testAMRestartWithExistingContainers() throws Exception { YarnConfiguration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 2); - conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, - ResourceScheduler.class); MockRM rm1 = new MockRM(conf); rm1.start(); @@ -124,18 +122,19 @@ public void testAMRestartWithExistingContainers() throws Exception { ContainerId containerId6 = ContainerId.newInstance(am1.getApplicationAttemptId(), 6); nm1.nodeHeartbeat(true); - SchedulerApplicationAttempt schedulerAttempt = - ((CapacityScheduler) rm1.getResourceScheduler()) - .getCurrentAttemptForContainer(containerId6); - while (schedulerAttempt.getReservedContainers().size() == 0) { + SchedulerAppReport schedulerAppInfo = rm1.getResourceScheduler() + .getSchedulerAppInfo(containerId6.getApplicationAttemptId()); + while (schedulerAppInfo.getReservedContainers().isEmpty()) { System.out.println("Waiting for container " + containerId6 + " to be reserved."); nm1.nodeHeartbeat(true); Thread.sleep(200); + schedulerAppInfo = rm1.getResourceScheduler() + .getSchedulerAppInfo(containerId6.getApplicationAttemptId()); } // assert containerId6 is reserved. - Assert.assertEquals(containerId6, schedulerAttempt.getReservedContainers() - .get(0).getContainerId()); + Assert.assertEquals(containerId6, schedulerAppInfo.getReservedContainers() + .iterator().next().getContainerId()); // fail the AM by sending CONTAINER_FINISHED event without registering. nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); @@ -219,17 +218,17 @@ public void testAMRestartWithExistingContainers() throws Exception { // New SchedulerApplicationAttempt also has the containers info. rm1.waitForState(nm1, containerId2, RMContainerState.RUNNING); - // record the scheduler attempt for testing. - SchedulerApplicationAttempt schedulerNewAttempt = - ((CapacityScheduler) rm1.getResourceScheduler()) - .getCurrentAttemptForContainer(containerId2); + schedulerAppInfo = rm1.getResourceScheduler() + .getSchedulerAppInfo(containerId2.getApplicationAttemptId()); + Assert.assertNotNull(schedulerAppInfo); // finish this application MockRM.finishAMAndVerifyAppState(app1, rm1, nm1, am2); // the 2nd attempt released the 1st attempt's running container, when the // 2nd attempt finishes. - Assert.assertFalse(schedulerNewAttempt.getLiveContainers().contains( - containerId2)); + schedulerAppInfo = rm1.getResourceScheduler() + .getSchedulerAppInfo(containerId2.getApplicationAttemptId()); + Assert.assertNull(schedulerAppInfo); // all 4 normal containers finished. System.out.println("New attempt's just finished containers: " + newAttempt.getJustFinishedContainers());