hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1097744 - in /hadoop/mapreduce/branches/MR-279: ./ yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache...
Date Fri, 29 Apr 2011 09:27:36 GMT
Author: vinodkv
Date: Fri Apr 29 09:27:35 2011
New Revision: 1097744

URL: http://svn.apache.org/viewvc?rev=1097744&view=rev
Log:
Fixing NPEs by disabling ContainerMonitoring for non-linux systems.

Modified:
    hadoop/mapreduce/branches/MR-279/CHANGES.txt
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java

Modified: hadoop/mapreduce/branches/MR-279/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/CHANGES.txt?rev=1097744&r1=1097743&r2=1097744&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/CHANGES.txt (original)
+++ hadoop/mapreduce/branches/MR-279/CHANGES.txt Fri Apr 29 09:27:35 2011
@@ -3,6 +3,9 @@ Hadoop MapReduce Change Log
 Trunk (unreleased changes)
 
   MAPREDUCE-279
+
+    Disable ContainerMonitoring for non-linux systems. (vinodkv)
+
     Fix file creation in JobHistoryEventHandler. (sharad)
 
     Reorient container localization to be per-container rather than

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java?rev=1097744&r1=1097743&r2=1097744&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
(original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
Fri Apr 29 09:27:35 2011
@@ -134,7 +134,7 @@ public class ContainersMonitorImpl exten
    * 
    * @return true if total physical memory check is enabled.
    */
-  boolean doCheckPhysicalMemory() {
+  boolean isPhysicalMemoryCheckEnabled() {
     return !(this.maxPmemAllottedForContainers == DISABLED_MEMORY_LIMIT);
   }
 
@@ -143,23 +143,43 @@ public class ContainersMonitorImpl exten
    * 
    * @return true if total virtual memory check is enabled.
    */
-  boolean doCheckVirtualMemory() {
+  boolean isVirtualMemoryCheckEnabled() {
     return !(this.maxVmemAllottedForContainers == DISABLED_MEMORY_LIMIT);
   }
 
+  private boolean isEnabled() {
+    if (!ProcfsBasedProcessTree.isAvailable()) {
+      LOG.info("ProcessTree implementation is missing on this system. "
+          + this.getClass().getName() + " is disabled.");
+      return false;
+    }
+
+    if (!(isPhysicalMemoryCheckEnabled() || isVirtualMemoryCheckEnabled())) {
+      LOG.info("Neither virutal-memory nor physical-memory monitoring is " +
+          "needed. Not running the monitor-thread");
+      return false;
+    }
+
+    return true;
+  }
+
   @Override
   public synchronized void start() {
-    this.monitoringThread.start();
+    if (this.isEnabled()) {
+      this.monitoringThread.start();
+    }
     super.start();
   }
 
   @Override
   public synchronized void stop() {
-    this.monitoringThread.interrupt();
-    try {
-      this.monitoringThread.join();
-    } catch (InterruptedException e) {
-      ;
+    if (this.isEnabled()) {
+      this.monitoringThread.interrupt();
+      try {
+        this.monitoringThread.join();
+      } catch (InterruptedException e) {
+        ;
+      }
     }
     super.stop();
   }
@@ -284,12 +304,6 @@ public class ContainersMonitorImpl exten
     @Override
     public void run() {
 
-      if (!(doCheckPhysicalMemory() || doCheckVirtualMemory())) {
-        LOG.info("Neither virutal-memory nor physical-memory monitoring is " +
-            "needed. Not running the monitor-thread");
-        return;
-      }
-
       while (true) {
 
         // Print the processTrees for debugging.
@@ -380,7 +394,7 @@ public class ContainersMonitorImpl exten
 
             boolean isMemoryOverLimit = false;
             String msg = "";
-            if (doCheckVirtualMemory()
+            if (isVirtualMemoryCheckEnabled()
                 && isProcessTreeOverLimit(containerId.toString(),
                     currentVmemUsage, curMemUsageOfAgedProcesses, vmemLimit)) {
               // Container (the root process) is still alive and overflowing
@@ -399,7 +413,7 @@ public class ContainersMonitorImpl exten
                       + "\nDump of the process-tree for " + containerId
                       + " : \n" + pTree.getProcessTreeDump();
               isMemoryOverLimit = true;
-            } else if (doCheckPhysicalMemory()
+            } else if (isPhysicalMemoryCheckEnabled()
                 && isProcessTreeOverLimit(containerId.toString(),
                     currentPmemUsage, curRssMemUsageOfAgedProcesses,
                     pmemLimit)) {
@@ -477,7 +491,7 @@ public class ContainersMonitorImpl exten
   @Override
   public void handle(ContainersMonitorEvent monitoringEvent) {
 
-    if (!(doCheckPhysicalMemory() || doCheckVirtualMemory())) {
+    if (!isEnabled()) {
       return;
     }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java?rev=1097744&r1=1097743&r2=1097744&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java
(original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java
Fri Apr 29 09:27:35 2011
@@ -238,7 +238,7 @@ public class TestContainersMonitor {
   public void testContainerKillOnMemoryOverflow() throws IOException,
       InterruptedException {
 
-    if (!System.getProperty("os.name").startsWith("Linux")) {
+    if (!ProcfsBasedProcessTree.isAvailable()) {
       return;
     }
 



Mime
View raw message