Пример #1
0
            /// <summary>Parse xml and instantiate the nested rule</summary>
            /// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.AllocationConfigurationException
            ///     "/>
            public override void InitializeFromXml(Element el)
            {
                NodeList elements = el.GetChildNodes();

                for (int i = 0; i < elements.GetLength(); i++)
                {
                    Node node = elements.Item(i);
                    if (node is Element)
                    {
                        Element element = (Element)node;
                        if ("rule".Equals(element.GetTagName()))
                        {
                            QueuePlacementRule rule = QueuePlacementPolicy.CreateAndInitializeRule(node);
                            if (rule == null)
                            {
                                throw new AllocationConfigurationException("Unable to create nested rule in nestedUserQueue rule"
                                                                           );
                            }
                            this.nestedRule = rule;
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                if (this.nestedRule == null)
                {
                    throw new AllocationConfigurationException("No nested rule specified in <nestedUserQueue> rule"
                                                               );
                }
                base.InitializeFromXml(el);
            }
Пример #2
0
        FromXml(Element el, IDictionary <FSQueueType, ICollection <string> > configuredQueues
                , Configuration conf)
        {
            IList <QueuePlacementRule> rules = new AList <QueuePlacementRule>();
            NodeList elements = el.GetChildNodes();

            for (int i = 0; i < elements.GetLength(); i++)
            {
                Node node = elements.Item(i);
                if (node is Element)
                {
                    QueuePlacementRule rule = CreateAndInitializeRule(node);
                    rules.AddItem(rule);
                }
            }
            return(new Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.QueuePlacementPolicy
                       (rules, configuredQueues, conf));
        }
Пример #3
0
        /// <summary>Create and initialize a rule given a xml node</summary>
        /// <param name="node"/>
        /// <returns>QueuePlacementPolicy</returns>
        /// <exception cref="AllocationConfigurationException"/>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.AllocationConfigurationException
        ///     "/>
        public static QueuePlacementRule CreateAndInitializeRule(Node node)
        {
            Element element  = (Element)node;
            string  ruleName = element.GetAttribute("name");

            if (string.Empty.Equals(ruleName))
            {
                throw new AllocationConfigurationException("No name provided for a " + "rule element"
                                                           );
            }
            Type clazz = ruleClasses[ruleName];

            if (clazz == null)
            {
                throw new AllocationConfigurationException("No rule class found for " + ruleName);
            }
            QueuePlacementRule rule = ReflectionUtils.NewInstance(clazz, null);

            rule.InitializeFromXml(element);
            return(rule);
        }