hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From templ...@apache.org
Subject hadoop git commit: YARN-5725. Test uncaught exception in TestContainersMonitorResourceChange.testContainersResourceChange when setting IP and host (Contributed by Miklos Szegedi via Daniel Templeton)
Date Mon, 28 Nov 2016 23:20:07 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk a2b1ff025 -> 62b42ef5d


YARN-5725. Test uncaught exception in TestContainersMonitorResourceChange.testContainersResourceChange
when setting IP and host (Contributed by Miklos Szegedi via Daniel Templeton)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/62b42ef5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/62b42ef5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/62b42ef5

Branch: refs/heads/trunk
Commit: 62b42ef5dd04d516d33bf0890ac5cd49f8184a73
Parents: a2b1ff0
Author: Daniel Templeton <templedf@apache.org>
Authored: Mon Nov 28 15:16:43 2016 -0800
Committer: Daniel Templeton <templedf@apache.org>
Committed: Mon Nov 28 15:19:52 2016 -0800

----------------------------------------------------------------------
 .../monitor/ContainersMonitorImpl.java          | 36 +++++++++++++-------
 .../TestContainersMonitorResourceChange.java    | 16 +++++++--
 2 files changed, 36 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/62b42ef5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
index dda55d2..718604d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
@@ -536,15 +536,21 @@ public class ContainersMonitorImpl extends AbstractService implements
           }
 
           Container container = context.getContainers().get(containerId);
-          String[] ipAndHost = containerExecutor.getIpAndHost(container);
-          if (ipAndHost != null && ipAndHost[0] != null
-                  && ipAndHost[1] != null) {
-            container.setIpAndHost(ipAndHost);
-            LOG.info(containerId + "'s ip = " + ipAndHost[0]
-                    + ", and hostname = " + ipAndHost[1]);
+
+          if (container != null) {
+            String[] ipAndHost = containerExecutor.getIpAndHost(container);
+
+            if ((ipAndHost != null) && (ipAndHost[0] != null) &&
+                (ipAndHost[1] != null)) {
+              container.setIpAndHost(ipAndHost);
+              LOG.info(containerId + "'s ip = " + ipAndHost[0]
+                  + ", and hostname = " + ipAndHost[1]);
+            } else {
+              LOG.info("Can not get both ip and hostname: "
+                  + Arrays.toString(ipAndHost));
+            }
           } else {
-            LOG.info("Can not get both ip and hostname: " + Arrays
-                    .toString(ipAndHost));
+            LOG.info(containerId + " is missing. Not setting ip and hostname");
           }
         }
       }
@@ -683,11 +689,15 @@ public class ContainersMonitorImpl extends AbstractService implements
         long currentPmemUsage, float cpuUsagePercentPerCore) {
       ContainerImpl container =
               (ContainerImpl) context.getContainers().get(containerId);
-      NMTimelinePublisher nmMetricsPublisher =
-              container.getNMTimelinePublisher();
-      if (nmMetricsPublisher != null) {
-        nmMetricsPublisher.reportContainerResourceUsage(container,
-                currentPmemUsage, cpuUsagePercentPerCore);
+      if (container != null) {
+        NMTimelinePublisher nmMetricsPublisher =
+                container.getNMTimelinePublisher();
+        if (nmMetricsPublisher != null) {
+          nmMetricsPublisher.reportContainerResourceUsage(container,
+                  currentPmemUsage, cpuUsagePercentPerCore);
+        }
+      } else {
+        LOG.info(containerId + " does not exist to report");
       }
     }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/62b42ef5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitorResourceChange.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitorResourceChange.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitorResourceChange.java
index d24f89d..29a60f7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitorResourceChange.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitorResourceChange.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 
 import org.apache.hadoop.conf.Configuration;
@@ -37,6 +38,7 @@ import org.apache.hadoop.yarn.server.nodemanager.Context;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType;
+import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerImpl;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl.ProcessTreeInfo;
 import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerLivenessContext;
 import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerSignalContext;
@@ -64,6 +66,7 @@ public class TestContainersMonitorResourceChange {
   private AsyncDispatcher dispatcher;
   private Context context;
   private MockContainerEventHandler containerEventHandler;
+  private ConcurrentMap<ContainerId, Container> containerMap;
 
   static final int WAIT_MS_PER_LOOP = 20; // 20 milli seconds
 
@@ -131,8 +134,10 @@ public class TestContainersMonitorResourceChange {
     executor = new MockExecutor();
     dispatcher = new AsyncDispatcher();
     context = Mockito.mock(Context.class);
-    Mockito.doReturn(new ConcurrentSkipListMap<ContainerId, Container>())
-        .when(context).getContainers();
+    containerMap = new ConcurrentSkipListMap<>();
+    Container container = Mockito.mock(ContainerImpl.class);
+    containerMap.put(getContainerId(1), container);
+    Mockito.doReturn(containerMap).when(context).getContainers();
     conf = new Configuration();
     conf.set(
         YarnConfiguration.NM_CONTAINER_MON_RESOURCE_CALCULATOR,
@@ -181,7 +186,12 @@ public class TestContainersMonitorResourceChange {
             getContainerId(1)).getProcessTree();
     mockTree.setRssMemorySize(2500L);
     // verify that this container is killed
-    Thread.sleep(200);
+    for (int waitMs = 0; waitMs < 5000; waitMs += 50) {
+      if (containerEventHandler.isContainerKilled(getContainerId(1))) {
+        break;
+      }
+      Thread.sleep(50);
+    }
     assertTrue(containerEventHandler
         .isContainerKilled(getContainerId(1)));
     // create container 2


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message