YARN-223. Update process tree instead of getting new process trees. (Radim Kolar via llu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1424242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luke Lu 2012-12-20 00:19:40 +00:00
parent e30516f017
commit 8636b12e35
13 changed files with 56 additions and 123 deletions

View File

@ -61,8 +61,7 @@ import org.apache.hadoop.mapreduce.MRConfig;
import org.apache.hadoop.mapreduce.MRJobConfig; import org.apache.hadoop.mapreduce.MRJobConfig;
import org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer; import org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer;
import org.apache.hadoop.mapreduce.task.ReduceContextImpl; import org.apache.hadoop.mapreduce.task.ReduceContextImpl;
import org.apache.hadoop.yarn.util.ResourceCalculatorPlugin; import org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree;
import org.apache.hadoop.yarn.util.ResourceCalculatorPlugin.*;
import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.util.Progress; import org.apache.hadoop.util.Progress;
import org.apache.hadoop.util.Progressable; import org.apache.hadoop.util.Progressable;
@ -169,7 +168,7 @@ abstract public class Task implements Writable, Configurable {
private Iterator<Long> currentRecIndexIterator = private Iterator<Long> currentRecIndexIterator =
skipRanges.skipRangeIterator(); skipRanges.skipRangeIterator();
private ResourceCalculatorPlugin resourceCalculator = null; private ResourceCalculatorProcessTree pTree;
private long initCpuCumulativeTime = 0; private long initCpuCumulativeTime = 0;
protected JobConf conf; protected JobConf conf;
@ -372,7 +371,7 @@ abstract public class Task implements Writable, Configurable {
* Return current state of the task. * Return current state of the task.
* needs to be synchronized as communication thread * needs to be synchronized as communication thread
* sends the state every second * sends the state every second
* @return * @return task state
*/ */
synchronized TaskStatus.State getState(){ synchronized TaskStatus.State getState(){
return this.taskStatus.getRunState(); return this.taskStatus.getRunState();
@ -558,15 +557,15 @@ abstract public class Task implements Writable, Configurable {
} }
} }
committer.setupTask(taskContext); committer.setupTask(taskContext);
Class<? extends ResourceCalculatorPlugin> clazz = Class<? extends ResourceCalculatorProcessTree> clazz =
conf.getClass(MRConfig.RESOURCE_CALCULATOR_PLUGIN, conf.getClass(MRConfig.RESOURCE_CALCULATOR_PROCESS_TREE,
null, ResourceCalculatorPlugin.class); null, ResourceCalculatorProcessTree.class);
resourceCalculator = ResourceCalculatorPlugin pTree = ResourceCalculatorProcessTree
.getResourceCalculatorPlugin(clazz, conf); .getResourceCalculatorProcessTree(System.getenv().get("JVM_PID"), clazz, conf);
LOG.info(" Using ResourceCalculatorPlugin : " + resourceCalculator); LOG.info(" Using ResourceCalculatorProcessTree : " + pTree);
if (resourceCalculator != null) { if (pTree != null) {
initCpuCumulativeTime = pTree.updateProcessTree();
resourceCalculator.getProcResourceValues().getCumulativeCpuTime(); initCpuCumulativeTime = pTree.getCumulativeCpuTime();
} }
} }
@ -817,14 +816,14 @@ abstract public class Task implements Writable, Configurable {
// Update generic resource counters // Update generic resource counters
updateHeapUsageCounter(); updateHeapUsageCounter();
// Updating resources specified in ResourceCalculatorPlugin // Updating resources specified in ResourceCalculatorProcessTree
if (resourceCalculator == null) { if (pTree == null) {
return; return;
} }
ProcResourceValues res = resourceCalculator.getProcResourceValues(); pTree.updateProcessTree();
long cpuTime = res.getCumulativeCpuTime(); long cpuTime = pTree.getCumulativeCpuTime();
long pMem = res.getPhysicalMemorySize(); long pMem = pTree.getCumulativeRssmem();
long vMem = res.getVirtualMemorySize(); long vMem = pTree.getCumulativeVmem();
// Remove the CPU time consumed previously by JVM reuse // Remove the CPU time consumed previously by JVM reuse
cpuTime -= initCpuCumulativeTime; cpuTime -= initCpuCumulativeTime;
counters.findCounter(TaskCounter.CPU_MILLISECONDS).setValue(cpuTime); counters.findCounter(TaskCounter.CPU_MILLISECONDS).setValue(cpuTime);

View File

@ -55,8 +55,8 @@ public interface MRConfig {
public static final long DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT = public static final long DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT =
7*24*60*60*1000; // 7 days 7*24*60*60*1000; // 7 days
public static final String RESOURCE_CALCULATOR_PLUGIN = public static final String RESOURCE_CALCULATOR_PROCESS_TREE =
"mapreduce.job.resourcecalculatorplugin"; "mapreduce.job.process-tree.class";
public static final String STATIC_RESOLUTIONS = public static final String STATIC_RESOLUTIONS =
"mapreduce.job.net.static.resolutions"; "mapreduce.job.net.static.resolutions";

View File

@ -409,7 +409,7 @@ public class LinuxResourceCalculatorPlugin extends ResourceCalculatorPlugin {
@Override @Override
public ProcResourceValues getProcResourceValues() { public ProcResourceValues getProcResourceValues() {
pTree = pTree.getProcessTree(); pTree.updateProcessTree();
long cpuTime = pTree.getCumulativeCpuTime(); long cpuTime = pTree.getCumulativeCpuTime();
long pMem = pTree.getCumulativeRssmem(); long pMem = pTree.getCumulativeRssmem();
long vMem = pTree.getCumulativeVmem(); long vMem = pTree.getCumulativeVmem();

View File

@ -166,12 +166,10 @@ public class ProcfsBasedProcessTree extends ProcessTree {
} }
/** /**
* Get the process-tree with latest state. If the root-process is not alive, * Update the process-tree with latest state. If the root-process is not alive,
* an empty tree will be returned. * tree will become empty.
*
* @return the process-tree with latest state.
*/ */
public ProcfsBasedProcessTree getProcessTree() { public void updateProcessTree() {
if (!pid.equals(deadPid)) { if (!pid.equals(deadPid)) {
// Get the list of processes // Get the list of processes
List<String> processList = getProcessList(); List<String> processList = getProcessList();
@ -197,7 +195,7 @@ public class ProcfsBasedProcessTree extends ProcessTree {
} }
if (me == null) { if (me == null) {
return this; return;
} }
// Add each process to its parent. // Add each process to its parent.
@ -239,7 +237,6 @@ public class ProcfsBasedProcessTree extends ProcessTree {
LOG.debug(this.toString()); LOG.debug(this.toString());
} }
} }
return this;
} }
/** /**

View File

@ -151,7 +151,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
ProcfsBasedProcessTree p = new ProcfsBasedProcessTree(pid, ProcfsBasedProcessTree p = new ProcfsBasedProcessTree(pid,
ProcessTree.isSetsidAvailable, ProcessTree.isSetsidAvailable,
ProcessTree.DEFAULT_SLEEPTIME_BEFORE_SIGKILL); ProcessTree.DEFAULT_SLEEPTIME_BEFORE_SIGKILL);
p = p.getProcessTree(); // initialize p.updateProcessTree(); // initialize
LOG.info("ProcessTree: " + p.toString()); LOG.info("ProcessTree: " + p.toString());
File leaf = new File(lowestDescendant); File leaf = new File(lowestDescendant);
@ -164,7 +164,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
} }
} }
p = p.getProcessTree(); // reconstruct p.updateProcessTree(); // reconstruct
LOG.info("ProcessTree: " + p.toString()); LOG.info("ProcessTree: " + p.toString());
// Get the process-tree dump // Get the process-tree dump
@ -203,7 +203,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
} }
// ProcessTree is gone now. Any further calls should be sane. // ProcessTree is gone now. Any further calls should be sane.
p = p.getProcessTree(); p.updateProcessTree();
assertFalse("ProcessTree must have been gone", p.isAlive()); assertFalse("ProcessTree must have been gone", p.isAlive());
assertTrue("Cumulative vmem for the gone-process is " assertTrue("Cumulative vmem for the gone-process is "
+ p.getCumulativeVmem() + " . It should be zero.", p + p.getCumulativeVmem() + " . It should be zero.", p
@ -336,7 +336,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
new ProcfsBasedProcessTree("100", true, 100L, new ProcfsBasedProcessTree("100", true, 100L,
procfsRootDir.getAbsolutePath()); procfsRootDir.getAbsolutePath());
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// verify cumulative memory // verify cumulative memory
assertEquals("Cumulative virtual memory does not match", 600000L, assertEquals("Cumulative virtual memory does not match", 600000L,
@ -362,7 +362,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
writeStatFiles(procfsRootDir, pids, procInfos); writeStatFiles(procfsRootDir, pids, procInfos);
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// verify cumulative cpu time again // verify cumulative cpu time again
cumuCpuTime = ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0 ? cumuCpuTime = ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0 ?
@ -409,7 +409,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
new ProcfsBasedProcessTree("100", true, 100L, new ProcfsBasedProcessTree("100", true, 100L,
procfsRootDir.getAbsolutePath()); procfsRootDir.getAbsolutePath());
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// verify cumulative memory // verify cumulative memory
assertEquals("Cumulative memory does not match", assertEquals("Cumulative memory does not match",
@ -425,7 +425,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
writeStatFiles(procfsRootDir, newPids, newProcInfos); writeStatFiles(procfsRootDir, newPids, newProcInfos);
// check memory includes the new process. // check memory includes the new process.
processTree.getProcessTree(); processTree.updateProcessTree();
assertEquals("Cumulative vmem does not include new process", assertEquals("Cumulative vmem does not include new process",
1200000L, processTree.getCumulativeVmem()); 1200000L, processTree.getCumulativeVmem());
long cumuRssMem = ProcfsBasedProcessTree.PAGE_SIZE > 0 ? long cumuRssMem = ProcfsBasedProcessTree.PAGE_SIZE > 0 ?
@ -451,7 +451,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
writeStatFiles(procfsRootDir, newPids, newProcInfos); writeStatFiles(procfsRootDir, newPids, newProcInfos);
// refresh process tree // refresh process tree
processTree.getProcessTree(); processTree.updateProcessTree();
// processes older than 2 iterations should be same as before. // processes older than 2 iterations should be same as before.
assertEquals("Cumulative vmem shouldn't have included new processes", assertEquals("Cumulative vmem shouldn't have included new processes",
@ -555,7 +555,7 @@ public class TestProcfsBasedProcessTree extends TestCase {
new ProcfsBasedProcessTree("100", true, 100L, procfsRootDir new ProcfsBasedProcessTree("100", true, 100L, procfsRootDir
.getAbsolutePath()); .getAbsolutePath());
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// Get the process-tree dump // Get the process-tree dump
String processTreeDump = processTree.getProcessTreeDump(); String processTreeDump = processTree.getProcessTreeDump();

View File

@ -91,7 +91,6 @@ public class LinuxResourceCalculatorPlugin extends ResourceCalculatorPlugin {
private float cpuUsage = UNAVAILABLE; private float cpuUsage = UNAVAILABLE;
private long sampleTime = UNAVAILABLE; private long sampleTime = UNAVAILABLE;
private long lastSampleTime = UNAVAILABLE; private long lastSampleTime = UNAVAILABLE;
private ResourceCalculatorProcessTree pTree = null;
boolean readMemInfoFile = false; boolean readMemInfoFile = false;
boolean readCpuInfoFile = false; boolean readCpuInfoFile = false;
@ -109,8 +108,6 @@ public class LinuxResourceCalculatorPlugin extends ResourceCalculatorPlugin {
procfsCpuFile = PROCFS_CPUINFO; procfsCpuFile = PROCFS_CPUINFO;
procfsStatFile = PROCFS_STAT; procfsStatFile = PROCFS_STAT;
jiffyLengthInMillis = ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS; jiffyLengthInMillis = ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS;
String pid = System.getenv().get("JVM_PID");
pTree = new ProcfsBasedProcessTree(pid);
} }
/** /**
@ -129,8 +126,6 @@ public class LinuxResourceCalculatorPlugin extends ResourceCalculatorPlugin {
this.procfsCpuFile = procfsCpuFile; this.procfsCpuFile = procfsCpuFile;
this.procfsStatFile = procfsStatFile; this.procfsStatFile = procfsStatFile;
this.jiffyLengthInMillis = jiffyLengthInMillis; this.jiffyLengthInMillis = jiffyLengthInMillis;
String pid = System.getenv().get("JVM_PID");
pTree = new ProcfsBasedProcessTree(pid);
} }
/** /**
@ -400,13 +395,4 @@ public class LinuxResourceCalculatorPlugin extends ResourceCalculatorPlugin {
} }
System.out.println("CPU usage % : " + plugin.getCpuUsage()); System.out.println("CPU usage % : " + plugin.getCpuUsage());
} }
@Override
public ProcResourceValues getProcResourceValues() {
pTree = pTree.getProcessTree();
long cpuTime = pTree.getCumulativeCpuTime();
long pMem = pTree.getCumulativeRssmem();
long vMem = pTree.getCumulativeVmem();
return new ProcResourceValues(cpuTime, pMem, vMem);
}
} }

View File

@ -140,13 +140,12 @@ public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree {
} }
/** /**
* Get the process-tree with latest state. If the root-process is not alive, * Update process-tree with latest state. If the root-process is not alive,
* an empty tree will be returned. * tree will be empty.
* *
* @return the process-tree with latest state.
*/ */
@Override @Override
public ResourceCalculatorProcessTree getProcessTree() { public void updateProcessTree() {
if (!pid.equals(deadPid)) { if (!pid.equals(deadPid)) {
// Get the list of processes // Get the list of processes
List<String> processList = getProcessList(); List<String> processList = getProcessList();
@ -172,7 +171,7 @@ public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree {
} }
if (me == null) { if (me == null) {
return this; return;
} }
// Add each process to its parent. // Add each process to its parent.
@ -214,7 +213,6 @@ public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree {
LOG.debug(this.toString()); LOG.debug(this.toString());
} }
} }
return this;
} }
/** Verify that the given process id is same as its process group id. /** Verify that the given process id is same as its process group id.

View File

@ -90,48 +90,6 @@ public abstract class ResourceCalculatorPlugin extends Configured {
*/ */
public abstract float getCpuUsage(); public abstract float getCpuUsage();
/**
* Obtain resource status used by current process tree.
*/
@InterfaceAudience.Private
@InterfaceStability.Unstable
public abstract ProcResourceValues getProcResourceValues();
public static class ProcResourceValues {
private final long cumulativeCpuTime;
private final long physicalMemorySize;
private final long virtualMemorySize;
public ProcResourceValues(long cumulativeCpuTime, long physicalMemorySize,
long virtualMemorySize) {
this.cumulativeCpuTime = cumulativeCpuTime;
this.physicalMemorySize = physicalMemorySize;
this.virtualMemorySize = virtualMemorySize;
}
/**
* Obtain the physical memory size used by current process tree.
* @return physical memory size in bytes.
*/
public long getPhysicalMemorySize() {
return physicalMemorySize;
}
/**
* Obtain the virtual memory size used by a current process tree.
* @return virtual memory size in bytes.
*/
public long getVirtualMemorySize() {
return virtualMemorySize;
}
/**
* Obtain the cumulative CPU time used by a current process tree.
* @return cumulative CPU time in milliseconds
*/
public long getCumulativeCpuTime() {
return cumulativeCpuTime;
}
}
/** /**
* Create the ResourceCalculatorPlugin from the class name and configure it. If * Create the ResourceCalculatorPlugin from the class name and configure it. If
* class name is null, this method will try and return a memory calculator * class name is null, this method will try and return a memory calculator

View File

@ -43,16 +43,14 @@ public abstract class ResourceCalculatorProcessTree extends Configured {
} }
/** /**
* Get the process-tree with latest state. If the root-process is not alive, * Update the process-tree with latest state.
* an empty tree will be returned.
* *
* Each call to this function should increment the age of the running * Each call to this function should increment the age of the running
* processes that already exist in the process tree. Age is used other API's * processes that already exist in the process tree. Age is used other API's
* of the interface. * of the interface.
* *
* @return the process-tree with latest state.
*/ */
public abstract ResourceCalculatorProcessTree getProcessTree(); public abstract void updateProcessTree();
/** /**
* Get a dump of the process-tree. * Get a dump of the process-tree.

View File

@ -161,7 +161,7 @@ public class TestProcfsBasedProcessTree {
String pid = getRogueTaskPID(); String pid = getRogueTaskPID();
LOG.info("Root process pid: " + pid); LOG.info("Root process pid: " + pid);
ProcfsBasedProcessTree p = createProcessTree(pid); ProcfsBasedProcessTree p = createProcessTree(pid);
p.getProcessTree(); // initialize p.updateProcessTree(); // initialize
LOG.info("ProcessTree: " + p.toString()); LOG.info("ProcessTree: " + p.toString());
File leaf = new File(lowestDescendant); File leaf = new File(lowestDescendant);
@ -174,7 +174,7 @@ public class TestProcfsBasedProcessTree {
} }
} }
p.getProcessTree(); // reconstruct p.updateProcessTree(); // reconstruct
LOG.info("ProcessTree: " + p.toString()); LOG.info("ProcessTree: " + p.toString());
// Get the process-tree dump // Get the process-tree dump
@ -213,7 +213,7 @@ public class TestProcfsBasedProcessTree {
} }
// ProcessTree is gone now. Any further calls should be sane. // ProcessTree is gone now. Any further calls should be sane.
p.getProcessTree(); p.updateProcessTree();
Assert.assertFalse("ProcessTree must have been gone", isAlive(pid)); Assert.assertFalse("ProcessTree must have been gone", isAlive(pid));
Assert.assertTrue("Cumulative vmem for the gone-process is " Assert.assertTrue("Cumulative vmem for the gone-process is "
+ p.getCumulativeVmem() + " . It should be zero.", p + p.getCumulativeVmem() + " . It should be zero.", p
@ -358,7 +358,7 @@ public class TestProcfsBasedProcessTree {
ProcfsBasedProcessTree processTree = ProcfsBasedProcessTree processTree =
createProcessTree("100", procfsRootDir.getAbsolutePath()); createProcessTree("100", procfsRootDir.getAbsolutePath());
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// verify cumulative memory // verify cumulative memory
Assert.assertEquals("Cumulative virtual memory does not match", 600000L, Assert.assertEquals("Cumulative virtual memory does not match", 600000L,
@ -384,7 +384,7 @@ public class TestProcfsBasedProcessTree {
writeStatFiles(procfsRootDir, pids, procInfos); writeStatFiles(procfsRootDir, pids, procInfos);
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// verify cumulative cpu time again // verify cumulative cpu time again
cumuCpuTime = ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0 ? cumuCpuTime = ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0 ?
@ -431,7 +431,7 @@ public class TestProcfsBasedProcessTree {
ProcfsBasedProcessTree processTree = ProcfsBasedProcessTree processTree =
createProcessTree("100", procfsRootDir.getAbsolutePath()); createProcessTree("100", procfsRootDir.getAbsolutePath());
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// verify cumulative memory // verify cumulative memory
Assert.assertEquals("Cumulative memory does not match", Assert.assertEquals("Cumulative memory does not match",
@ -447,7 +447,7 @@ public class TestProcfsBasedProcessTree {
writeStatFiles(procfsRootDir, newPids, newProcInfos); writeStatFiles(procfsRootDir, newPids, newProcInfos);
// check memory includes the new process. // check memory includes the new process.
processTree.getProcessTree(); processTree.updateProcessTree();
Assert.assertEquals("Cumulative vmem does not include new process", Assert.assertEquals("Cumulative vmem does not include new process",
1200000L, processTree.getCumulativeVmem()); 1200000L, processTree.getCumulativeVmem());
long cumuRssMem = ProcfsBasedProcessTree.PAGE_SIZE > 0 ? long cumuRssMem = ProcfsBasedProcessTree.PAGE_SIZE > 0 ?
@ -473,7 +473,7 @@ public class TestProcfsBasedProcessTree {
writeStatFiles(procfsRootDir, newPids, newProcInfos); writeStatFiles(procfsRootDir, newPids, newProcInfos);
// refresh process tree // refresh process tree
processTree.getProcessTree(); processTree.updateProcessTree();
// processes older than 2 iterations should be same as before. // processes older than 2 iterations should be same as before.
Assert.assertEquals("Cumulative vmem shouldn't have included new processes", Assert.assertEquals("Cumulative vmem shouldn't have included new processes",
@ -577,7 +577,7 @@ public class TestProcfsBasedProcessTree {
ProcfsBasedProcessTree processTree = createProcessTree( ProcfsBasedProcessTree processTree = createProcessTree(
"100", procfsRootDir.getAbsolutePath()); "100", procfsRootDir.getAbsolutePath());
// build the process tree. // build the process tree.
processTree.getProcessTree(); processTree.updateProcessTree();
// Get the process-tree dump // Get the process-tree dump
String processTreeDump = processTree.getProcessTreeDump(); String processTreeDump = processTree.getProcessTreeDump();

View File

@ -34,8 +34,7 @@ public class TestResourceCalculatorProcessTree {
super(pid); super(pid);
} }
public ResourceCalculatorProcessTree getProcessTree() { public void updateProcessTree() {
return this;
} }
public String getProcessTreeDump() { public String getProcessTreeDump() {

View File

@ -396,9 +396,7 @@ public class ContainersMonitorImpl extends AbstractService implements
LOG.debug("Constructing ProcessTree for : PID = " + pId LOG.debug("Constructing ProcessTree for : PID = " + pId
+ " ContainerId = " + containerId); + " ContainerId = " + containerId);
ResourceCalculatorProcessTree pTree = ptInfo.getProcessTree(); ResourceCalculatorProcessTree pTree = ptInfo.getProcessTree();
pTree = pTree.getProcessTree(); // get the updated process-tree pTree.updateProcessTree(); // update process-tree
ptInfo.setProcessTree(pTree); // update ptInfo with proces-tree of
// updated state
long currentVmemUsage = pTree.getCumulativeVmem(); long currentVmemUsage = pTree.getCumulativeVmem();
long currentPmemUsage = pTree.getCumulativeRssmem(); long currentPmemUsage = pTree.getCumulativeRssmem();
// as processes begin with an age 1, we want to see if there // as processes begin with an age 1, we want to see if there

View File

@ -134,7 +134,7 @@ public class TestContainersMonitor extends BaseContainerManagerTest {
ProcfsBasedProcessTree pTree = new ProcfsBasedProcessTree( ProcfsBasedProcessTree pTree = new ProcfsBasedProcessTree(
"100", "100",
procfsRootDir.getAbsolutePath()); procfsRootDir.getAbsolutePath());
pTree.getProcessTree(); pTree.updateProcessTree();
assertTrue("tree rooted at 100 should be over limit " + assertTrue("tree rooted at 100 should be over limit " +
"after first iteration.", "after first iteration.",
test.isProcessTreeOverLimit(pTree, "dummyId", limit)); test.isProcessTreeOverLimit(pTree, "dummyId", limit));
@ -142,13 +142,13 @@ public class TestContainersMonitor extends BaseContainerManagerTest {
// the tree rooted at 200 is initially below limit. // the tree rooted at 200 is initially below limit.
pTree = new ProcfsBasedProcessTree("200", pTree = new ProcfsBasedProcessTree("200",
procfsRootDir.getAbsolutePath()); procfsRootDir.getAbsolutePath());
pTree.getProcessTree(); pTree.updateProcessTree();
assertFalse("tree rooted at 200 shouldn't be over limit " + assertFalse("tree rooted at 200 shouldn't be over limit " +
"after one iteration.", "after one iteration.",
test.isProcessTreeOverLimit(pTree, "dummyId", limit)); test.isProcessTreeOverLimit(pTree, "dummyId", limit));
// second iteration - now the tree has been over limit twice, // second iteration - now the tree has been over limit twice,
// hence it should be declared over limit. // hence it should be declared over limit.
pTree.getProcessTree(); pTree.updateProcessTree();
assertTrue( assertTrue(
"tree rooted at 200 should be over limit after 2 iterations", "tree rooted at 200 should be over limit after 2 iterations",
test.isProcessTreeOverLimit(pTree, "dummyId", limit)); test.isProcessTreeOverLimit(pTree, "dummyId", limit));
@ -156,12 +156,12 @@ public class TestContainersMonitor extends BaseContainerManagerTest {
// the tree rooted at 600 is never over limit. // the tree rooted at 600 is never over limit.
pTree = new ProcfsBasedProcessTree("600", pTree = new ProcfsBasedProcessTree("600",
procfsRootDir.getAbsolutePath()); procfsRootDir.getAbsolutePath());
pTree.getProcessTree(); pTree.updateProcessTree();
assertFalse("tree rooted at 600 should never be over limit.", assertFalse("tree rooted at 600 should never be over limit.",
test.isProcessTreeOverLimit(pTree, "dummyId", limit)); test.isProcessTreeOverLimit(pTree, "dummyId", limit));
// another iteration does not make any difference. // another iteration does not make any difference.
pTree.getProcessTree(); pTree.updateProcessTree();
assertFalse("tree rooted at 600 should never be over limit.", assertFalse("tree rooted at 600 should never be over limit.",
test.isProcessTreeOverLimit(pTree, "dummyId", limit)); test.isProcessTreeOverLimit(pTree, "dummyId", limit));
} finally { } finally {