ResourceCalculatorProcessTree extends Configured { public static ResourceCalculatorProcessTree getResourceCalculatorProcessTree( String pid, Class<? extends ResourceCalculatorProcessTree> clazz, Configuration conf) { if (clazz != null) { 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); } } if (ProcfsBasedProcessTree.isAvailable()) { return new ProcfsBasedProcessTree(pid); } if (WindowsBasedProcessTree.isAvailable()) { return new WindowsBasedProcessTree(pid); } return null; } ResourceCalculatorProcessTree(String root); abstract void updateProcessTree(); abstract String getProcessTreeDump(); long getVirtualMemorySize(); @Deprecated long getCumulativeVmem(); long getRssMemorySize(); @Deprecated long getCumulativeRssmem(); long getVirtualMemorySize(int olderThanAge); @Deprecated long getCumulativeVmem(int olderThanAge); long getRssMemorySize(int olderThanAge); @Deprecated long getCumulativeRssmem(int olderThanAge); long getCumulativeCpuTime(); float getCpuUsagePercent(); abstract boolean checkPidPgrpidForMatch(); static ResourceCalculatorProcessTree getResourceCalculatorProcessTree(
    String pid, Class<? extends ResourceCalculatorProcessTree> clazz, Configuration conf); static final int UNAVAILABLE; }
@Test public void testCreateInstance() { ResourceCalculatorProcessTree tree; tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, new Configuration()); assertNotNull(tree); assertThat(tree, instanceOf(EmptyProcessTree.class)); }
@Test public void testCreatedInstanceConfigured() { ResourceCalculatorProcessTree tree; Configuration conf = new Configuration(); tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, conf); assertNotNull(tree); assertThat(tree.getConf(), sameInstance(conf)); }