Author: bobby Date: Wed Oct 24 14:08:28 2012 New Revision: 1401700 URL: http://svn.apache.org/viewvc?rev=1401700&view=rev Log: svn merge -c 1401698 FIXES: YARN-178. Fix custom ProcessTree instance creation (Radim Kolar via bobby)
Added: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestResourceCalculatorProcessTree.java - copied unchanged from r1401698, hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestResourceCalculatorProcessTree.java Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ProcfsBasedProcessTree.java hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorProcessTree.java Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt?rev=1401700&r1=1401699&r2=1401700&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-yarn-project/CHANGES.txt Wed Oct 24 14:08:28 2012 @@ -160,6 +160,8 @@ Release 0.23.5 - UNRELEASED YARN-177. CapacityScheduler - adding a queue while the RM is running has wacky results (acmurthy vai tgraves) + YARN-178. Fix custom ProcessTree instance creation (Radim Kolar via bobby) + Release 0.23.4 - UNRELEASED INCOMPATIBLE CHANGES Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ProcfsBasedProcessTree.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ProcfsBasedProcessTree.java?rev=1401700&r1=1401699&r2=1401700&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ProcfsBasedProcessTree.java (original) +++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ProcfsBasedProcessTree.java Wed Oct 24 14:08:28 2012 @@ -114,6 +114,7 @@ public class ProcfsBasedProcessTree exte * @param procfsDir the root of a proc file system - only used for testing. */ public ProcfsBasedProcessTree(String pid, String procfsDir) { + super(pid); this.pid = getValidPID(pid); this.procfsDir = procfsDir; } Modified: hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorProcessTree.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorProcessTree.java?rev=1401700&r1=1401699&r2=1401700&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorProcessTree.java (original) +++ hadoop/common/branches/branch-2/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/ResourceCalculatorProcessTree.java Wed Oct 24 14:08:28 2012 @@ -21,17 +21,28 @@ package org.apache.hadoop.yarn.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.conf.Configured; import org.apache.hadoop.util.ReflectionUtils; +import java.lang.reflect.Constructor; /** * Interface class to obtain process resource usage * */ -public abstract class ResourceCalculatorProcessTree { +public abstract class ResourceCalculatorProcessTree extends Configured { static final Log LOG = LogFactory .getLog(ResourceCalculatorProcessTree.class); /** + * Create process-tree instance with specified root process. + * + * Subclass must override this. + * @param root process-tree root-process + */ + public ResourceCalculatorProcessTree(String root) { + } + + /** * Get the process-tree with latest state. If the root-process is not alive, * an empty tree will be returned. * @@ -122,10 +133,17 @@ public abstract class ResourceCalculator * is not available for this system. */ public static ResourceCalculatorProcessTree getResourceCalculatorProcessTree( - String pid, Class<? extends ResourceCalculatorProcessTree> clazz, Configuration conf) { + String pid, Class<? extends ResourceCalculatorProcessTree> clazz, Configuration conf) { if (clazz != null) { - return ReflectionUtils.newInstance(clazz, conf); + try { + Constructor <? extends ResourceCalculatorProcessTree> c = clazz.getConstructor(String.class); + ResourceCalculatorProcessTree rctree = c.newInstance(pid); + rctree.setConf(conf); + return rctree; + } catch(Exception e) { + throw new RuntimeException(e); + } } // No class given, try a os specific class