diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java index c325a65..89b69bc 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java @@ -74,31 +74,17 @@ public void setAMRMProtocol(ApplicationMasterProtocol amRMProtocol, this.amRMProtocol = amRMProtocol; } - public void waitForState(RMAppAttemptState finalState) throws Exception { + /** + * Wait until an attempt has reached a specified state. + * The timeout is 40 seconds. + * @param finalState the attempt state waited + * @throws InterruptedException if an unexpected error occurs + */ + private void waitForState(RMAppAttemptState finalState) + throws InterruptedException { RMApp app = context.getRMApps().get(attemptId.getApplicationId()); RMAppAttempt attempt = app.getRMAppAttempt(attemptId); - final int timeoutMsecs = 40000; - final int minWaitMsecs = 1000; - final int waitMsPerLoop = 500; - int loop = 0; - while (!finalState.equals(attempt.getAppAttemptState()) - && waitMsPerLoop * loop < timeoutMsecs) { - LOG.info("AppAttempt : " + attemptId + " State is : " + - attempt.getAppAttemptState() + " Waiting for state : " + - finalState); - Thread.yield(); - Thread.sleep(waitMsPerLoop); - loop++; - } - int waitedMsecs = waitMsPerLoop * loop; - if (minWaitMsecs > waitedMsecs) { - Thread.sleep(minWaitMsecs - waitedMsecs); - } - LOG.info("Attempt State is : " + attempt.getAppAttemptState()); - if (waitedMsecs >= timeoutMsecs) { - Assert.fail("Attempt state is not correct (timedout): expected: " - + finalState + " actual: " + attempt.getAppAttemptState()); - } + MockRM.waitForState(attempt, finalState); } public RegisterApplicationMasterResponse registerAppAttempt() diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java index 25c558f..8b57164 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java @@ -105,8 +105,12 @@ static final Logger LOG = Logger.getLogger(MockRM.class); static final String ENABLE_WEBAPP = "mockrm.webapp.enabled"; - - final private boolean useNullRMNodeLabelsManager; + private static final int SECOND = 1000; + private static final int TIMEOUT_MS_FOR_ATTEMPT = 40 * SECOND; + private static final int TIMEOUT_MS_FOR_CONTAINER_AND_NODE = 10 * SECOND; + private static final int WAIT_MS_PER_LOOP = 10; + + private final boolean useNullRMNodeLabelsManager; public MockRM() { this(new YarnConfiguration()); @@ -158,106 +162,102 @@ public void drainEvents() { } } + /** + * Wait until an application has reached a specified state. + * The timeout is 80 seconds. + * @param appId the id of an application + * @param finalState the application state waited + * @throws InterruptedException if an unexpected error occurs + */ public void waitForState(ApplicationId appId, RMAppState finalState) - throws Exception { + throws InterruptedException { RMApp app = getRMContext().getRMApps().get(appId); Assert.assertNotNull("app shouldn't be null", app); - final int timeoutMsecs = 80000; - final int waitMsPerLoop = 500; - int loop = 0; - while (!finalState.equals(app.getState()) && - ((waitMsPerLoop * loop) < timeoutMsecs)) { + final int timeoutMsecs = 80 * SECOND; + int timeWaiting = 0; + while (!finalState.equals(app.getState())) { + if (timeWaiting >= timeoutMsecs) { + break; + } + LOG.info("App : " + appId + " State is : " + app.getState() + - " Waiting for state : " + finalState); - Thread.yield(); - Thread.sleep(waitMsPerLoop); - loop++; + " Waiting for state : " + finalState); + Thread.sleep(WAIT_MS_PER_LOOP); + timeWaiting += WAIT_MS_PER_LOOP; } - int waitedMsecs = waitMsPerLoop * loop; + LOG.info("App State is : " + app.getState()); - if (waitedMsecs >= timeoutMsecs) { - Assert.fail("App state is not correct (timedout): expected: " + - finalState + " actual: " + app.getState() + - " for the application " + appId); - } + Assert.assertEquals("App State is not correct (timeout).", finalState, + app.getState()); } + /** + * Wait until an attempt has reached a specified state. + * The timeout is 40 seconds. + * @param attemptId the id of an attempt + * @param finalState the attempt state waited + * @throws InterruptedException if an unexpected error occurs + */ public void waitForState(ApplicationAttemptId attemptId, - RMAppAttemptState finalState) - throws Exception { - waitForState(attemptId, finalState, 40000); - } - + RMAppAttemptState finalState) throws InterruptedException { + waitForState(attemptId, finalState, TIMEOUT_MS_FOR_ATTEMPT); + } + + /** + * Wait until an attempt has reached a specified state. + * The timeout can be specified by the parameter. + * @param attemptId the id of an attempt + * @param finalState the attempt state waited + * @param timeoutMsecs the length of timeout in milliseconds + * @throws InterruptedException if an unexpected error occurs + */ public void waitForState(ApplicationAttemptId attemptId, - RMAppAttemptState finalState, int timeoutMsecs) throws Exception { + RMAppAttemptState finalState, int timeoutMsecs) + throws InterruptedException { RMApp app = getRMContext().getRMApps().get(attemptId.getApplicationId()); Assert.assertNotNull("app shouldn't be null", app); RMAppAttempt attempt = app.getRMAppAttempt(attemptId); - final int minWaitMsecs = 1000; - final int waitMsPerLoop = 10; - int loop = 0; - while (!finalState.equals(attempt.getAppAttemptState()) - && waitMsPerLoop * loop < timeoutMsecs) { - LOG.info("AppAttempt : " + attemptId + " State is : " + - attempt.getAppAttemptState() + " Waiting for state : " + finalState); - Thread.yield(); - Thread.sleep(waitMsPerLoop); - loop++; - } - int waitedMsecs = waitMsPerLoop * loop; - if (minWaitMsecs > waitedMsecs) { - Thread.sleep(minWaitMsecs - waitedMsecs); - } - LOG.info("Attempt State is : " + attempt.getAppAttemptState()); - if (waitedMsecs >= timeoutMsecs) { - Assert.fail("Attempt state is not correct (timedout): expected: " - + finalState + " actual: " + attempt.getAppAttemptState()+ - " for the application attempt " + attemptId); - } - } - - public void waitForContainerState(ContainerId containerId, - RMContainerState state) throws Exception { - // This method will assert if state is not expected after timeout. - Assert.assertTrue(waitForContainerState(containerId, state, 8 * 1000)); - } - - public boolean waitForContainerState(ContainerId containerId, - RMContainerState containerState, int timeoutMillisecs) throws Exception { - RMContainer container = getResourceScheduler().getRMContainer(containerId); - int timeoutSecs = 0; - while (((container == null) || !containerState.equals(container.getState())) - && timeoutSecs++ < timeoutMillisecs / 100) { - if(container == null){ - container = getResourceScheduler().getRMContainer(containerId); + MockRM.waitForState(attempt, finalState, timeoutMsecs); + } + + /** + * Wait until an attempt has reached a specified state. + * The timeout is 40 seconds. + * @param attempt an attempt + * @param finalState the attempt state waited + * @throws InterruptedException if an unexpected error occurs + */ + public static void waitForState(RMAppAttempt attempt, + RMAppAttemptState finalState) throws InterruptedException { + waitForState(attempt, finalState, TIMEOUT_MS_FOR_ATTEMPT); + } + + /** + * Wait until an attempt has reached a specified state. + * The timeout can be specified by the parameter. + * @param attempt an attempt + * @param finalState the attempt state waited + * @param timeoutMsecs the length of timeout in milliseconds + * @throws InterruptedException if an unexpected error occurs + */ + public static void waitForState(RMAppAttempt attempt, + RMAppAttemptState finalState, int timeoutMsecs) + throws InterruptedException { + int timeWaiting = 0; + while (!finalState.equals(attempt.getAppAttemptState())) { + if (timeWaiting >= timeoutMsecs) { + break; } - System.out.println("Container : " + containerId + - " Waiting for state : " + containerState); - - Thread.sleep(100); - if (timeoutMillisecs <= timeoutSecs * 100) { - return false; - } + LOG.info("AppAttempt : " + attempt.getAppAttemptId() + " State is : " + + attempt.getAppAttemptState() + " Waiting for state : " + finalState); + Thread.sleep(WAIT_MS_PER_LOOP); + timeWaiting += WAIT_MS_PER_LOOP; } - System.out.println("Container State is : " + container.getState()); - Assert.assertEquals("Container state is not correct (timedout)", - containerState, container.getState()); - return true; - } - - public void waitForContainerAllocated(MockNM nm, ContainerId containerId) - throws Exception { - int timeoutSecs = 0; - while (getResourceScheduler().getRMContainer(containerId) == null - && timeoutSecs++ < 40) { - System.out.println("Waiting for" + containerId + " to be allocated."); - nm.nodeHeartbeat(true); - Thread.sleep(200); - } - Assert.assertNotNull("Failed in waiting for " + containerId + " " + - "allocation.", getResourceScheduler().getRMContainer(containerId)); + LOG.info("Attempt State is : " + attempt.getAppAttemptState()); + Assert.assertEquals("Attempt state is not correct (timeout).", finalState, + attempt.getState()); } public void waitForContainerToComplete(RMAppAttempt attempt, @@ -271,7 +271,7 @@ public void waitForContainerToComplete(RMAppAttempt attempt, return; } } - Thread.sleep(200); + Thread.sleep(WAIT_MS_PER_LOOP); } } @@ -283,58 +283,101 @@ public MockAM waitForNewAMToLaunchAndRegister(ApplicationId appId, int attemptSi System.out.println("Application " + appId + " is waiting for AM to restart. Current has " + app.getAppAttempts().size() + " attempts."); - Thread.sleep(200); + Thread.sleep(WAIT_MS_PER_LOOP); } return launchAndRegisterAM(app, this, nm); } + /** + * Wait until a container has reached a specified state. + * The timeout is 10 seconds. + * @param nm A mock nodemanager + * @param containerId the id of a container + * @param containerState the container state waited + * @return if reach the state before timeout; false otherwise. + * @throws Exception if an unexpected error occurs + */ public boolean waitForState(MockNM nm, ContainerId containerId, RMContainerState containerState) throws Exception { - // default is wait for 30,000 ms - return waitForState(nm, containerId, containerState, 30 * 1000); - } - + return waitForState(nm, containerId, containerState, + TIMEOUT_MS_FOR_CONTAINER_AND_NODE); + } + + /** + * Wait until a container has reached a specified state. + * The timeout is specified by the parameter. + * @param nm A mock nodemanager + * @param containerId the id of a container + * @param containerState the container state waited + * @param timeoutMsecs the length of timeout in milliseconds + * @return if reach the state before timeout; false otherwise. + * @throws Exception if an unexpected error occurs + */ public boolean waitForState(MockNM nm, ContainerId containerId, - RMContainerState containerState, int timeoutMillisecs) throws Exception { + RMContainerState containerState, int timeoutMsecs) throws Exception { return waitForState(Arrays.asList(nm), containerId, containerState, - timeoutMillisecs); - } - + timeoutMsecs); + } + + /** + * Wait until a container has reached a specified state. + * The timeout is 10 seconds. + * @param nms array of mock nodemanagers + * @param containerId the id of a container + * @param containerState the container state waited + * @return if reach the state before timeout; false otherwise. + * @throws Exception if an unexpected error occurs + */ + public boolean waitForState(Collection nms, ContainerId containerId, + RMContainerState containerState) throws Exception { + return waitForState(nms, containerId, containerState, + TIMEOUT_MS_FOR_CONTAINER_AND_NODE); + } + + /** + * Wait until a container has reached a specified state. + * The timeout is specified by the parameter. + * @param nms array of mock nodemanagers + * @param containerId the id of a container + * @param containerState the container state waited + * @param timeoutMsecs the length of timeout in milliseconds + * @return if reach the state before timeout; false otherwise. + * @throws Exception if an unexpected error occurs + */ public boolean waitForState(Collection nms, ContainerId containerId, - RMContainerState containerState, int timeoutMillisecs) throws Exception { + RMContainerState containerState, int timeoutMsecs) throws Exception { RMContainer container = getResourceScheduler().getRMContainer(containerId); - int timeoutSecs = 0; - while(container == null && timeoutSecs++ < timeoutMillisecs / 100) { + int timeWaiting = 0; + while (container == null) { + if (timeWaiting >= timeoutMsecs) { + return false; + } + for (MockNM nm : nms) { nm.nodeHeartbeat(true); } container = getResourceScheduler().getRMContainer(containerId); System.out.println("Waiting for container " + containerId + " to be " + containerState + ", container is null right now."); - Thread.sleep(100); - - if (timeoutMillisecs <= timeoutSecs * 100) { + Thread.sleep(WAIT_MS_PER_LOOP); + timeWaiting += WAIT_MS_PER_LOOP; + } + + while (!containerState.equals(container.getState())) { + if (timeWaiting >= timeoutMsecs) { return false; } - } - Assert.assertNotNull("Container shouldn't be null", container); - while (!containerState.equals(container.getState()) - && timeoutSecs++ < timeoutMillisecs / 100) { + System.out.println("Container : " + containerId + " State is : " + container.getState() + " Waiting for state : " + containerState); for (MockNM nm : nms) { nm.nodeHeartbeat(true); } - Thread.sleep(100); - - if (timeoutMillisecs <= timeoutSecs * 100) { - return false; - } + Thread.sleep(WAIT_MS_PER_LOOP); + timeWaiting += WAIT_MS_PER_LOOP; } - + System.out.println("Container State is : " + container.getState()); - Assert.assertEquals("Container state is not correct (timedout)", - containerState, container.getState()); return true; } @@ -638,16 +681,29 @@ public void sendNodeLost(MockNM nm) throws Exception { node.handle(new RMNodeEvent(nm.getNodeId(), RMNodeEventType.EXPIRE)); } - public void NMwaitForState(NodeId nodeid, NodeState finalState) - throws Exception { - RMNode node = getRMContext().getRMNodes().get(nodeid); + /** + * Wait until a node has reached a specified state. + * The timeout is 10 seconds. + * @param nodeId the id of a node + * @param finalState the node state waited + * @throws InterruptedException if an unexpected error occurs + */ + public void waitForState(NodeId nodeId, NodeState finalState) + throws InterruptedException { + RMNode node = getRMContext().getRMNodes().get(nodeId); Assert.assertNotNull("node shouldn't be null", node); - int timeoutSecs = 0; - while (!finalState.equals(node.getState()) && timeoutSecs++ < 20) { + int timeWaiting = 0; + while (!finalState.equals(node.getState())) { + if (timeWaiting >= TIMEOUT_MS_FOR_CONTAINER_AND_NODE) { + break; + } + System.out.println("Node State is : " + node.getState() + " Waiting for state : " + finalState); - Thread.sleep(500); + Thread.sleep(WAIT_MS_PER_LOOP); + timeWaiting += WAIT_MS_PER_LOOP; } + System.out.println("Node State is : " + node.getState()); Assert.assertEquals("Node state is not correct (timedout)", finalState, node.getState()); @@ -671,7 +727,7 @@ public FailApplicationAttemptResponse failApplicationAttempt( public MockAM sendAMLaunched(ApplicationAttemptId appAttemptId) throws Exception { MockAM am = new MockAM(getRMContext(), masterService, appAttemptId); - am.waitForState(RMAppAttemptState.ALLOCATED); + waitForState(appAttemptId, RMAppAttemptState.ALLOCATED); //create and set AMRMToken Token amrmToken = this.rmContext.getAMRMTokenSecretManager().createAndGetAMRMToken( @@ -690,7 +746,7 @@ public MockAM sendAMLaunched(ApplicationAttemptId appAttemptId) public void sendAMLaunchFailed(ApplicationAttemptId appAttemptId) throws Exception { MockAM am = new MockAM(getRMContext(), masterService, appAttemptId); - am.waitForState(RMAppAttemptState.ALLOCATED); + waitForState(am.getApplicationAttemptId(), RMAppAttemptState.ALLOCATED); getRMContext().getDispatcher().getEventHandler() .handle(new RMAppAttemptEvent(appAttemptId, RMAppAttemptEventType.LAUNCH_FAILED, "Failed")); @@ -825,9 +881,9 @@ public static void finishAMAndVerifyAppState(RMApp rmApp, MockRM rm, MockNM nm, FinishApplicationMasterRequest.newInstance( FinalApplicationStatus.SUCCEEDED, "", ""); am.unregisterAppAttempt(req,true); - am.waitForState(RMAppAttemptState.FINISHING); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHING); nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java index 3fa377e..73d0c4f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java @@ -122,7 +122,7 @@ public void testAppCleanup() throws Exception { am.unregisterAppAttempt(); NodeHeartbeatResponse resp = nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); //currently only containers are cleaned via this //AM container is cleaned via container launcher diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java index 8fa88d5..8cdb191 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java @@ -190,7 +190,7 @@ public void testAMLaunchAndCleanup() throws Exception { //complete the AM container to finish the app normally nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); waitCount = 0; while (containerManager.cleanedup == false && waitCount++ < 20) { @@ -199,7 +199,7 @@ public void testAMLaunchAndCleanup() throws Exception { } Assert.assertTrue(containerManager.cleanedup); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm.stop(); } @@ -248,14 +248,13 @@ protected Dispatcher createDispatcher() { MockNM nm1 = rm.registerNode("127.0.0.1:1234", 5120); RMApp app = rm.submitApp(2000); - final ApplicationAttemptId appAttemptId = app.getCurrentAppAttempt() - .getAppAttemptId(); // kick the scheduling nm1.nodeHeartbeat(true); dispatcher.await(); - rm.waitForState(appAttemptId, RMAppAttemptState.LAUNCHED, 500); + MockRM.waitForState(app.getCurrentAppAttempt(), + RMAppAttemptState.LAUNCHED, 500); } @@ -310,7 +309,7 @@ public void testallocateBeforeAMRegistration() throws Exception { am.unregisterAppAttempt(); nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); try { amrs = am.allocate(new ArrayList(), diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterService.java index cef1b5f..db85057 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterService.java @@ -270,7 +270,7 @@ public void testFinishApplicationMasterBeforeRegistering() throws Exception { am1.registerAppAttempt(); am1.unregisterAppAttempt(req, false); - am1.waitForState(RMAppAttemptState.FINISHING); + rm.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FINISHING); } finally { if (rm != null) { rm.stop(); @@ -310,6 +310,8 @@ public void testResourceTypes() throws Exception { rm.start(); MockNM nm1 = rm.registerNode("127.0.0.1:1234", 6 * GB); RMApp app1 = rm.submitApp(2048); + //TODO explore a better way than sleeping for a while (YARN-4929) + Thread.sleep(1000); nm1.nodeHeartbeat(true); RMAppAttempt attempt1 = app1.getCurrentAppAttempt(); MockAM am1 = rm.sendAMLaunched(attempt1.getAppAttemptId()); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java index bb31f6e..7a19267 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java @@ -188,7 +188,7 @@ protected ClientRMService createClientRMService() { MockNM lostNode = rm.registerNode("host2:1235", 1024); rm.sendNodeStarted(lostNode); lostNode.nodeHeartbeat(true); - rm.NMwaitForState(lostNode.getNodeId(), NodeState.RUNNING); + rm.waitForState(lostNode.getNodeId(), NodeState.RUNNING); rm.sendNodeLost(lostNode); // Create a client. @@ -214,7 +214,7 @@ protected ClientRMService createClientRMService() { // Now make the node unhealthy. node.nodeHeartbeat(false); - rm.NMwaitForState(node.getNodeId(), NodeState.UNHEALTHY); + rm.waitForState(node.getNodeId(), NodeState.UNHEALTHY); // Call again nodeReports = client.getClusterNodes(request).getNodeReports(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java index fcb48a0..e81ebf2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java @@ -308,7 +308,7 @@ private void amRestartTests(boolean keepRunningContainers) app.getCurrentAppAttempt().getMasterContainer().getId(); nm.nodeHeartbeat(am0.getApplicationAttemptId(), amContainerId.getContainerId(), ContainerState.COMPLETE); - am0.waitForState(RMAppAttemptState.FAILED); + rm.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.FAILED); long memorySeconds = 0; long vcoreSeconds = 0; @@ -347,6 +347,8 @@ private void amRestartTests(boolean keepRunningContainers) .equals(am0.getApplicationAttemptId())); // launch the new AM + //TODO explore a better way than sleeping for a while (YARN-4929) + Thread.sleep(1000); nm.nodeHeartbeat(true); MockAM am1 = rm.sendAMLaunched(attempt2.getAppAttemptId()); am1.registerAppAttempt(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRM.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRM.java index b04b173..8454947 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRM.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRM.java @@ -134,7 +134,7 @@ public void testAppWithNoContainers() throws Exception { am.registerAppAttempt(); am.unregisterAppAttempt(); nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm.stop(); } @@ -191,7 +191,7 @@ public void testAppOnMultiNode() throws Exception { am.unregisterAppAttempt(); nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm.stop(); } @@ -398,7 +398,7 @@ public void testNMToken() throws Exception { } nm1.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); Assert.assertFalse(nmTokenSecretManager .isApplicationAttemptRegistered(attempt.getAppAttemptId())); } finally { @@ -498,7 +498,7 @@ public void testInvalidateAMHostPortWhenAMFailedOrKilled() throws Exception { RMApp app2 = rm1.submitApp(200); MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1); nm1.nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am2.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app2.getApplicationId(), RMAppState.FAILED); // a killed app @@ -545,7 +545,7 @@ public void testInvalidatedAMHostPortOnAMRestart() throws Exception { MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1); nm1 .nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am2.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app2.getApplicationId(), RMAppState.ACCEPTED); // before new attempt is launched, the app report returns the invalid AM @@ -610,7 +610,7 @@ protected Dispatcher createDispatcher() { // a failed app RMApp application = rm.submitApp(200); MockAM am = MockRM.launchAM(application, rm, nm1); - am.waitForState(RMAppAttemptState.LAUNCHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.LAUNCHED); nm1.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.RUNNING); rm.waitForState(application.getApplicationId(), RMAppState.ACCEPTED); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index 3b9952b..70678cf 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -462,7 +462,7 @@ public void testRMRestartAppRunningAMFailed() throws Exception { // fail the AM by sending CONTAINER_FINISHED event without registering. nm1.nodeHeartbeat(am0.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am0.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.FAILED); ApplicationStateData appState = rmAppState.get(app0.getApplicationId()); // assert the AM failed state is saved. @@ -516,7 +516,7 @@ public void testRMRestartWaitForPreviousAMToFinish() throws Exception { MockAM am1 = launchAM(app1, rm1, nm1); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); // Fail first AM. - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); // launch another AM. MockAM am2 = launchAM(app1, rm1, nm1); @@ -687,7 +687,7 @@ public void updateApplicationStateInternal(ApplicationId appId, FinishApplicationMasterRequest.newInstance( FinalApplicationStatus.SUCCEEDED, "", ""); am0.unregisterAppAttempt(req, true); - am0.waitForState(RMAppAttemptState.FINISHING); + rm1.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.FINISHING); // app final state is not saved. This guarantees that RMApp cannot be // recovered via its own saved state, but only via the event notification // from the RMAppAttempt on recovery. @@ -728,7 +728,7 @@ public void testRMRestartFailedApp() throws Exception { // fail the AM by sending CONTAINER_FINISHED event without registering. nm1.nodeHeartbeat(am0.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am0.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app0.getApplicationId(), RMAppState.FAILED); // assert the app/attempt failed state is saved. @@ -923,7 +923,7 @@ protected SystemMetricsPublisher createSystemMetricsPublisher() { MockAM am1 = launchAM(app1, rm1, nm1); // fail the AM by sending CONTAINER_FINISHED event without registering. nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app1.getApplicationId(), RMAppState.FAILED); // a killed app. @@ -1042,9 +1042,9 @@ private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm, Map rmAppState = rmState.getApplicationState(); am.unregisterAppAttempt(req,true); - am.waitForState(RMAppAttemptState.FINISHING); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHING); nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED); // check that app/attempt is saved with the final state ApplicationStateData appState = rmAppState.get(rmApp.getApplicationId()); @@ -2337,7 +2337,7 @@ public void testRMRestartAfterPreemption() throws Exception { MockAM am0 = MockRM.launchAM(app0, rm1, nm1); nm1.nodeHeartbeat(am0.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am0.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.FAILED); for (int i = 0; i < 4; i++) { am0 = MockRM.launchAM(app0, rm1, nm1); am0.registerAppAttempt(); @@ -2348,7 +2348,7 @@ public void testRMRestartAfterPreemption() throws Exception { // kill app0-attempt cs.markContainerForKillable(schedulerAppAttempt.getRMContainer( app0.getCurrentAppAttempt().getMasterContainer().getId())); - am0.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am0.getApplicationAttemptId(), RMAppAttemptState.FAILED); } am0 = MockRM.launchAM(app0, rm1, nm1); am0.registerAppAttempt(); @@ -2427,7 +2427,7 @@ private MockAM launchAndFailAM(RMApp app, MockRM rm, MockNM nm) throws Exception { MockAM am = launchAM(app, rm, nm); nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FAILED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FAILED); return am; } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java index 16cb866..39cec99 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestSignalContainer.java @@ -106,7 +106,7 @@ public void testSignalRequestDeliveryToNM() throws Exception { am.unregisterAppAttempt(); nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm.stop(); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java index f827bf4..e8418bd 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java @@ -446,6 +446,8 @@ private void testRMWritingMassiveHistory(MockRM rm) throws Exception { MockNM nm = rm.registerNode("127.0.0.1:1234", 1024 * 10100); RMApp app = rm.submitApp(1024); + //TODO explore a better way than sleeping for a while (YARN-4929) + Thread.sleep(1000); nm.nodeHeartbeat(true); RMAppAttempt attempt = app.getCurrentAppAttempt(); MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId()); @@ -470,9 +472,9 @@ private void testRMWritingMassiveHistory(MockRM rm) throws Exception { Assert.assertEquals(request, allocatedSize); am.unregisterAppAttempt(); - am.waitForState(RMAppAttemptState.FINISHING); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHING); nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); NodeHeartbeatResponse resp = nm.nodeHeartbeat(true); List cleaned = resp.getContainersToCleanup(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRMRPCNodeUpdates.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRMRPCNodeUpdates.java index f4cb3b3..801587c 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRMRPCNodeUpdates.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRMRPCNodeUpdates.java @@ -96,7 +96,7 @@ private void syncNodeHeartbeat(MockNM nm, boolean health) throws Exception { private void syncNodeLost(MockNM nm) throws Exception { rm.sendNodeStarted(nm); - rm.NMwaitForState(nm.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm.getNodeId(), NodeState.RUNNING); rm.sendNodeLost(nm); dispatcher.await(); } 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 6cfd868..73c11b2 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 @@ -116,7 +116,6 @@ public void testAMRestartWithExistingContainers() throws Exception { nm1.nodeHeartbeat(true); ContainerId containerId5 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 5); - rm1.waitForContainerAllocated(nm1, containerId5); rm1.waitForState(nm1, containerId5, RMContainerState.ALLOCATED); // 6th container is in Reserved state. @@ -139,7 +138,7 @@ public void testAMRestartWithExistingContainers() throws Exception { // fail the AM by sending CONTAINER_FINISHED event without registering. nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); // wait for some time. previous AM's running containers should still remain // in scheduler even though am failed @@ -324,7 +323,7 @@ public void testNMTokensRebindOnAMRestart() throws Exception { // fail am1 nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); // restart the am @@ -363,7 +362,7 @@ public void testNMTokensRebindOnAMRestart() throws Exception { // fail am2. nm1.nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am2.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); // restart am @@ -485,7 +484,7 @@ protected Dispatcher createDispatcher() { BuilderUtils.newContainerStatus(amContainer, ContainerState.COMPLETE, "", exitStatus, Resources.createResource(200)); currentNode.containerStatus(containerStatus); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); // restart the am @@ -567,7 +566,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { // Preempt the first attempt; scheduler.markContainerForKillable(scheduler.getRMContainer(amContainer)); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertTrue(! attempt1.shouldCountTowardsMaxAttemptRetry()); rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); ApplicationStateData appState = @@ -583,7 +582,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { ContainerId.newContainerId(am2.getApplicationAttemptId(), 1); scheduler.markContainerForKillable(scheduler.getRMContainer(amContainer2)); - am2.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertTrue(! attempt2.shouldCountTowardsMaxAttemptRetry()); rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); MockAM am3 = @@ -603,7 +602,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { Collections.singletonList(containerStatus)); nm1.nodeHeartbeat(conts, true); - am3.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am3.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertTrue(! attempt3.shouldCountTowardsMaxAttemptRetry()); Assert.assertEquals(ContainerExitStatus.DISKS_FAILED, appState.getAttempt(am3.getApplicationAttemptId()) @@ -622,7 +621,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { // nm1 heartbeats to report unhealthy // This will mimic ContainerExitStatus.ABORT nm1.nodeHeartbeat(false); - am4.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am4.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertTrue(! attempt4.shouldCountTowardsMaxAttemptRetry()); Assert.assertEquals(ContainerExitStatus.ABORTED, appState.getAttempt(am4.getApplicationAttemptId()) @@ -636,7 +635,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { // fail the AM normally nm2 .nodeHeartbeat(am5.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am5.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am5.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertTrue(attempt5.shouldCountTowardsMaxAttemptRetry()); // AM should not be restarted. @@ -678,7 +677,7 @@ public void testPreemptedAMRestartOnRMRestart() throws Exception { // Forcibly preempt the am container; scheduler.markContainerForKillable(scheduler.getRMContainer(amContainer)); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertTrue(! attempt1.shouldCountTowardsMaxAttemptRetry()); rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); @@ -805,30 +804,32 @@ public void testRMAppAttemptFailuresValidityInterval() throws Exception { // Fail current attempt normally nm1.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FAILED); // launch the second attempt rm1.waitForState(app.getApplicationId(), RMAppState.ACCEPTED); Assert.assertEquals(2, app.getAppAttempts().size()); Assert.assertTrue(((RMAppAttemptImpl) app.getCurrentAppAttempt()) .mayBeLastAttempt()); MockAM am_2 = MockRM.launchAndRegisterAM(app, rm1, nm1); - am_2.waitForState(RMAppAttemptState.RUNNING); + rm1.waitForState(am_2.getApplicationAttemptId(), RMAppAttemptState.RUNNING); nm1.nodeHeartbeat(am_2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am_2.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am_2.getApplicationAttemptId(), RMAppAttemptState.FAILED); // current app should be failed. rm1.waitForState(app.getApplicationId(), RMAppState.FAILED); ControlledClock clock = new ControlledClock(); // set window size to 10s - RMAppImpl app1 = (RMAppImpl)rm1.submitApp(200, 10000);; + RMAppImpl app1 = (RMAppImpl)rm1.submitApp(200, 10000); app1.setSystemClock(clock); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); // Fail attempt1 normally nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); + //TODO explore a better way than sleeping for a while (YARN-4929) + Thread.sleep(15 * 1000); // launch the second attempt rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); @@ -837,14 +838,14 @@ public void testRMAppAttemptFailuresValidityInterval() throws Exception { RMAppAttempt attempt2 = app1.getCurrentAppAttempt(); Assert.assertTrue(((RMAppAttemptImpl) attempt2).mayBeLastAttempt()); MockAM am2 = MockRM.launchAndRegisterAM(app1, rm1, nm1); - am2.waitForState(RMAppAttemptState.RUNNING); + rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.RUNNING); // wait for 10 seconds clock.setTime(System.currentTimeMillis() + 10*1000); // Fail attempt2 normally nm1.nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am2.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); // can launch the third attempt successfully rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); @@ -852,7 +853,7 @@ public void testRMAppAttemptFailuresValidityInterval() throws Exception { RMAppAttempt attempt3 = app1.getCurrentAppAttempt(); clock.reset(); MockAM am3 = MockRM.launchAndRegisterAM(app1, rm1, nm1); - am3.waitForState(RMAppAttemptState.RUNNING); + rm1.waitForState(am3.getApplicationAttemptId(), RMAppAttemptState.RUNNING); // Restart rm. @SuppressWarnings("resource") @@ -873,6 +874,8 @@ public void testRMAppAttemptFailuresValidityInterval() throws Exception { nm1.registerNode(Collections.singletonList(status), null); rm2.waitForState(attempt3.getAppAttemptId(), RMAppAttemptState.FAILED); + //TODO explore a better way than sleeping for a while (YARN-4929) + Thread.sleep(15 * 1000); Assert.assertEquals(2, app1State.getAttemptCount()); rm2.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); @@ -886,7 +889,7 @@ public void testRMAppAttemptFailuresValidityInterval() throws Exception { // Fail attempt4 normally nm1 .nodeHeartbeat(am4.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am4.waitForState(RMAppAttemptState.FAILED); + rm2.waitForState(am4.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertEquals(2, app1State.getAttemptCount()); // can launch the 5th attempt successfully @@ -895,12 +898,12 @@ public void testRMAppAttemptFailuresValidityInterval() throws Exception { MockAM am5 = rm2.waitForNewAMToLaunchAndRegister(app1.getApplicationId(), 5, nm1); clock.reset(); - am5.waitForState(RMAppAttemptState.RUNNING); + rm2.waitForState(am5.getApplicationAttemptId(), RMAppAttemptState.RUNNING); // Fail attempt5 normally nm1 .nodeHeartbeat(am5.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am5.waitForState(RMAppAttemptState.FAILED); + rm2.waitForState(am5.getApplicationAttemptId(), RMAppAttemptState.FAILED); Assert.assertEquals(2, app1State.getAttemptCount()); rm2.waitForState(app1.getApplicationId(), RMAppState.FAILED); @@ -973,7 +976,7 @@ public void testAMRestartNotLostContainerCompleteMsg() throws Exception { // fail the AM by sending CONTAINER_FINISHED event without registering. nm1.nodeHeartbeat( am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am1.waitForState(RMAppAttemptState.FAILED); + rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); // wait for app to start a new attempt. rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestNodesListManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestNodesListManager.java index 507165d..8812ffe 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestNodesListManager.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/TestNodesListManager.java @@ -85,7 +85,7 @@ protected Dispatcher createDispatcher() { am.registerAppAttempt(); am.unregisterAppAttempt(); nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FINISHED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED); // Create submitted App RMApp subrmApp = rm.submitApp(200); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java index 4042a29..12f3ee4 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java @@ -475,7 +475,6 @@ public void testResourceRequestRestoreWhenRMContainerIsAtAllocated() nm2.nodeHeartbeat(true); ContainerId containerId3 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); - rm1.waitForContainerAllocated(nm2, containerId3); rm1.waitForState(nm2, containerId3, RMContainerState.ALLOCATED); // NodeManager restart @@ -563,7 +562,6 @@ public void testResourceRequestRecoveryToTheRightAppAttempt() node.nodeHeartbeat(true); ContainerId allocatedContainerID = ContainerId.newContainerId(applicationAttemptOneID, 3); - rm.waitForContainerAllocated(node, allocatedContainerID); rm.waitForState(node, allocatedContainerID, RMContainerState.ALLOCATED); RMContainer allocatedContainer = rm.getResourceScheduler().getRMContainer(allocatedContainerID); @@ -576,8 +574,7 @@ public void testResourceRequestRecoveryToTheRightAppAttempt() // AM crashes, and a new app-attempt gets created node.nodeHeartbeat(applicationAttemptOneID, 1, ContainerState.COMPLETE); - rm.waitForContainerState(am1ContainerID, RMContainerState.COMPLETED, - 30 * 1000); + rm.waitForState(node, am1ContainerID, RMContainerState.COMPLETED, 30 * 1000); RMAppAttempt rmAppAttempt2 = MockRM.waitForAttemptScheduled(rmApp, rm); ApplicationAttemptId applicationAttemptTwoID = rmAppAttempt2.getAppAttemptId(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java index 16ba607..4daff24 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java @@ -1083,7 +1083,7 @@ public ApplicationMasterProtocol run() { ContainerId containerId2 = ContainerId.newContainerId(applicationAttemptId, 2); Assert.assertTrue(rm.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire the container allocateRequest = AllocateRequest.newInstance(1, 0.0f, null, null, null); @@ -2569,7 +2569,7 @@ private void waitContainerAllocated(MockAM am, int mem, int nContainer, ContainerId containerId = ContainerId.newContainerId(am.getApplicationAttemptId(), cId); Assert.assertTrue(rm.waitForState(nm, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); } } @@ -2806,10 +2806,10 @@ protected RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); Assert.assertTrue(rm.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkPendingResource(rm, "a1", 0 * GB, null); checkPendingResource(rm, "a", 0 * GB, null); @@ -3151,7 +3151,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId3 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); Assert.assertTrue(rm.waitForState(nm1, containerId3, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them am1.allocate(null, null); sentRMContainerLaunched(rm, diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodeLabelUpdate.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodeLabelUpdate.java index cff79cd..ca78e25 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodeLabelUpdate.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNodeLabelUpdate.java @@ -181,7 +181,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am1.allocate("*", GB, 1, new ArrayList(), "x"); containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); - rm.waitForState(nm1, containerId, RMContainerState.ALLOCATED, 10 * 1000); + rm.waitForState(nm1, containerId, RMContainerState.ALLOCATED); appResourceUsageReport = rm.getResourceScheduler().getAppResourceUsageReport( am1.getApplicationAttemptId()); @@ -242,7 +242,7 @@ public RMNodeLabelsManager createNodeLabelManager() { containerId1 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 1); containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // check used resource: // queue-a used x=1G, ""=1G @@ -415,12 +415,12 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); am1.allocate("*", GB, 1, new ArrayList()); containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); Assert.assertTrue(rm.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // app2 RMApp app2 = rm.submitApp(GB, "app", "u2", null, "a"); @@ -431,7 +431,7 @@ public RMNodeLabelsManager createNodeLabelManager() { containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 3); Assert.assertTrue(rm.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // check used resource: // queue-a used x=1G, ""=1G @@ -513,7 +513,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId.newContainerId(am1.getApplicationAttemptId(), 1); containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // check used resource: // queue-a used x=2G diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java index f04748d..5edc36a 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerResizing.java @@ -254,7 +254,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am1.allocate(null, null); sentRMContainerLaunched(rm1, containerId2); @@ -359,7 +359,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am1.allocate(null, null); sentRMContainerLaunched(rm1, containerId2); @@ -436,7 +436,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am1.allocate(null, null); sentRMContainerLaunched(rm1, containerId2); @@ -547,7 +547,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am1.allocate(null, null); sentRMContainerLaunched(rm1, containerId2); @@ -659,11 +659,12 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm1, containerId2, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am1.allocate(null, null); sentRMContainerLaunched(rm1, containerId2); - rm1.waitForContainerState(containerId2, RMContainerState.RUNNING); + rm1.waitForState(Arrays.asList(nm1, nm2), containerId2, + RMContainerState.RUNNING); // am1 asks to change its AM container from 2GB to 8GB am1.sendContainerResizingRequest(Arrays.asList( @@ -757,8 +758,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue( - rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED, - 10 * 1000)); + rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am1.allocate(null, null); sentRMContainerLaunched(rm1, containerId2); @@ -834,7 +834,7 @@ private void allocateAndLaunchContainers(MockAM am, MockNM nm, MockRM rm, ContainerId lastContainerId = ContainerId.newContainerId( am.getApplicationAttemptId(), startContainerId + nContainer - 1); Assert.assertTrue(rm.waitForState(nm, lastContainerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Acquire them, and NM report RUNNING am.allocate(null, null); @@ -842,7 +842,7 @@ private void allocateAndLaunchContainers(MockAM am, MockNM nm, MockRM rm, + nContainer; cId++) { sentRMContainerLaunched(rm, ContainerId.newContainerId(am.getApplicationAttemptId(), cId)); - rm.waitForContainerState( + rm.waitForState(nm, ContainerId.newContainerId(am.getApplicationAttemptId(), cId), RMContainerState.RUNNING); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestNodeLabelContainerAllocation.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestNodeLabelContainerAllocation.java index dc74593..9b6d0ab 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestNodeLabelContainerAllocation.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestNodeLabelContainerAllocation.java @@ -179,13 +179,13 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); am1.allocate("*", 1024, 1, new ArrayList(), ""); Assert.assertTrue(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Cannot allocate 2nd label=empty container containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); am1.allocate("*", 1024, 1, new ArrayList(), ""); Assert.assertFalse(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // A has default user limit = 100, so it can use all resource in label = x // We can allocate floor(8000 / 1024) = 7 containers @@ -194,7 +194,7 @@ public RMNodeLabelsManager createNodeLabelManager() { ContainerId.newContainerId(am1.getApplicationAttemptId(), id); am1.allocate("*", 1024, 1, new ArrayList(), "x"); Assert.assertTrue(rm1.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); } rm1.close(); } @@ -269,7 +269,7 @@ public RMNodeLabelsManager createNodeLabelManager() { containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2L); Assert.assertTrue(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1, "h2"); @@ -284,9 +284,9 @@ public RMNodeLabelsManager createNodeLabelManager() { am2.allocate("*", 1024, 1, new ArrayList()); containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm4, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertFalse(rm1.waitForState(nm5, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // launch an app to queue b2 RMApp app3 = rm1.submitApp(1024, "app", "user", null, "b2"); @@ -297,9 +297,9 @@ public RMNodeLabelsManager createNodeLabelManager() { am3.allocate("*", 1024, 1, new ArrayList(), "y"); containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1, "h3"); @@ -308,7 +308,7 @@ public RMNodeLabelsManager createNodeLabelManager() { am3.allocate("*", 1024, 1, new ArrayList(), "z"); containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 3L); Assert.assertTrue(rm1.waitForState(nm4, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1, "h4"); @@ -348,9 +348,9 @@ public RMNodeLabelsManager createNodeLabelManager() { containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1, "h1"); @@ -363,9 +363,9 @@ public RMNodeLabelsManager createNodeLabelManager() { am2.allocate("*", 1024, 1, new ArrayList(), "y"); containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am2.getApplicationAttemptId(), containerId, rm1, "h2"); @@ -378,9 +378,9 @@ public RMNodeLabelsManager createNodeLabelManager() { am3.allocate("*", 1024, 1, new ArrayList()); containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1, "h3"); @@ -424,9 +424,9 @@ public RMNodeLabelsManager createNodeLabelManager() { containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am1.getApplicationAttemptId(), containerId, rm1, "h1"); @@ -439,9 +439,9 @@ public RMNodeLabelsManager createNodeLabelManager() { am2.allocate("*", 1024, 1, new ArrayList()); containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am2.getApplicationAttemptId(), containerId, rm1, "h2"); @@ -454,9 +454,9 @@ public RMNodeLabelsManager createNodeLabelManager() { am3.allocate("*", 1024, 1, new ArrayList()); containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); Assert.assertTrue(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkTaskContainersHost(am3.getApplicationAttemptId(), containerId, rm1, "h3"); @@ -779,7 +779,7 @@ public RMNodeLabelsManager createNodeLabelManager() { am1.allocate("*", 1 * GB, 1, 1, new ArrayList(), ""); am1.allocate("*", 1 * GB, 1, 2, new ArrayList(), "y"); Assert.assertTrue(rm1.waitForState(nm1, nextContainerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); // Check pending resource for am2, priority=1 doesn't get allocated before // priority=2 allocated @@ -833,7 +833,7 @@ public RMNodeLabelsManager createNodeLabelManager() { nextContainerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), i); Assert.assertTrue(rm1.waitForState(Arrays.asList(nm1, nm2), - nextContainerId, RMContainerState.ALLOCATED, 10 * 1000)); + nextContainerId, RMContainerState.ALLOCATED)); } // no more container allocated on nm1 checkLaunchedContainerNumOnNode(rm1, nm1.getNodeId(), 0); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestWorkPreservingRMRestartForNodeLabel.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestWorkPreservingRMRestartForNodeLabel.java index eeec940..cb62ba0 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestWorkPreservingRMRestartForNodeLabel.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestWorkPreservingRMRestartForNodeLabel.java @@ -166,7 +166,7 @@ public RMNodeLabelsManager createNodeLabelManager() { containerId = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm1, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkRMContainerLabelExpression(ContainerId.newContainerId( am1.getApplicationAttemptId(), 1), rm1, "x"); checkRMContainerLabelExpression(ContainerId.newContainerId( @@ -181,7 +181,7 @@ public RMNodeLabelsManager createNodeLabelManager() { am2.allocate("*", 1024, 1, new ArrayList()); containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm2, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkRMContainerLabelExpression(ContainerId.newContainerId( am2.getApplicationAttemptId(), 1), rm1, "y"); checkRMContainerLabelExpression(ContainerId.newContainerId( @@ -196,7 +196,7 @@ public RMNodeLabelsManager createNodeLabelManager() { am3.allocate("*", 1024, 1, new ArrayList()); containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertTrue(rm1.waitForState(nm3, containerId, - RMContainerState.ALLOCATED, 10 * 1000)); + RMContainerState.ALLOCATED)); checkRMContainerLabelExpression(ContainerId.newContainerId( am3.getApplicationAttemptId(), 1), rm1, ""); checkRMContainerLabelExpression(ContainerId.newContainerId( diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java index 72cccf6..9f1d160 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesApps.java @@ -1460,7 +1460,7 @@ public void testMultipleAppAttempts() throws JSONException, Exception { while (true) { // fail the AM by sending CONTAINER_FINISHED event without registering. amNodeManager.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE); - am.waitForState(RMAppAttemptState.FAILED); + rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FAILED); if (numAttempt == maxAppAttempts) { rm.waitForState(app1.getApplicationId(), RMAppState.FAILED); break; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java index 3fd1fd5..0889033 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java @@ -133,13 +133,13 @@ public void testNodesDefaultWithUnHealthyNode() throws JSONException, MockNM nm1 = rm.registerNode("h1:1234", 5120); MockNM nm2 = rm.registerNode("h2:1235", 5121); rm.sendNodeStarted(nm1); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.NEW); MockNM nm3 = rm.registerNode("h3:1236", 5122); - rm.NMwaitForState(nm3.getNodeId(), NodeState.NEW); + rm.waitForState(nm3.getNodeId(), NodeState.NEW); rm.sendNodeStarted(nm3); - rm.NMwaitForState(nm3.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm3.getNodeId(), NodeState.RUNNING); RMNodeImpl node = (RMNodeImpl) rm.getRMContext().getRMNodes() .get(nm3.getNodeId()); NodeHealthStatus nodeHealth = NodeHealthStatus.newInstance(false, @@ -147,7 +147,7 @@ public void testNodesDefaultWithUnHealthyNode() throws JSONException, NodeStatus nodeStatus = NodeStatus.newInstance(nm3.getNodeId(), 1, new ArrayList(), null, nodeHealth, null, null, null); node.handle(new RMNodeStatusEvent(nm3.getNodeId(), nodeStatus, null)); - rm.NMwaitForState(nm3.getNodeId(), NodeState.UNHEALTHY); + rm.waitForState(nm3.getNodeId(), NodeState.UNHEALTHY); ClientResponse response = r.path("ws").path("v1").path("cluster").path("nodes") @@ -169,8 +169,8 @@ public void testNodesQueryNew() throws JSONException, Exception { MockNM nm1 = rm.registerNode("h1:1234", 5120); MockNM nm2 = rm.registerNode("h2:1235", 5121); rm.sendNodeStarted(nm1); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.NEW); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("nodes").queryParam("states", NodeState.NEW.toString()) @@ -250,8 +250,8 @@ public void testNodesQueryStateLost() throws JSONException, Exception { MockNM nm2 = rm.registerNode("h2:1234", 5120); rm.sendNodeStarted(nm1); rm.sendNodeStarted(nm2); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.RUNNING); rm.sendNodeLost(nm1); rm.sendNodeLost(nm2); @@ -284,8 +284,8 @@ public void testSingleNodeQueryStateLost() throws JSONException, Exception { MockNM nm2 = rm.registerNode("h2:1234", 5120); rm.sendNodeStarted(nm1); rm.sendNodeStarted(nm2); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.RUNNING); rm.sendNodeLost(nm1); rm.sendNodeLost(nm2); @@ -314,8 +314,8 @@ public void testNodesQueryRunning() throws JSONException, Exception { MockNM nm1 = rm.registerNode("h1:1234", 5120); MockNM nm2 = rm.registerNode("h2:1235", 5121); rm.sendNodeStarted(nm1); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.NEW); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("nodes").queryParam("states", "running") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); @@ -334,8 +334,8 @@ public void testNodesQueryHealthyFalse() throws JSONException, Exception { MockNM nm1 = rm.registerNode("h1:1234", 5120); MockNM nm2 = rm.registerNode("h2:1235", 5121); rm.sendNodeStarted(nm1); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.NEW); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("nodes").queryParam("states", "UNHEALTHY") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); @@ -352,8 +352,8 @@ public void testNodesHelper(String path, String media) throws JSONException, MockNM nm2 = rm.registerNode("h2:1235", 5121); rm.sendNodeStarted(nm1); rm.sendNodeStarted(nm2); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.RUNNING); ClientResponse response = r.path("ws").path("v1").path("cluster") .path(path).accept(media).get(ClientResponse.class); @@ -623,8 +623,8 @@ public void testQueryAll() throws Exception { MockNM nm3 = rm.registerNode("h3:1236", 5122); rm.sendNodeStarted(nm1); rm.sendNodeStarted(nm3); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); - rm.NMwaitForState(nm2.getNodeId(), NodeState.NEW); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm2.getNodeId(), NodeState.NEW); rm.sendNodeLost(nm3); ClientResponse response = r.path("ws").path("v1").path("cluster") @@ -645,7 +645,7 @@ public void testNodesResourceUtilization() throws JSONException, Exception { WebResource r = resource(); MockNM nm1 = rm.registerNode("h1:1234", 5120); rm.sendNodeStarted(nm1); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); RMNodeImpl node = (RMNodeImpl) rm.getRMContext().getRMNodes() .get(nm1.getNodeId()); @@ -659,7 +659,7 @@ public void testNodesResourceUtilization() throws JSONException, Exception { new ArrayList(), null, nodeHealth, containerResource, nodeResource, null); node.handle(new RMNodeStatusEvent(nm1.getNodeId(), nodeStatus, null)); - rm.NMwaitForState(nm1.getNodeId(), NodeState.RUNNING); + rm.waitForState(nm1.getNodeId(), NodeState.RUNNING); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("nodes").accept(MediaType.APPLICATION_JSON)