locked
Get a number of idle cores RRS feed

  • Question

  • Hi, all

    I'd like to calculate a number of idle and simultaneously on-line cores cores in some nodes group. I'm wonder that cores of off-line nodes are calculated as idle. Where is mistake?

     

                int MaxCores = 0;
                // Calculate a number of free cores in cluster
                IScheduler scheduler = new Scheduler();
                try
                {
                    scheduler.Connect("hnode");
                    foreach (ISchedulerNode node in scheduler.GetNodeList(null, null))
                    {
                        MaxCores += GetCoresNumber(node);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }


            private static int GetCoresNumber(ISchedulerNode node)
            {
                int result = 0;
                bool IfGroupEncoding = false;

                // If service is installed on this node
                foreach (string name in node.NodeGroups)
                {
                    if (name == "Encoding")
                    {
                        IfGroupEncoding = true;
                        break;
                    }
                }

                // Number of enabled cores in this node
                if (IfGroupEncoding)
                    foreach (ISchedulerCore core in node.GetCores())
                    {
                        if (SchedulerCoreState.Idle == core.State)
                            result++;
                    }
                return result;       
            }

    Wednesday, May 26, 2010 2:21 PM

Answers

All replies

  • The node was on-line but not reachable.

             {   ...

                int result = 0;
                bool IfGroupEncoding = false;

                // If node is reachable
                if (node.Reachable == true)
                {

                    // If service is installed on this node

                     ...

                    // Number of enabled cores in this node

                     ...

                 }

                return result;       
            }

    Wednesday, May 26, 2010 3:23 PM
  • Hi Kandaur,

    Does your second post resolve your problem? Please let us know if you still have trouble. thanks,

    Liwei

     

    Tuesday, June 8, 2010 8:57 PM
  • Hi Liwei,

    The trouble was solved.

    Thanks.

    Tuesday, October 26, 2010 5:26 PM