goiri commented on a change in pull request #2461:
URL: https://github.com/apache/hadoop/pull/2461#discussion_r522372852



##########
File path: 
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
##########
@@ -1161,43 +1165,34 @@ protected NodeStatusUpdater 
createNodeStatusUpdater(Context context,
     Assert.assertTrue("last service is NOT the node status updater",
         lastService instanceof NodeStatusUpdater);
 
-    new Thread() {
-      public void run() {
-        try {
-          nm.start();
-        } catch (Throwable e) {
-          TestNodeStatusUpdater.this.nmStartError = e;
-          throw new YarnRuntimeException(e);
-        }
+    Thread starterThread = new Thread(() -> {
+      try {
+        nm.start();
+      } catch (Throwable e) {
+        TestNodeStatusUpdater.this.nmStartError = e;
+        throw new YarnRuntimeException(e);
       }
-    }.start();
+    });
+    starterThread.start();
 
-    System.out.println(" ----- thread already started.."
-        + nm.getServiceState());
+    LOG.info(" ----- thread already started..{}", nm.getServiceState());
 
-    int waitCount = 0;
-    while (nm.getServiceState() == STATE.INITED && waitCount++ != 50) {
-      LOG.info("Waiting for NM to start..");
-      if (nmStartError != null) {
-        LOG.error("Error during startup. ", nmStartError);
-        Assert.fail(nmStartError.getCause().getMessage());
-      }
-      Thread.sleep(2000);
-    }
-    if (nm.getServiceState() != STATE.STARTED) {
-      // NM could have failed.
-      Assert.fail("NodeManager failed to start");
+    starterThread.join(100000);
+
+    if (nmStartError != null) {
+      LOG.error("Error during startup. ", nmStartError);
+      Assert.fail(nmStartError.getCause().getMessage());
     }
 
-    waitCount = 0;
-    while (heartBeatID <= 3 && waitCount++ != 200) {
-      Thread.sleep(1000);
+    int waitCount = 0;
+    while (nm.getServiceState() == STATE.STARTED

Review comment:
       I would split it into two lines but I think the or condition is clear 
enough.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to