/// <summary>
 /// Create the ResourceCalculatorProcessTree rooted to specified process
 /// from the class name and configure it.
 /// </summary>
 /// <remarks>
 /// Create the ResourceCalculatorProcessTree rooted to specified process
 /// from the class name and configure it. If class name is null, this method
 /// will try and return a process tree plugin available for this system.
 /// </remarks>
 /// <param name="pid">process pid of the root of the process tree</param>
 /// <param name="clazz">class-name</param>
 /// <param name="conf">configure the plugin with this.</param>
 /// <returns>
 /// ResourceCalculatorProcessTree or null if ResourceCalculatorPluginTree
 /// is not available for this system.
 /// </returns>
 public static Org.Apache.Hadoop.Yarn.Util.ResourceCalculatorProcessTree GetResourceCalculatorProcessTree
     (string pid, Type clazz, Configuration conf)
 {
     if (clazz != null)
     {
         try
         {
             Constructor <Org.Apache.Hadoop.Yarn.Util.ResourceCalculatorProcessTree> c = clazz.
                                                                                         GetConstructor(typeof(string));
             Org.Apache.Hadoop.Yarn.Util.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
     if (ProcfsBasedProcessTree.IsAvailable())
     {
         return(new ProcfsBasedProcessTree(pid));
     }
     if (WindowsBasedProcessTree.IsAvailable())
     {
         return(new WindowsBasedProcessTree(pid));
     }
     // Not supported on this system.
     return(null);
 }
예제 #2
0
 public virtual void Tree()
 {
     if (!Shell.Windows)
     {
         Log.Info("Platform not Windows. Not testing");
         return;
     }
     NUnit.Framework.Assert.IsTrue("WindowsBasedProcessTree should be available on Windows"
                                   , WindowsBasedProcessTree.IsAvailable());
     TestWindowsBasedProcessTree.WindowsBasedProcessTreeTester pTree = new TestWindowsBasedProcessTree.WindowsBasedProcessTreeTester
                                                                           (this, "-1");
     pTree.infoStr = "3524,1024,1024,500\r\n2844,1024,1024,500\r\n";
     pTree.UpdateProcessTree();
     NUnit.Framework.Assert.IsTrue(pTree.GetVirtualMemorySize() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeVmem() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetVirtualMemorySize(0) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeVmem(0) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetRssMemorySize() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeRssmem() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetRssMemorySize(0) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeRssmem(0) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeCpuTime() == 1000);
     pTree.infoStr = "3524,1024,1024,1000\r\n2844,1024,1024,1000\r\n1234,1024,1024,1000\r\n";
     pTree.UpdateProcessTree();
     NUnit.Framework.Assert.IsTrue(pTree.GetVirtualMemorySize() == 3072);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeVmem() == 3072);
     NUnit.Framework.Assert.IsTrue(pTree.GetVirtualMemorySize(1) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeVmem(1) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetRssMemorySize() == 3072);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeRssmem() == 3072);
     NUnit.Framework.Assert.IsTrue(pTree.GetRssMemorySize(1) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeRssmem(1) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeCpuTime() == 3000);
     pTree.infoStr = "3524,1024,1024,1500\r\n2844,1024,1024,1500\r\n";
     pTree.UpdateProcessTree();
     NUnit.Framework.Assert.IsTrue(pTree.GetVirtualMemorySize() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeVmem() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetVirtualMemorySize(2) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeVmem(2) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetRssMemorySize() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeRssmem() == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetRssMemorySize(2) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeRssmem(2) == 2048);
     NUnit.Framework.Assert.IsTrue(pTree.GetCumulativeCpuTime() == 4000);
 }