hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [37/50] hadoop git commit: YARN-6438. Code can be improved in ContainersMonitorImpl.java (Contributed by Miklos Szegedi via Daniel Templeton)
Date Thu, 20 Apr 2017 21:53:55 GMT
YARN-6438. Code can be improved in ContainersMonitorImpl.java
(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/41ac190d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/41ac190d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/41ac190d

Branch: refs/heads/YARN-5734
Commit: 41ac190dba782a59669bd622f572f452267c808e
Parents: 15acdbd
Author: Daniel Templeton <templedf@apache.org>
Authored: Wed Apr 19 10:53:08 2017 -0700
Committer: Daniel Templeton <templedf@apache.org>
Committed: Wed Apr 19 10:53:08 2017 -0700

----------------------------------------------------------------------
 .../monitor/ContainersMonitorImpl.java          | 49 +++++++++-----------
 1 file changed, 21 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/41ac190d/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 718604d..6ee60bd 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
@@ -422,7 +422,6 @@ public class ContainersMonitorImpl extends AbstractService implements
         long vmemUsageByAllContainers = 0;
         long pmemByAllContainers = 0;
         long cpuUsagePercentPerCoreByAllContainers = 0;
-        long cpuUsageTotalCoresByAllContainers = 0;
         for (Entry<ContainerId, ProcessTreeInfo> entry : trackingContainers
             .entrySet()) {
           ContainerId containerId = entry.getKey();
@@ -446,8 +445,7 @@ public class ContainersMonitorImpl extends AbstractService implements
             long currentPmemUsage = pTree.getRssMemorySize();
 
             // if machine has 6 cores and 3 are used,
-            // cpuUsagePercentPerCore should be 300% and
-            // cpuUsageTotalCoresPercentage should be 50%
+            // cpuUsagePercentPerCore should be 300%
             float cpuUsagePercentPerCore = pTree.getCpuUsagePercent();
             if (cpuUsagePercentPerCore < 0) {
               // CPU usage is not available likely because the container just
@@ -469,7 +467,6 @@ public class ContainersMonitorImpl extends AbstractService implements
             pmemByAllContainers += currentPmemUsage;
             // Accounting the total cpu usage for all containers
             cpuUsagePercentPerCoreByAllContainers += cpuUsagePercentPerCore;
-            cpuUsageTotalCoresByAllContainers += cpuUsagePercentPerCore;
 
             reportResourceUsage(containerId, currentPmemUsage,
                     cpuUsagePercentPerCore);
@@ -483,8 +480,7 @@ public class ContainersMonitorImpl extends AbstractService implements
           LOG.debug("Total Resource Usage stats in NM by all containers : "
               + "Virtual Memory= " + vmemUsageByAllContainers
               + ", Physical Memory= " + pmemByAllContainers
-              + ", Total CPU usage= " + cpuUsageTotalCoresByAllContainers
-              + ", Total CPU(% per core) usage"
+              + ", Total CPU usage(% per core)= "
               + cpuUsagePercentPerCoreByAllContainers);
         }
 
@@ -572,6 +568,9 @@ public class ContainersMonitorImpl extends AbstractService implements
                              ProcessTreeInfo ptInfo,
                              long currentVmemUsage, long currentPmemUsage,
                              ResourceUtilization trackedContainersUtilization) {
+      // if machine has 6 cores and 3 are used,
+      // cpuUsagePercentPerCore should be 300% and
+      // cpuUsageTotalCoresPercentage should be 50%
       float cpuUsagePercentPerCore = pTree.getCpuUsagePercent();
       float cpuUsageTotalCoresPercentage = cpuUsagePercentPerCore /
               resourceCalculatorPlugin.getNumProcessors();
@@ -867,16 +866,6 @@ public class ContainersMonitorImpl extends AbstractService implements
   @SuppressWarnings("unchecked")
   public void handle(ContainersMonitorEvent monitoringEvent) {
     ContainerId containerId = monitoringEvent.getContainerId();
-    if (!containersMonitorEnabled) {
-      if (monitoringEvent.getType() == ContainersMonitorEventType
-          .CHANGE_MONITORING_CONTAINER_RESOURCE) {
-        // Nothing to enforce. Update container resource immediately.
-        ChangeMonitoringContainerResourceEvent changeEvent =
-            (ChangeMonitoringContainerResourceEvent) monitoringEvent;
-        changeContainerResource(containerId, changeEvent.getResource());
-      }
-      return;
-    }
 
     switch (monitoringEvent.getType()) {
     case START_MONITORING_CONTAINER:
@@ -897,19 +886,23 @@ public class ContainersMonitorImpl extends AbstractService implements
       ContainersMonitorEvent monitoringEvent, ContainerId containerId) {
     ChangeMonitoringContainerResourceEvent changeEvent =
         (ChangeMonitoringContainerResourceEvent) monitoringEvent;
-    ProcessTreeInfo processTreeInfo = trackingContainers.get(containerId);
-    if (processTreeInfo == null) {
-      LOG.warn("Failed to track container "
-          + containerId.toString()
-          + ". It may have already completed.");
-      return;
+    if (containersMonitorEnabled) {
+      ProcessTreeInfo processTreeInfo = trackingContainers.get(containerId);
+      if (processTreeInfo == null) {
+        LOG.warn("Failed to track container "
+            + containerId.toString()
+            + ". It may have already completed.");
+        return;
+      }
+      LOG.info("Changing resource-monitoring for " + containerId);
+      updateContainerMetrics(monitoringEvent);
+      long pmemLimit =
+          changeEvent.getResource().getMemorySize() * 1024L * 1024L;
+      long vmemLimit = (long) (pmemLimit * vmemRatio);
+      int cpuVcores = changeEvent.getResource().getVirtualCores();
+      processTreeInfo.setResourceLimit(pmemLimit, vmemLimit, cpuVcores);
     }
-    LOG.info("Changing resource-monitoring for " + containerId);
-    updateContainerMetrics(monitoringEvent);
-    long pmemLimit = changeEvent.getResource().getMemorySize() * 1024L * 1024L;
-    long vmemLimit = (long) (pmemLimit * vmemRatio);
-    int cpuVcores = changeEvent.getResource().getVirtualCores();
-    processTreeInfo.setResourceLimit(pmemLimit, vmemLimit, cpuVcores);
+
     changeContainerResource(containerId, changeEvent.getResource());
   }
 


---------------------------------------------------------------------
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