You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@twill.apache.org by ch...@apache.org on 2018/03/22 05:20:08 UTC

[04/15] twill git commit: (TWILL-251) Reduce log level of YarnNMClient

(TWILL-251) Reduce log level of YarnNMClient

- Also reduce the polling frequency

This closes #64 on Github.

Signed-off-by: Terence Yim <ch...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/twill/repo
Commit: http://git-wip-us.apache.org/repos/asf/twill/commit/55f6d6fc
Tree: http://git-wip-us.apache.org/repos/asf/twill/tree/55f6d6fc
Diff: http://git-wip-us.apache.org/repos/asf/twill/diff/55f6d6fc

Branch: refs/heads/site
Commit: 55f6d6fc9b088e1fa9a1462a92146d608bbebb22
Parents: b7785bd
Author: Terence Yim <ch...@apache.org>
Authored: Fri Dec 1 13:21:07 2017 -0600
Committer: Terence Yim <ch...@apache.org>
Committed: Mon Dec 4 10:21:05 2017 -0800

----------------------------------------------------------------------
 .../twill/internal/yarn/Hadoop20YarnNMClient.java     | 12 ++++++++----
 .../twill/internal/yarn/Hadoop21YarnNMClient.java     | 14 +++++++++-----
 2 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/twill/blob/55f6d6fc/twill-yarn/src/main/hadoop20/org/apache/twill/internal/yarn/Hadoop20YarnNMClient.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/main/hadoop20/org/apache/twill/internal/yarn/Hadoop20YarnNMClient.java b/twill-yarn/src/main/hadoop20/org/apache/twill/internal/yarn/Hadoop20YarnNMClient.java
index b43e4e1..e8628da 100644
--- a/twill-yarn/src/main/hadoop20/org/apache/twill/internal/yarn/Hadoop20YarnNMClient.java
+++ b/twill-yarn/src/main/hadoop20/org/apache/twill/internal/yarn/Hadoop20YarnNMClient.java
@@ -18,6 +18,7 @@
 package org.apache.twill.internal.yarn;
 
 import com.google.common.base.Throwables;
+import com.google.common.util.concurrent.Uninterruptibles;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.yarn.api.ContainerManager;
@@ -36,6 +37,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
 
 /**
  *
@@ -102,14 +104,16 @@ public final class Hadoop20YarnNMClient implements YarnNMClient {
       stopRequest.setContainerId(container.getId());
       try {
         manager.stopContainer(stopRequest);
-        boolean completed = false;
-        while (!completed) {
+        while (true) {
           GetContainerStatusRequest statusRequest = Records.newRecord(GetContainerStatusRequest.class);
           statusRequest.setContainerId(container.getId());
           GetContainerStatusResponse statusResponse = manager.getContainerStatus(statusRequest);
-          LOG.info("Container status: {} {}", statusResponse.getStatus(), statusResponse.getStatus().getDiagnostics());
+          LOG.trace("Container status: {} {}", statusResponse.getStatus(), statusResponse.getStatus().getDiagnostics());
 
-          completed = (statusResponse.getStatus().getState() == ContainerState.COMPLETE);
+          if (statusResponse.getStatus().getState() == ContainerState.COMPLETE) {
+            break;
+          }
+          Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
         }
         LOG.info("Container {} stopped.", container.getId());
       } catch (YarnRemoteException e) {

http://git-wip-us.apache.org/repos/asf/twill/blob/55f6d6fc/twill-yarn/src/main/hadoop21/org/apache/twill/internal/yarn/Hadoop21YarnNMClient.java
----------------------------------------------------------------------
diff --git a/twill-yarn/src/main/hadoop21/org/apache/twill/internal/yarn/Hadoop21YarnNMClient.java b/twill-yarn/src/main/hadoop21/org/apache/twill/internal/yarn/Hadoop21YarnNMClient.java
index 8c5f0fc..dcdeb70 100644
--- a/twill-yarn/src/main/hadoop21/org/apache/twill/internal/yarn/Hadoop21YarnNMClient.java
+++ b/twill-yarn/src/main/hadoop21/org/apache/twill/internal/yarn/Hadoop21YarnNMClient.java
@@ -19,6 +19,7 @@ package org.apache.twill.internal.yarn;
 
 import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.AbstractIdleService;
+import com.google.common.util.concurrent.Uninterruptibles;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
@@ -29,6 +30,8 @@ import org.apache.twill.common.Cancellable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.concurrent.TimeUnit;
+
 /**
  * Wrapper class for {@link NMClient} for Hadoop version 2.1 or greater.
  */
@@ -82,12 +85,13 @@ public final class Hadoop21YarnNMClient extends AbstractIdleService implements Y
 
       try {
         nmClient.stopContainer(container.getId(), container.getNodeId());
-        boolean completed = false;
-        while (!completed) {
+        while (true) {
           ContainerStatus status = nmClient.getContainerStatus(container.getId(), container.getNodeId());
-          LOG.info("Container status: {} {}", status, status.getDiagnostics());
-
-          completed = (status.getState() == ContainerState.COMPLETE);
+          LOG.trace("Container status: {} {}", status, status.getDiagnostics());
+          if (status.getState() == ContainerState.COMPLETE) {
+            break;
+          }
+          Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
         }
         LOG.info("Container {} stopped.", container.getId());
       } catch (Exception e) {