/// <summary>
        /// Checks whether making the application runnable would exceed any
        /// maxRunningApps limits.
        /// </summary>
        public virtual bool CanAppBeRunnable(FSQueue queue, string user)
        {
            AllocationConfiguration allocConf = scheduler.GetAllocationConfiguration();
            int userNumRunnable = usersNumRunnableApps[user];

            if (userNumRunnable == null)
            {
                userNumRunnable = 0;
            }
            if (userNumRunnable >= allocConf.GetUserMaxApps(user))
            {
                return(false);
            }
            // Check queue and all parent queues
            while (queue != null)
            {
                int queueMaxApps = allocConf.GetQueueMaxApps(queue.GetName());
                if (queue.GetNumRunnableApps() >= queueMaxApps)
                {
                    return(false);
                }
                queue = queue.GetParent();
            }
            return(true);
        }
Exemple #2
0
        public virtual void TestReloadTurnsLeafToParentWithNoLeaf()
        {
            AllocationConfiguration allocConf = new AllocationConfiguration(conf);

            // Create a leaf queue1
            allocConf.configuredQueues[FSQueueType.Leaf].AddItem("root.queue1");
            queueManager.UpdateAllocationConfiguration(allocConf);
            NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("root.queue1", false));
            // Lets say later on admin makes queue1 a parent queue by
            // specifying "type=parent" in the alloc xml and lets say apps running in
            // queue1
            notEmptyQueues.AddItem(queueManager.GetLeafQueue("root.queue1", false));
            allocConf = new AllocationConfiguration(conf);
            allocConf.configuredQueues[FSQueueType.Parent].AddItem("root.queue1");
            // When allocs are reloaded queue1 shouldn't be converter to parent
            queueManager.UpdateAllocationConfiguration(allocConf);
            NUnit.Framework.Assert.IsNotNull(queueManager.GetLeafQueue("root.queue1", false));
            NUnit.Framework.Assert.IsNull(queueManager.GetParentQueue("root.queue1", false));
            // Now lets assume apps completed and there are no apps in queue1
            notEmptyQueues.Clear();
            // We should see queue1 transform from leaf queue to parent queue.
            queueManager.UpdateAllocationConfiguration(allocConf);
            NUnit.Framework.Assert.IsNull(queueManager.GetLeafQueue("root.queue1", false));
            NUnit.Framework.Assert.IsNotNull(queueManager.GetParentQueue("root.queue1", false
                                                                         ));
            // this parent should not have any children
            NUnit.Framework.Assert.IsTrue(queueManager.GetParentQueue("root.queue1", false).GetChildQueues
                                              ().IsEmpty());
        }
        public virtual void TestSimplePlacementPolicyFromConf()
        {
            Configuration conf = new Configuration();

            conf.Set(FairSchedulerConfiguration.AllocationFile, AllocFile);
            conf.SetBoolean(FairSchedulerConfiguration.AllowUndeclaredPools, false);
            conf.SetBoolean(FairSchedulerConfiguration.UserAsDefaultQueue, false);
            PrintWriter @out = new PrintWriter(new FileWriter(AllocFile));

            @out.WriteLine("<?xml version=\"1.0\"?>");
            @out.WriteLine("<allocations>");
            @out.WriteLine("</allocations>");
            @out.Close();
            AllocationFileLoaderService allocLoader = new AllocationFileLoaderService();

            allocLoader.Init(conf);
            TestAllocationFileLoaderService.ReloadListener confHolder = new TestAllocationFileLoaderService.ReloadListener
                                                                            (this);
            allocLoader.SetReloadListener(confHolder);
            allocLoader.ReloadAllocations();
            AllocationConfiguration    allocConf       = confHolder.allocConf;
            QueuePlacementPolicy       placementPolicy = allocConf.GetPlacementPolicy();
            IList <QueuePlacementRule> rules           = placementPolicy.GetRules();

            NUnit.Framework.Assert.AreEqual(2, rules.Count);
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.Specified), rules[0].GetType
                                                ());
            NUnit.Framework.Assert.AreEqual(false, rules[0].create);
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.Default), rules[1].GetType
                                                ());
        }
Exemple #4
0
        private void UpdateConfiguredLeafQueues(QueueManager queueMgr, params string[] confLeafQueues
                                                )
        {
            AllocationConfiguration allocConf = new AllocationConfiguration(conf);

            Sharpen.Collections.AddAll(allocConf.configuredQueues[FSQueueType.Leaf], Sets.NewHashSet
                                           (confLeafQueues));
            queueMgr.UpdateAllocationConfiguration(allocConf);
        }
        /// <summary>
        /// Checks to see whether any other applications runnable now that the given
        /// application has been removed from the given queue.
        /// </summary>
        /// <remarks>
        /// Checks to see whether any other applications runnable now that the given
        /// application has been removed from the given queue.  And makes them so.
        /// Runs in O(n log(n)) where n is the number of queues that are under the
        /// highest queue that went from having no slack to having slack.
        /// </remarks>
        public virtual void UpdateRunnabilityOnAppRemoval(FSAppAttempt app, FSLeafQueue queue
                                                          )
        {
            AllocationConfiguration allocConf = scheduler.GetAllocationConfiguration();
            // childqueueX might have no pending apps itself, but if a queue higher up
            // in the hierarchy parentqueueY has a maxRunningApps set, an app completion
            // in childqueueX could allow an app in some other distant child of
            // parentqueueY to become runnable.
            // An app removal will only possibly allow another app to become runnable if
            // the queue was already at its max before the removal.
            // Thus we find the ancestor queue highest in the tree for which the app
            // that was at its maxRunningApps before the removal.
            FSQueue highestQueueWithAppsNowRunnable = (queue.GetNumRunnableApps() == allocConf
                                                       .GetQueueMaxApps(queue.GetName()) - 1) ? queue : null;
            FSParentQueue parent = queue.GetParent();

            while (parent != null)
            {
                if (parent.GetNumRunnableApps() == allocConf.GetQueueMaxApps(parent.GetName()) -
                    1)
                {
                    highestQueueWithAppsNowRunnable = parent;
                }
                parent = parent.GetParent();
            }
            IList <IList <FSAppAttempt> > appsNowMaybeRunnable = new AList <IList <FSAppAttempt> >(
                );

            // Compile lists of apps which may now be runnable
            // We gather lists instead of building a set of all non-runnable apps so
            // that this whole operation can be O(number of queues) instead of
            // O(number of apps)
            if (highestQueueWithAppsNowRunnable != null)
            {
                GatherPossiblyRunnableAppLists(highestQueueWithAppsNowRunnable, appsNowMaybeRunnable
                                               );
            }
            string user           = app.GetUser();
            int    userNumRunning = usersNumRunnableApps[user];

            if (userNumRunning == null)
            {
                userNumRunning = 0;
            }
            if (userNumRunning == allocConf.GetUserMaxApps(user) - 1)
            {
                IList <FSAppAttempt> userWaitingApps = usersNonRunnableApps.Get(user);
                if (userWaitingApps != null)
                {
                    appsNowMaybeRunnable.AddItem(userWaitingApps);
                }
            }
            UpdateAppsRunnability(appsNowMaybeRunnable, appsNowMaybeRunnable.Count);
        }
        public virtual void TestReservableQueue()
        {
            Configuration conf = new Configuration();

            conf.Set(FairSchedulerConfiguration.AllocationFile, AllocFile);
            PrintWriter @out = new PrintWriter(new FileWriter(AllocFile));

            @out.WriteLine("<?xml version=\"1.0\"?>");
            @out.WriteLine("<allocations>");
            @out.WriteLine("<queue name=\"reservable\">");
            @out.WriteLine("<reservation>");
            @out.WriteLine("</reservation>");
            @out.WriteLine("</queue>");
            @out.WriteLine("<queue name=\"other\">");
            @out.WriteLine("</queue>");
            @out.WriteLine("<reservation-agent>DummyAgentName</reservation-agent>");
            @out.WriteLine("<reservation-policy>AnyAdmissionPolicy</reservation-policy>");
            @out.WriteLine("</allocations>");
            @out.Close();
            AllocationFileLoaderService allocLoader = new AllocationFileLoaderService();

            allocLoader.Init(conf);
            TestAllocationFileLoaderService.ReloadListener confHolder = new TestAllocationFileLoaderService.ReloadListener
                                                                            (this);
            allocLoader.SetReloadListener(confHolder);
            allocLoader.ReloadAllocations();
            AllocationConfiguration allocConf = confHolder.allocConf;
            string reservableQueueName        = "root.reservable";
            string nonreservableQueueName     = "root.other";

            NUnit.Framework.Assert.IsFalse(allocConf.IsReservable(nonreservableQueueName));
            NUnit.Framework.Assert.IsTrue(allocConf.IsReservable(reservableQueueName));
            NUnit.Framework.Assert.IsTrue(allocConf.GetMoveOnExpiry(reservableQueueName));
            NUnit.Framework.Assert.AreEqual(ReservationSchedulerConfiguration.DefaultReservationWindow
                                            , allocConf.GetReservationWindow(reservableQueueName));
            NUnit.Framework.Assert.AreEqual(100, allocConf.GetInstantaneousMaxCapacity(reservableQueueName
                                                                                       ), 0.0001);
            NUnit.Framework.Assert.AreEqual("DummyAgentName", allocConf.GetReservationAgent(reservableQueueName
                                                                                            ));
            NUnit.Framework.Assert.AreEqual(100, allocConf.GetAverageCapacity(reservableQueueName
                                                                              ), 0.001);
            NUnit.Framework.Assert.IsFalse(allocConf.GetShowReservationAsQueues(reservableQueueName
                                                                                ));
            NUnit.Framework.Assert.AreEqual("AnyAdmissionPolicy", allocConf.GetReservationAdmissionPolicy
                                                (reservableQueueName));
            NUnit.Framework.Assert.AreEqual(ReservationSchedulerConfiguration.DefaultReservationPlannerName
                                            , allocConf.GetReplanner(reservableQueueName));
            NUnit.Framework.Assert.AreEqual(ReservationSchedulerConfiguration.DefaultReservationEnforcementWindow
                                            , allocConf.GetEnforcementWindow(reservableQueueName));
        }
Exemple #7
0
        public virtual void SetUp()
        {
            conf = new FairSchedulerConfiguration();
            FairScheduler           scheduler = Org.Mockito.Mockito.Mock <FairScheduler>();
            AllocationConfiguration allocConf = new AllocationConfiguration(conf);

            Org.Mockito.Mockito.When(scheduler.GetAllocationConfiguration()).ThenReturn(allocConf
                                                                                        );
            Org.Mockito.Mockito.When(scheduler.GetConf()).ThenReturn(conf);
            SystemClock clock = new SystemClock();

            Org.Mockito.Mockito.When(scheduler.GetClock()).ThenReturn(clock);
            notEmptyQueues = new HashSet <FSQueue>();
            queueManager   = new _QueueManager_47(this, scheduler);
            FSQueueMetrics.ForQueue("root", null, true, conf);
            queueManager.Initialize(conf);
        }
Exemple #8
0
 public virtual void UpdateAllocationConfiguration(AllocationConfiguration queueConf
                                                   )
 {
     // Create leaf queues and the parent queues in a leaf's ancestry if they do not exist
     foreach (string name in queueConf.GetConfiguredQueues()[FSQueueType.Leaf])
     {
         if (RemoveEmptyIncompatibleQueues(name, FSQueueType.Leaf))
         {
             GetLeafQueue(name, true);
         }
     }
     // At this point all leaves and 'parents with at least one child' would have been created.
     // Now create parents with no configured leaf.
     foreach (string name_1 in queueConf.GetConfiguredQueues()[FSQueueType.Parent])
     {
         if (RemoveEmptyIncompatibleQueues(name_1, FSQueueType.Parent))
         {
             GetParentQueue(name_1, true);
         }
     }
     foreach (FSQueue queue in queues.Values)
     {
         // Update queue metrics
         FSQueueMetrics queueMetrics = queue.GetMetrics();
         queueMetrics.SetMinShare(queue.GetMinShare());
         queueMetrics.SetMaxShare(queue.GetMaxShare());
         // Set scheduling policies
         try
         {
             SchedulingPolicy policy = queueConf.GetSchedulingPolicy(queue.GetName());
             policy.Initialize(scheduler.GetClusterResource());
             queue.SetPolicy(policy);
         }
         catch (AllocationConfigurationException ex)
         {
             Log.Warn("Cannot apply configured scheduling policy to queue " + queue.GetName(),
                      ex);
         }
     }
     // Update steady fair shares for all queues
     rootQueue.RecomputeSteadyShares();
     // Update the fair share preemption timeouts and preemption for all queues
     // recursively
     rootQueue.UpdatePreemptionVariables();
 }
        public virtual void Setup()
        {
            Configuration conf = new Configuration();

            clock     = new FairSchedulerTestBase.MockClock();
            scheduler = Org.Mockito.Mockito.Mock <FairScheduler>();
            Org.Mockito.Mockito.When(scheduler.GetConf()).ThenReturn(new FairSchedulerConfiguration
                                                                         (conf));
            Org.Mockito.Mockito.When(scheduler.GetClock()).ThenReturn(clock);
            AllocationConfiguration allocConf = new AllocationConfiguration(conf);

            Org.Mockito.Mockito.When(scheduler.GetAllocationConfiguration()).ThenReturn(allocConf
                                                                                        );
            queueManager = new QueueManager(scheduler);
            queueManager.Initialize(conf);
            queueMaxApps    = allocConf.queueMaxApps;
            userMaxApps     = allocConf.userMaxApps;
            maxAppsEnforcer = new MaxRunningAppsEnforcer(scheduler);
            appNum          = 0;
            rmContext       = Org.Mockito.Mockito.Mock <RMContext>();
            Org.Mockito.Mockito.When(rmContext.GetEpoch()).ThenReturn(0L);
        }
 /// <summary>Updates the allocation list from the allocation config file.</summary>
 /// <remarks>
 /// Updates the allocation list from the allocation config file. This file is
 /// expected to be in the XML format specified in the design doc.
 /// </remarks>
 /// <exception cref="System.IO.IOException">if the config file cannot be read.</exception>
 /// <exception cref="AllocationConfigurationException">if allocations are invalid.</exception>
 /// <exception cref="Javax.Xml.Parsers.ParserConfigurationException">if XML parser is misconfigured.
 ///     </exception>
 /// <exception cref="Org.Xml.Sax.SAXException">if config file is malformed.</exception>
 /// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.AllocationConfigurationException
 ///     "/>
 public virtual void ReloadAllocations()
 {
     lock (this)
     {
         if (allocFile == null)
         {
             return;
         }
         Log.Info("Loading allocation file " + allocFile);
         // Create some temporary hashmaps to hold the new allocs, and we only save
         // them in our fields if we have parsed the entire allocs file successfully.
         IDictionary <string, Resource> minQueueResources = new Dictionary <string, Resource
                                                                            >();
         IDictionary <string, Resource> maxQueueResources = new Dictionary <string, Resource
                                                                            >();
         IDictionary <string, int>             queueMaxApps     = new Dictionary <string, int>();
         IDictionary <string, int>             userMaxApps      = new Dictionary <string, int>();
         IDictionary <string, float>           queueMaxAMShares = new Dictionary <string, float>();
         IDictionary <string, ResourceWeights> queueWeights     = new Dictionary <string, ResourceWeights
                                                                                  >();
         IDictionary <string, SchedulingPolicy> queuePolicies = new Dictionary <string, SchedulingPolicy
                                                                                >();
         IDictionary <string, long> minSharePreemptionTimeouts = new Dictionary <string, long
                                                                                 >();
         IDictionary <string, long> fairSharePreemptionTimeouts = new Dictionary <string, long
                                                                                  >();
         IDictionary <string, float> fairSharePreemptionThresholds = new Dictionary <string,
                                                                                     float>();
         IDictionary <string, IDictionary <QueueACL, AccessControlList> > queueAcls = new Dictionary
                                                                                      <string, IDictionary <QueueACL, AccessControlList> >();
         ICollection <string> reservableQueues                = new HashSet <string>();
         int              userMaxAppsDefault                  = int.MaxValue;
         int              queueMaxAppsDefault                 = int.MaxValue;
         float            queueMaxAMShareDefault              = 0.5f;
         long             defaultFairSharePreemptionTimeout   = long.MaxValue;
         long             defaultMinSharePreemptionTimeout    = long.MaxValue;
         float            defaultFairSharePreemptionThreshold = 0.5f;
         SchedulingPolicy defaultSchedPolicy                  = SchedulingPolicy.DefaultPolicy;
         // Reservation global configuration knobs
         string planner                          = null;
         string reservationAgent                 = null;
         string reservationAdmissionPolicy       = null;
         QueuePlacementPolicy newPlacementPolicy = null;
         // Remember all queue names so we can display them on web UI, etc.
         // configuredQueues is segregated based on whether it is a leaf queue
         // or a parent queue. This information is used for creating queues
         // and also for making queue placement decisions(QueuePlacementRule.java).
         IDictionary <FSQueueType, ICollection <string> > configuredQueues = new Dictionary <FSQueueType
                                                                                             , ICollection <string> >();
         foreach (FSQueueType queueType in FSQueueType.Values())
         {
             configuredQueues[queueType] = new HashSet <string>();
         }
         // Read and parse the allocations file.
         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.NewInstance();
         docBuilderFactory.SetIgnoringComments(true);
         DocumentBuilder builder = docBuilderFactory.NewDocumentBuilder();
         Document        doc     = builder.Parse(allocFile);
         Element         root    = doc.GetDocumentElement();
         if (!"allocations".Equals(root.GetTagName()))
         {
             throw new AllocationConfigurationException("Bad fair scheduler config " + "file: top-level element not <allocations>"
                                                        );
         }
         NodeList        elements               = root.GetChildNodes();
         IList <Element> queueElements          = new AList <Element>();
         Element         placementPolicyElement = null;
         for (int i = 0; i < elements.GetLength(); i++)
         {
             Node node = elements.Item(i);
             if (node is Element)
             {
                 Element element = (Element)node;
                 if ("queue".Equals(element.GetTagName()) || "pool".Equals(element.GetTagName()))
                 {
                     queueElements.AddItem(element);
                 }
                 else
                 {
                     if ("user".Equals(element.GetTagName()))
                     {
                         string   userName = element.GetAttribute("name");
                         NodeList fields   = element.GetChildNodes();
                         for (int j = 0; j < fields.GetLength(); j++)
                         {
                             Node fieldNode = fields.Item(j);
                             if (!(fieldNode is Element))
                             {
                                 continue;
                             }
                             Element field = (Element)fieldNode;
                             if ("maxRunningApps".Equals(field.GetTagName()))
                             {
                                 string text = ((Text)field.GetFirstChild()).GetData().Trim();
                                 int    val  = System.Convert.ToInt32(text);
                                 userMaxApps[userName] = val;
                             }
                         }
                     }
                     else
                     {
                         if ("userMaxAppsDefault".Equals(element.GetTagName()))
                         {
                             string text = ((Text)element.GetFirstChild()).GetData().Trim();
                             int    val  = System.Convert.ToInt32(text);
                             userMaxAppsDefault = val;
                         }
                         else
                         {
                             if ("defaultFairSharePreemptionTimeout".Equals(element.GetTagName()))
                             {
                                 string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                 long   val  = long.Parse(text) * 1000L;
                                 defaultFairSharePreemptionTimeout = val;
                             }
                             else
                             {
                                 if ("fairSharePreemptionTimeout".Equals(element.GetTagName()))
                                 {
                                     if (defaultFairSharePreemptionTimeout == long.MaxValue)
                                     {
                                         string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                         long   val  = long.Parse(text) * 1000L;
                                         defaultFairSharePreemptionTimeout = val;
                                     }
                                 }
                                 else
                                 {
                                     if ("defaultMinSharePreemptionTimeout".Equals(element.GetTagName()))
                                     {
                                         string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                         long   val  = long.Parse(text) * 1000L;
                                         defaultMinSharePreemptionTimeout = val;
                                     }
                                     else
                                     {
                                         if ("defaultFairSharePreemptionThreshold".Equals(element.GetTagName()))
                                         {
                                             string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                             float  val  = float.ParseFloat(text);
                                             val = Math.Max(Math.Min(val, 1.0f), 0.0f);
                                             defaultFairSharePreemptionThreshold = val;
                                         }
                                         else
                                         {
                                             if ("queueMaxAppsDefault".Equals(element.GetTagName()))
                                             {
                                                 string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                                 int    val  = System.Convert.ToInt32(text);
                                                 queueMaxAppsDefault = val;
                                             }
                                             else
                                             {
                                                 if ("queueMaxAMShareDefault".Equals(element.GetTagName()))
                                                 {
                                                     string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                                     float  val  = float.ParseFloat(text);
                                                     val = Math.Min(val, 1.0f);
                                                     queueMaxAMShareDefault = val;
                                                 }
                                                 else
                                                 {
                                                     if ("defaultQueueSchedulingPolicy".Equals(element.GetTagName()) || "defaultQueueSchedulingMode"
                                                         .Equals(element.GetTagName()))
                                                     {
                                                         string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                                         defaultSchedPolicy = SchedulingPolicy.Parse(text);
                                                     }
                                                     else
                                                     {
                                                         if ("queuePlacementPolicy".Equals(element.GetTagName()))
                                                         {
                                                             placementPolicyElement = element;
                                                         }
                                                         else
                                                         {
                                                             if ("reservation-planner".Equals(element.GetTagName()))
                                                             {
                                                                 string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                                                 planner = text;
                                                             }
                                                             else
                                                             {
                                                                 if ("reservation-agent".Equals(element.GetTagName()))
                                                                 {
                                                                     string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                                                     reservationAgent = text;
                                                                 }
                                                                 else
                                                                 {
                                                                     if ("reservation-policy".Equals(element.GetTagName()))
                                                                     {
                                                                         string text = ((Text)element.GetFirstChild()).GetData().Trim();
                                                                         reservationAdmissionPolicy = text;
                                                                     }
                                                                     else
                                                                     {
                                                                         Log.Warn("Bad element in allocations file: " + element.GetTagName());
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Load queue elements.  A root queue can either be included or omitted.  If
         // it's included, all other queues must be inside it.
         foreach (Element element_1 in queueElements)
         {
             string parent = "root";
             if (Sharpen.Runtime.EqualsIgnoreCase(element_1.GetAttribute("name"), "root"))
             {
                 if (queueElements.Count > 1)
                 {
                     throw new AllocationConfigurationException("If configuring root queue," + " no other queues can be placed alongside it."
                                                                );
                 }
                 parent = null;
             }
             LoadQueue(parent, element_1, minQueueResources, maxQueueResources, queueMaxApps,
                       userMaxApps, queueMaxAMShares, queueWeights, queuePolicies, minSharePreemptionTimeouts
                       , fairSharePreemptionTimeouts, fairSharePreemptionThresholds, queueAcls, configuredQueues
                       , reservableQueues);
         }
         // Load placement policy and pass it configured queues
         Configuration conf = GetConfig();
         if (placementPolicyElement != null)
         {
             newPlacementPolicy = QueuePlacementPolicy.FromXml(placementPolicyElement, configuredQueues
                                                               , conf);
         }
         else
         {
             newPlacementPolicy = QueuePlacementPolicy.FromConfiguration(conf, configuredQueues
                                                                         );
         }
         // Set the min/fair share preemption timeout for the root queue
         if (!minSharePreemptionTimeouts.Contains(QueueManager.RootQueue))
         {
             minSharePreemptionTimeouts[QueueManager.RootQueue] = defaultMinSharePreemptionTimeout;
         }
         if (!fairSharePreemptionTimeouts.Contains(QueueManager.RootQueue))
         {
             fairSharePreemptionTimeouts[QueueManager.RootQueue] = defaultFairSharePreemptionTimeout;
         }
         // Set the fair share preemption threshold for the root queue
         if (!fairSharePreemptionThresholds.Contains(QueueManager.RootQueue))
         {
             fairSharePreemptionThresholds[QueueManager.RootQueue] = defaultFairSharePreemptionThreshold;
         }
         ReservationQueueConfiguration globalReservationQueueConfig = new ReservationQueueConfiguration
                                                                          ();
         if (planner != null)
         {
             globalReservationQueueConfig.SetPlanner(planner);
         }
         if (reservationAdmissionPolicy != null)
         {
             globalReservationQueueConfig.SetReservationAdmissionPolicy(reservationAdmissionPolicy
                                                                        );
         }
         if (reservationAgent != null)
         {
             globalReservationQueueConfig.SetReservationAgent(reservationAgent);
         }
         AllocationConfiguration info = new AllocationConfiguration(minQueueResources, maxQueueResources
                                                                    , queueMaxApps, userMaxApps, queueWeights, queueMaxAMShares, userMaxAppsDefault,
                                                                    queueMaxAppsDefault, queueMaxAMShareDefault, queuePolicies, defaultSchedPolicy,
                                                                    minSharePreemptionTimeouts, fairSharePreemptionTimeouts, fairSharePreemptionThresholds
                                                                    , queueAcls, newPlacementPolicy, configuredQueues, globalReservationQueueConfig,
                                                                    reservableQueues);
         lastSuccessfulReload    = clock.GetTime();
         lastReloadAttemptFailed = false;
         reloadListener.OnReload(info);
     }
 }
Exemple #11
0
        /// <summary>
        /// Creates a leaf or parent queue based on what is specified in 'queueType'
        /// and places it in the tree.
        /// </summary>
        /// <remarks>
        /// Creates a leaf or parent queue based on what is specified in 'queueType'
        /// and places it in the tree. Creates any parents that don't already exist.
        /// </remarks>
        /// <returns>
        /// the created queue, if successful. null if not allowed (one of the parent
        /// queues in the queue name is already a leaf queue)
        /// </returns>
        private FSQueue CreateQueue(string name, FSQueueType queueType)
        {
            IList <string> newQueueNames = new AList <string>();

            newQueueNames.AddItem(name);
            int           sepIndex = name.Length;
            FSParentQueue parent   = null;

            // Move up the queue tree until we reach one that exists.
            while (sepIndex != -1)
            {
                sepIndex = name.LastIndexOf('.', sepIndex - 1);
                FSQueue queue;
                string  curName = null;
                curName = Sharpen.Runtime.Substring(name, 0, sepIndex);
                queue   = queues[curName];
                if (queue == null)
                {
                    newQueueNames.AddItem(curName);
                }
                else
                {
                    if (queue is FSParentQueue)
                    {
                        parent = (FSParentQueue)queue;
                        break;
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            // At this point, parent refers to the deepest existing parent of the
            // queue to create.
            // Now that we know everything worked out, make all the queues
            // and add them to the map.
            AllocationConfiguration queueConf = scheduler.GetAllocationConfiguration();
            FSLeafQueue             leafQueue = null;

            for (int i = newQueueNames.Count - 1; i >= 0; i--)
            {
                string queueName = newQueueNames[i];
                if (i == 0 && queueType != FSQueueType.Parent)
                {
                    leafQueue = new FSLeafQueue(name, scheduler, parent);
                    try
                    {
                        leafQueue.SetPolicy(queueConf.GetDefaultSchedulingPolicy());
                    }
                    catch (AllocationConfigurationException ex)
                    {
                        Log.Warn("Failed to set default scheduling policy " + queueConf.GetDefaultSchedulingPolicy
                                     () + " on new leaf queue.", ex);
                    }
                    parent.AddChildQueue(leafQueue);
                    queues[leafQueue.GetName()] = leafQueue;
                    leafQueues.AddItem(leafQueue);
                    leafQueue.UpdatePreemptionVariables();
                    return(leafQueue);
                }
                else
                {
                    FSParentQueue newParent = new FSParentQueue(queueName, scheduler, parent);
                    try
                    {
                        newParent.SetPolicy(queueConf.GetDefaultSchedulingPolicy());
                    }
                    catch (AllocationConfigurationException ex)
                    {
                        Log.Warn("Failed to set default scheduling policy " + queueConf.GetDefaultSchedulingPolicy
                                     () + " on new parent queue.", ex);
                    }
                    parent.AddChildQueue(newParent);
                    queues[newParent.GetName()] = newParent;
                    newParent.UpdatePreemptionVariables();
                    parent = newParent;
                }
            }
            return(parent);
        }
 public virtual void OnReload(AllocationConfiguration info)
 {
     this.allocConf = info;
 }
        /// <exception cref="System.Exception"/>
        public virtual void TestReload()
        {
            PrintWriter @out = new PrintWriter(new FileWriter(AllocFile));

            @out.WriteLine("<?xml version=\"1.0\"?>");
            @out.WriteLine("<allocations>");
            @out.WriteLine("  <queue name=\"queueA\">");
            @out.WriteLine("    <maxRunningApps>1</maxRunningApps>");
            @out.WriteLine("  </queue>");
            @out.WriteLine("  <queue name=\"queueB\" />");
            @out.WriteLine("  <queuePlacementPolicy>");
            @out.WriteLine("    <rule name='default' />");
            @out.WriteLine("  </queuePlacementPolicy>");
            @out.WriteLine("</allocations>");
            @out.Close();
            TestAllocationFileLoaderService.MockClock clock = new TestAllocationFileLoaderService.MockClock
                                                                  (this);
            Configuration conf = new Configuration();

            conf.Set(FairSchedulerConfiguration.AllocationFile, AllocFile);
            AllocationFileLoaderService allocLoader = new AllocationFileLoaderService(clock);

            allocLoader.reloadIntervalMs = 5;
            allocLoader.Init(conf);
            TestAllocationFileLoaderService.ReloadListener confHolder = new TestAllocationFileLoaderService.ReloadListener
                                                                            (this);
            allocLoader.SetReloadListener(confHolder);
            allocLoader.ReloadAllocations();
            AllocationConfiguration allocConf = confHolder.allocConf;
            // Verify conf
            QueuePlacementPolicy       policy = allocConf.GetPlacementPolicy();
            IList <QueuePlacementRule> rules  = policy.GetRules();

            NUnit.Framework.Assert.AreEqual(1, rules.Count);
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.Default), rules[0].GetType
                                                ());
            NUnit.Framework.Assert.AreEqual(1, allocConf.GetQueueMaxApps("root.queueA"));
            NUnit.Framework.Assert.AreEqual(2, allocConf.GetConfiguredQueues()[FSQueueType.Leaf
                                            ].Count);
            NUnit.Framework.Assert.IsTrue(allocConf.GetConfiguredQueues()[FSQueueType.Leaf].Contains
                                              ("root.queueA"));
            NUnit.Framework.Assert.IsTrue(allocConf.GetConfiguredQueues()[FSQueueType.Leaf].Contains
                                              ("root.queueB"));
            confHolder.allocConf = null;
            // Modify file and advance the clock
            @out = new PrintWriter(new FileWriter(AllocFile));
            @out.WriteLine("<?xml version=\"1.0\"?>");
            @out.WriteLine("<allocations>");
            @out.WriteLine("  <queue name=\"queueB\">");
            @out.WriteLine("    <maxRunningApps>3</maxRunningApps>");
            @out.WriteLine("  </queue>");
            @out.WriteLine("  <queuePlacementPolicy>");
            @out.WriteLine("    <rule name='specified' />");
            @out.WriteLine("    <rule name='nestedUserQueue' >");
            @out.WriteLine("         <rule name='primaryGroup' />");
            @out.WriteLine("    </rule>");
            @out.WriteLine("    <rule name='default' />");
            @out.WriteLine("  </queuePlacementPolicy>");
            @out.WriteLine("</allocations>");
            @out.Close();
            clock.Tick(Runtime.CurrentTimeMillis() + AllocationFileLoaderService.AllocReloadWaitMs
                       + 10000);
            allocLoader.Start();
            while (confHolder.allocConf == null)
            {
                Sharpen.Thread.Sleep(20);
            }
            // Verify conf
            allocConf = confHolder.allocConf;
            policy    = allocConf.GetPlacementPolicy();
            rules     = policy.GetRules();
            NUnit.Framework.Assert.AreEqual(3, rules.Count);
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.Specified), rules[0].GetType
                                                ());
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.NestedUserQueue), rules
                                            [1].GetType());
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.PrimaryGroup), ((QueuePlacementRule.NestedUserQueue
                                                                                       )(rules[1])).nestedRule.GetType());
            NUnit.Framework.Assert.AreEqual(typeof(QueuePlacementRule.Default), rules[2].GetType
                                                ());
            NUnit.Framework.Assert.AreEqual(3, allocConf.GetQueueMaxApps("root.queueB"));
            NUnit.Framework.Assert.AreEqual(1, allocConf.GetConfiguredQueues()[FSQueueType.Leaf
                                            ].Count);
            NUnit.Framework.Assert.IsTrue(allocConf.GetConfiguredQueues()[FSQueueType.Leaf].Contains
                                              ("root.queueB"));
        }
        public virtual void TestBackwardsCompatibleAllocationFileParsing()
        {
            Configuration conf = new Configuration();

            conf.Set(FairSchedulerConfiguration.AllocationFile, AllocFile);
            AllocationFileLoaderService allocLoader = new AllocationFileLoaderService();
            PrintWriter @out = new PrintWriter(new FileWriter(AllocFile));

            @out.WriteLine("<?xml version=\"1.0\"?>");
            @out.WriteLine("<allocations>");
            // Give queue A a minimum of 1024 M
            @out.WriteLine("<pool name=\"queueA\">");
            @out.WriteLine("<minResources>1024mb,0vcores</minResources>");
            @out.WriteLine("</pool>");
            // Give queue B a minimum of 2048 M
            @out.WriteLine("<pool name=\"queueB\">");
            @out.WriteLine("<minResources>2048mb,0vcores</minResources>");
            @out.WriteLine("<aclAdministerApps>alice,bob admins</aclAdministerApps>");
            @out.WriteLine("</pool>");
            // Give queue C no minimum
            @out.WriteLine("<pool name=\"queueC\">");
            @out.WriteLine("<aclSubmitApps>alice,bob admins</aclSubmitApps>");
            @out.WriteLine("</pool>");
            // Give queue D a limit of 3 running apps
            @out.WriteLine("<pool name=\"queueD\">");
            @out.WriteLine("<maxRunningApps>3</maxRunningApps>");
            @out.WriteLine("</pool>");
            // Give queue E a preemption timeout of one minute and 0.3f threshold
            @out.WriteLine("<pool name=\"queueE\">");
            @out.WriteLine("<minSharePreemptionTimeout>60</minSharePreemptionTimeout>");
            @out.WriteLine("<fairSharePreemptionThreshold>0.3</fairSharePreemptionThreshold>"
                           );
            @out.WriteLine("</pool>");
            // Set default limit of apps per queue to 15
            @out.WriteLine("<queueMaxAppsDefault>15</queueMaxAppsDefault>");
            // Set default limit of apps per user to 5
            @out.WriteLine("<userMaxAppsDefault>5</userMaxAppsDefault>");
            // Give user1 a limit of 10 jobs
            @out.WriteLine("<user name=\"user1\">");
            @out.WriteLine("<maxRunningApps>10</maxRunningApps>");
            @out.WriteLine("</user>");
            // Set default min share preemption timeout to 2 minutes
            @out.WriteLine("<defaultMinSharePreemptionTimeout>120" + "</defaultMinSharePreemptionTimeout>"
                           );
            // Set fair share preemption timeout to 5 minutes
            @out.WriteLine("<fairSharePreemptionTimeout>300</fairSharePreemptionTimeout>");
            // Set default fair share preemption threshold to 0.6f
            @out.WriteLine("<defaultFairSharePreemptionThreshold>0.6</defaultFairSharePreemptionThreshold>"
                           );
            @out.WriteLine("</allocations>");
            @out.Close();
            allocLoader.Init(conf);
            TestAllocationFileLoaderService.ReloadListener confHolder = new TestAllocationFileLoaderService.ReloadListener
                                                                            (this);
            allocLoader.SetReloadListener(confHolder);
            allocLoader.ReloadAllocations();
            AllocationConfiguration queueConf = confHolder.allocConf;

            NUnit.Framework.Assert.AreEqual(5, queueConf.GetConfiguredQueues()[FSQueueType.Leaf
                                            ].Count);
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root." + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root." + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(1024, 0), queueConf.GetMinResources
                                                ("root.queueA"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(2048, 0), queueConf.GetMinResources
                                                ("root.queueB"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root.queueC"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root.queueD"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root.queueE"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root." + YarnConfiguration
                                                                          .DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueA"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueB"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueC"));
            NUnit.Framework.Assert.AreEqual(3, queueConf.GetQueueMaxApps("root.queueD"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueE"));
            NUnit.Framework.Assert.AreEqual(10, queueConf.GetUserMaxApps("user1"));
            NUnit.Framework.Assert.AreEqual(5, queueConf.GetUserMaxApps("user2"));
            // Unspecified queues should get default ACL
            NUnit.Framework.Assert.AreEqual(" ", queueConf.GetQueueAcl("root.queueA", QueueACL
                                                                       .AdministerQueue).GetAclString());
            NUnit.Framework.Assert.AreEqual(" ", queueConf.GetQueueAcl("root.queueA", QueueACL
                                                                       .SubmitApplications).GetAclString());
            // Queue B ACL
            NUnit.Framework.Assert.AreEqual("alice,bob admins", queueConf.GetQueueAcl("root.queueB"
                                                                                      , QueueACL.AdministerQueue).GetAclString());
            // Queue C ACL
            NUnit.Framework.Assert.AreEqual("alice,bob admins", queueConf.GetQueueAcl("root.queueC"
                                                                                      , QueueACL.SubmitApplications).GetAclString());
            NUnit.Framework.Assert.AreEqual(120000, queueConf.GetMinSharePreemptionTimeout("root"
                                                                                           ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root."
                                                                                       + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueA"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueB"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueC"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueD"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(60000, queueConf.GetMinSharePreemptionTimeout("root.queueE"
                                                                                          ));
            NUnit.Framework.Assert.AreEqual(300000, queueConf.GetFairSharePreemptionTimeout("root"
                                                                                            ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root."
                                                                                        + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueA"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueB"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueC"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueD"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueE"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(.6f, queueConf.GetFairSharePreemptionThreshold("root"
                                                                                           ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root."
                                                                                          + YarnConfiguration.DefaultQueueName), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueA"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueB"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueC"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueD"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(.3f, queueConf.GetFairSharePreemptionThreshold("root.queueE"
                                                                                           ), 0.01);
        }
        public virtual void TestAllocationFileParsing()
        {
            Configuration conf = new Configuration();

            conf.Set(FairSchedulerConfiguration.AllocationFile, AllocFile);
            AllocationFileLoaderService allocLoader = new AllocationFileLoaderService();
            PrintWriter @out = new PrintWriter(new FileWriter(AllocFile));

            @out.WriteLine("<?xml version=\"1.0\"?>");
            @out.WriteLine("<allocations>");
            // Give queue A a minimum of 1024 M
            @out.WriteLine("<queue name=\"queueA\">");
            @out.WriteLine("<minResources>1024mb,0vcores</minResources>");
            @out.WriteLine("</queue>");
            // Give queue B a minimum of 2048 M
            @out.WriteLine("<queue name=\"queueB\">");
            @out.WriteLine("<minResources>2048mb,0vcores</minResources>");
            @out.WriteLine("<aclAdministerApps>alice,bob admins</aclAdministerApps>");
            @out.WriteLine("<schedulingPolicy>fair</schedulingPolicy>");
            @out.WriteLine("</queue>");
            // Give queue C no minimum
            @out.WriteLine("<queue name=\"queueC\">");
            @out.WriteLine("<aclSubmitApps>alice,bob admins</aclSubmitApps>");
            @out.WriteLine("</queue>");
            // Give queue D a limit of 3 running apps and 0.4f maxAMShare
            @out.WriteLine("<queue name=\"queueD\">");
            @out.WriteLine("<maxRunningApps>3</maxRunningApps>");
            @out.WriteLine("<maxAMShare>0.4</maxAMShare>");
            @out.WriteLine("</queue>");
            // Give queue E a preemption timeout of one minute
            @out.WriteLine("<queue name=\"queueE\">");
            @out.WriteLine("<minSharePreemptionTimeout>60</minSharePreemptionTimeout>");
            @out.WriteLine("</queue>");
            //Make queue F a parent queue without configured leaf queues using the 'type' attribute
            @out.WriteLine("<queue name=\"queueF\" type=\"parent\" >");
            @out.WriteLine("</queue>");
            // Create hierarchical queues G,H, with different min/fair share preemption
            // timeouts and preemption thresholds
            @out.WriteLine("<queue name=\"queueG\">");
            @out.WriteLine("<fairSharePreemptionTimeout>120</fairSharePreemptionTimeout>");
            @out.WriteLine("<minSharePreemptionTimeout>50</minSharePreemptionTimeout>");
            @out.WriteLine("<fairSharePreemptionThreshold>0.6</fairSharePreemptionThreshold>"
                           );
            @out.WriteLine("   <queue name=\"queueH\">");
            @out.WriteLine("   <fairSharePreemptionTimeout>180</fairSharePreemptionTimeout>");
            @out.WriteLine("   <minSharePreemptionTimeout>40</minSharePreemptionTimeout>");
            @out.WriteLine("   <fairSharePreemptionThreshold>0.7</fairSharePreemptionThreshold>"
                           );
            @out.WriteLine("   </queue>");
            @out.WriteLine("</queue>");
            // Set default limit of apps per queue to 15
            @out.WriteLine("<queueMaxAppsDefault>15</queueMaxAppsDefault>");
            // Set default limit of apps per user to 5
            @out.WriteLine("<userMaxAppsDefault>5</userMaxAppsDefault>");
            // Set default limit of AMResourceShare to 0.5f
            @out.WriteLine("<queueMaxAMShareDefault>0.5f</queueMaxAMShareDefault>");
            // Give user1 a limit of 10 jobs
            @out.WriteLine("<user name=\"user1\">");
            @out.WriteLine("<maxRunningApps>10</maxRunningApps>");
            @out.WriteLine("</user>");
            // Set default min share preemption timeout to 2 minutes
            @out.WriteLine("<defaultMinSharePreemptionTimeout>120" + "</defaultMinSharePreemptionTimeout>"
                           );
            // Set default fair share preemption timeout to 5 minutes
            @out.WriteLine("<defaultFairSharePreemptionTimeout>300</defaultFairSharePreemptionTimeout>"
                           );
            // Set default fair share preemption threshold to 0.4
            @out.WriteLine("<defaultFairSharePreemptionThreshold>0.4</defaultFairSharePreemptionThreshold>"
                           );
            // Set default scheduling policy to DRF
            @out.WriteLine("<defaultQueueSchedulingPolicy>drf</defaultQueueSchedulingPolicy>"
                           );
            @out.WriteLine("</allocations>");
            @out.Close();
            allocLoader.Init(conf);
            TestAllocationFileLoaderService.ReloadListener confHolder = new TestAllocationFileLoaderService.ReloadListener
                                                                            (this);
            allocLoader.SetReloadListener(confHolder);
            allocLoader.ReloadAllocations();
            AllocationConfiguration queueConf = confHolder.allocConf;

            NUnit.Framework.Assert.AreEqual(6, queueConf.GetConfiguredQueues()[FSQueueType.Leaf
                                            ].Count);
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root." + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root." + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(1024, 0), queueConf.GetMinResources
                                                ("root.queueA"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(2048, 0), queueConf.GetMinResources
                                                ("root.queueB"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root.queueC"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root.queueD"));
            NUnit.Framework.Assert.AreEqual(Resources.CreateResource(0), queueConf.GetMinResources
                                                ("root.queueE"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root." + YarnConfiguration
                                                                          .DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueA"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueB"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueC"));
            NUnit.Framework.Assert.AreEqual(3, queueConf.GetQueueMaxApps("root.queueD"));
            NUnit.Framework.Assert.AreEqual(15, queueConf.GetQueueMaxApps("root.queueE"));
            NUnit.Framework.Assert.AreEqual(10, queueConf.GetUserMaxApps("user1"));
            NUnit.Framework.Assert.AreEqual(5, queueConf.GetUserMaxApps("user2"));
            NUnit.Framework.Assert.AreEqual(.5f, queueConf.GetQueueMaxAMShare("root." + YarnConfiguration
                                                                              .DefaultQueueName), 0.01);
            NUnit.Framework.Assert.AreEqual(.5f, queueConf.GetQueueMaxAMShare("root.queueA"),
                                            0.01);
            NUnit.Framework.Assert.AreEqual(.5f, queueConf.GetQueueMaxAMShare("root.queueB"),
                                            0.01);
            NUnit.Framework.Assert.AreEqual(.5f, queueConf.GetQueueMaxAMShare("root.queueC"),
                                            0.01);
            NUnit.Framework.Assert.AreEqual(.4f, queueConf.GetQueueMaxAMShare("root.queueD"),
                                            0.01);
            NUnit.Framework.Assert.AreEqual(.5f, queueConf.GetQueueMaxAMShare("root.queueE"),
                                            0.01);
            // Root should get * ACL
            NUnit.Framework.Assert.AreEqual("*", queueConf.GetQueueAcl("root", QueueACL.AdministerQueue
                                                                       ).GetAclString());
            NUnit.Framework.Assert.AreEqual("*", queueConf.GetQueueAcl("root", QueueACL.SubmitApplications
                                                                       ).GetAclString());
            // Unspecified queues should get default ACL
            NUnit.Framework.Assert.AreEqual(" ", queueConf.GetQueueAcl("root.queueA", QueueACL
                                                                       .AdministerQueue).GetAclString());
            NUnit.Framework.Assert.AreEqual(" ", queueConf.GetQueueAcl("root.queueA", QueueACL
                                                                       .SubmitApplications).GetAclString());
            // Queue B ACL
            NUnit.Framework.Assert.AreEqual("alice,bob admins", queueConf.GetQueueAcl("root.queueB"
                                                                                      , QueueACL.AdministerQueue).GetAclString());
            // Queue C ACL
            NUnit.Framework.Assert.AreEqual("alice,bob admins", queueConf.GetQueueAcl("root.queueC"
                                                                                      , QueueACL.SubmitApplications).GetAclString());
            NUnit.Framework.Assert.AreEqual(120000, queueConf.GetMinSharePreemptionTimeout("root"
                                                                                           ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root."
                                                                                       + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueA"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueB"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueC"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueD"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(60000, queueConf.GetMinSharePreemptionTimeout("root.queueE"
                                                                                          ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetMinSharePreemptionTimeout("root.queueF"
                                                                                       ));
            NUnit.Framework.Assert.AreEqual(50000, queueConf.GetMinSharePreemptionTimeout("root.queueG"
                                                                                          ));
            NUnit.Framework.Assert.AreEqual(40000, queueConf.GetMinSharePreemptionTimeout("root.queueG.queueH"
                                                                                          ));
            NUnit.Framework.Assert.AreEqual(300000, queueConf.GetFairSharePreemptionTimeout("root"
                                                                                            ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root."
                                                                                        + YarnConfiguration.DefaultQueueName));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueA"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueB"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueC"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueD"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueE"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionTimeout("root.queueF"
                                                                                        ));
            NUnit.Framework.Assert.AreEqual(120000, queueConf.GetFairSharePreemptionTimeout("root.queueG"
                                                                                            ));
            NUnit.Framework.Assert.AreEqual(180000, queueConf.GetFairSharePreemptionTimeout("root.queueG.queueH"
                                                                                            ));
            NUnit.Framework.Assert.AreEqual(.4f, queueConf.GetFairSharePreemptionThreshold("root"
                                                                                           ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root."
                                                                                          + YarnConfiguration.DefaultQueueName), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueA"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueB"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueC"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueD"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueE"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(-1, queueConf.GetFairSharePreemptionThreshold("root.queueF"
                                                                                          ), 0.01);
            NUnit.Framework.Assert.AreEqual(.6f, queueConf.GetFairSharePreemptionThreshold("root.queueG"
                                                                                           ), 0.01);
            NUnit.Framework.Assert.AreEqual(.7f, queueConf.GetFairSharePreemptionThreshold("root.queueG.queueH"
                                                                                           ), 0.01);
            NUnit.Framework.Assert.IsTrue(queueConf.GetConfiguredQueues()[FSQueueType.Parent]
                                          .Contains("root.queueF"));
            NUnit.Framework.Assert.IsTrue(queueConf.GetConfiguredQueues()[FSQueueType.Parent]
                                          .Contains("root.queueG"));
            NUnit.Framework.Assert.IsTrue(queueConf.GetConfiguredQueues()[FSQueueType.Leaf].Contains
                                              ("root.queueG.queueH"));
            // Verify existing queues have default scheduling policy
            NUnit.Framework.Assert.AreEqual(DominantResourceFairnessPolicy.Name, queueConf.GetSchedulingPolicy
                                                ("root").GetName());
            NUnit.Framework.Assert.AreEqual(DominantResourceFairnessPolicy.Name, queueConf.GetSchedulingPolicy
                                                ("root.queueA").GetName());
            // Verify default is overriden if specified explicitly
            NUnit.Framework.Assert.AreEqual(FairSharePolicy.Name, queueConf.GetSchedulingPolicy
                                                ("root.queueB").GetName());
            // Verify new queue gets default scheduling policy
            NUnit.Framework.Assert.AreEqual(DominantResourceFairnessPolicy.Name, queueConf.GetSchedulingPolicy
                                                ("root.newqueue").GetName());
        }