Exemplo n.º 1
0
        private void SetupQueueConfigurationWithLabelsInherit(CapacitySchedulerConfiguration
                                                              conf)
        {
            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b" });
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "red", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "blue", 100);
            // Set A configuration
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 15);
            conf.SetQueues(A, new string[] { "a1", "a2" });
            conf.SetAccessibleNodeLabels(A, ImmutableSet.Of("red", "blue"));
            conf.SetCapacityByLabel(A, "red", 100);
            conf.SetCapacityByLabel(A, "blue", 100);
            // Set B configuraiton
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 90);
            conf.SetAccessibleNodeLabels(B, CommonNodeLabelsManager.EmptyStringSet);
            // Define 2nd-level queues
            string A1 = A + ".a1";
            string A2 = A + ".a2";

            conf.SetCapacity(A1, 30);
            conf.SetMaximumCapacity(A1, 45);
            conf.SetCapacityByLabel(A1, "red", 50);
            conf.SetCapacityByLabel(A1, "blue", 100);
            conf.SetCapacity(A2, 70);
            conf.SetMaximumCapacity(A2, 85);
            conf.SetAccessibleNodeLabels(A2, ImmutableSet.Of("red"));
            conf.SetCapacityByLabel(A2, "red", 50);
        }
Exemplo n.º 2
0
        public virtual void TestQueueParsing()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(csConf);
            YarnConfiguration conf = new YarnConfiguration(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(conf);
            capacityScheduler.SetRMContext(TestUtils.GetMockRMContext());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, TestUtils.GetMockRMContext());
            CSQueue a = capacityScheduler.GetQueue("a");

            NUnit.Framework.Assert.AreEqual(0.10, a.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue b1 = capacityScheduler.GetQueue("b1");

            NUnit.Framework.Assert.AreEqual(0.2 * 0.5, b1.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual("Parent B has no MAX_CAP", 0.85, b1.GetAbsoluteMaximumCapacity
                                                (), Delta);
            CSQueue c12 = capacityScheduler.GetQueue("c12");

            NUnit.Framework.Assert.AreEqual(0.7 * 0.5 * 0.45, c12.GetAbsoluteCapacity(), Delta
                                            );
            NUnit.Framework.Assert.AreEqual(0.7 * 0.55 * 0.7, c12.GetAbsoluteMaximumCapacity(
                                                ), Delta);
            ServiceOperations.StopQuietly(capacityScheduler);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Test init a queue configuration, children's capacity for a given label
        /// doesn't equals to 100%.
        /// </summary>
        /// <remarks>
        /// Test init a queue configuration, children's capacity for a given label
        /// doesn't equals to 100%. This expect IllegalArgumentException thrown.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestQueueParsingWithSumOfChildLabelCapacityNot100PercentWithWildCard
            ()
        {
            nodeLabelManager.AddToCluserNodeLabels(ImmutableSet.Of("red", "blue"));
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfigurationWithLabels(csConf);
            csConf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root + ".b.b3", "red", 24
                                      );
            csConf.SetAccessibleNodeLabels(CapacitySchedulerConfiguration.Root, ImmutableSet.
                                           Of(RMNodeLabelsManager.Any));
            csConf.SetAccessibleNodeLabels(CapacitySchedulerConfiguration.Root + ".b", ImmutableSet
                                           .Of(RMNodeLabelsManager.Any));
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            ServiceOperations.StopQuietly(capacityScheduler);
        }
Exemplo n.º 4
0
        public virtual void TestNestedQueueParsingShouldTrimSpaces()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupNestedQueueConfigurationWithSpacesShouldBeTrimmed(csConf);
            YarnConfiguration conf = new YarnConfiguration(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(conf);
            capacityScheduler.SetRMContext(TestUtils.GetMockRMContext());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, TestUtils.GetMockRMContext());
            CSQueue a = capacityScheduler.GetQueue("a");

            NUnit.Framework.Assert.IsNotNull(a);
            NUnit.Framework.Assert.AreEqual(0.10, a.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue c = capacityScheduler.GetQueue("c");

            NUnit.Framework.Assert.IsNotNull(c);
            NUnit.Framework.Assert.AreEqual(0.70, c.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.70, c.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue a1 = capacityScheduler.GetQueue("a1");

            NUnit.Framework.Assert.IsNotNull(a1);
            NUnit.Framework.Assert.AreEqual(0.10 * 0.6, a1.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a1.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue a2 = capacityScheduler.GetQueue("a2");

            NUnit.Framework.Assert.IsNotNull(a2);
            NUnit.Framework.Assert.AreEqual(0.10 * 0.4, a2.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a2.GetAbsoluteMaximumCapacity(), Delta);
        }
Exemplo n.º 5
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestQueueParsingWithMoveQueue()
        {
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            csConf.SetQueues("root", new string[] { "a" });
            csConf.SetQueues("root.a", new string[] { "x", "y" });
            csConf.SetCapacity("root.a", 100);
            csConf.SetCapacity("root.a.x", 50);
            csConf.SetCapacity("root.a.y", 50);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            csConf.SetQueues("root", new string[] { "a", "x" });
            csConf.SetQueues("root.a", new string[] { "y" });
            csConf.SetCapacity("root.x", 50);
            csConf.SetCapacity("root.a", 50);
            csConf.SetCapacity("root.a.y", 100);
            capacityScheduler.Reinitialize(csConf, rmContext);
        }
Exemplo n.º 6
0
        private void SetupNestedQueueConfigurationWithSpacesShouldBeTrimmed(CapacitySchedulerConfiguration
                                                                            conf)
        {
            // Define top-level queues
            conf.Set(CapacitySchedulerConfiguration.GetQueuePrefix(CapacitySchedulerConfiguration
                                                                   .Root) + CapacitySchedulerConfiguration.Queues, " a ,b, c");
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 15);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 20);
            string C = CapacitySchedulerConfiguration.Root + ".c";

            conf.SetCapacity(C, 70);
            conf.SetMaximumCapacity(C, 70);
            // sub queues for A
            conf.Set(CapacitySchedulerConfiguration.GetQueuePrefix(A) + CapacitySchedulerConfiguration
                     .Queues, "a1, a2 ");
            string A1 = CapacitySchedulerConfiguration.Root + ".a.a1";

            conf.SetCapacity(A1, 60);
            string A2 = CapacitySchedulerConfiguration.Root + ".a.a2";

            conf.SetCapacity(A2, 40);
        }
Exemplo n.º 7
0
        /// <exception cref="System.IO.IOException"/>
        public PlanQueue(CapacitySchedulerContext cs, string queueName, CSQueue parent, CSQueue
                         old)
            : base(cs, queueName, parent, old)
        {
            this.schedulerContext = cs;
            // Set the reservation queue attributes for the Plan
            CapacitySchedulerConfiguration conf = cs.GetConfiguration();
            string queuePath             = base.GetQueuePath();
            int    maxAppsForReservation = conf.GetMaximumApplicationsPerQueue(queuePath);

            showReservationsAsQueues = conf.GetShowReservationAsQueues(queuePath);
            if (maxAppsForReservation < 0)
            {
                maxAppsForReservation = (int)(CapacitySchedulerConfiguration.DefaultMaximumSystemApplicatiions
                                              * base.GetAbsoluteCapacity());
            }
            int   userLimit       = conf.GetUserLimit(queuePath);
            float userLimitFactor = conf.GetUserLimitFactor(queuePath);
            int   maxAppsPerUserForReservation = (int)(maxAppsForReservation * (userLimit / 100.0f
                                                                                ) * userLimitFactor);

            UpdateQuotas(userLimit, userLimitFactor, maxAppsForReservation, maxAppsPerUserForReservation
                         );
            StringBuilder queueInfo = new StringBuilder();

            queueInfo.Append("Created Plan Queue: ").Append(queueName).Append("\nwith capacity: ["
                                                                              ).Append(base.GetCapacity()).Append("]\nwith max capacity: [").Append(base.GetMaximumCapacity
                                                                                                                                                        ()).Append("\nwith max reservation apps: [").Append(maxAppsForReservation).Append
                ("]\nwith max reservation apps per user: [").Append(maxAppsPerUserForReservation
                                                                    ).Append("]\nwith user limit: [").Append(userLimit).Append("]\nwith user limit factor: ["
                                                                                                                               ).Append(userLimitFactor).Append("].");
            Log.Info(queueInfo.ToString());
        }
Exemplo n.º 8
0
        public virtual void Setup()
        {
            // setup a context / conf
            csConf = new CapacitySchedulerConfiguration();
            YarnConfiguration conf = new YarnConfiguration();

            csContext = Org.Mockito.Mockito.Mock <CapacitySchedulerContext>();
            Org.Mockito.Mockito.When(csContext.GetConfiguration()).ThenReturn(csConf);
            Org.Mockito.Mockito.When(csContext.GetConf()).ThenReturn(conf);
            Org.Mockito.Mockito.When(csContext.GetMinimumResourceCapability()).ThenReturn(Resources
                                                                                          .CreateResource(Gb, 1));
            Org.Mockito.Mockito.When(csContext.GetMaximumResourceCapability()).ThenReturn(Resources
                                                                                          .CreateResource(16 * Gb, 32));
            Org.Mockito.Mockito.When(csContext.GetClusterResource()).ThenReturn(Resources.CreateResource
                                                                                    (100 * 16 * Gb, 100 * 32));
            Org.Mockito.Mockito.When(csContext.GetResourceCalculator()).ThenReturn(resourceCalculator
                                                                                   );
            RMContext mockRMContext = TestUtils.GetMockRMContext();

            Org.Mockito.Mockito.When(csContext.GetRMContext()).ThenReturn(mockRMContext);
            // create a queue
            PlanQueue pq = new PlanQueue(csContext, "root", null, null);

            reservationQueue = new ReservationQueue(csContext, "a", pq);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Do following steps for capacities
 /// - Load capacities from configuration
 /// - Update absolute capacities for new capacities
 /// - Check if capacities/absolute-capacities legal
 /// </summary>
 public static void LoadUpdateAndCheckCapacities(string queuePath, CapacitySchedulerConfiguration
                                                 csConf, QueueCapacities queueCapacities, QueueCapacities parentQueueCapacities)
 {
     LoadCapacitiesByLabelsFromConf(queuePath, queueCapacities, csConf);
     UpdateAbsoluteCapacitiesByNodeLabels(queueCapacities, parentQueueCapacities);
     CapacitiesSanityCheck(queuePath, queueCapacities);
 }
Exemplo n.º 10
0
        /// <summary>
        /// The specified queue is preemptable if system-wide preemption is turned on
        /// unless any queue in the <em>qPath</em> hierarchy has explicitly turned
        /// preemption off.
        /// </summary>
        /// <remarks>
        /// The specified queue is preemptable if system-wide preemption is turned on
        /// unless any queue in the <em>qPath</em> hierarchy has explicitly turned
        /// preemption off.
        /// NOTE: Preemptability is inherited from a queue's parent.
        /// </remarks>
        /// <returns>true if queue has preemption disabled, false otherwise</returns>
        private bool IsQueueHierarchyPreemptionDisabled(CSQueue q)
        {
            CapacitySchedulerConfiguration csConf = csContext.GetConfiguration();
            bool systemWidePreemption             = csConf.GetBoolean(YarnConfiguration.RmSchedulerEnableMonitors
                                                                      , YarnConfiguration.DefaultRmSchedulerEnableMonitors);
            CSQueue parentQ = q.GetParent();

            // If the system-wide preemption switch is turned off, all of the queues in
            // the qPath hierarchy have preemption disabled, so return true.
            if (!systemWidePreemption)
            {
                return(true);
            }
            // If q is the root queue and the system-wide preemption switch is turned
            // on, then q does not have preemption disabled (default=false, below)
            // unless the preemption_disabled property is explicitly set.
            if (parentQ == null)
            {
                return(csConf.GetPreemptionDisabled(q.GetQueuePath(), false));
            }
            // If this is not the root queue, inherit the default value for the
            // preemption_disabled property from the parent. Preemptability will be
            // inherited from the parent's hierarchy unless explicitly overridden at
            // this level.
            return(csConf.GetPreemptionDisabled(q.GetQueuePath(), parentQ.GetPreemptionDisabled
                                                    ()));
        }
Exemplo n.º 11
0
        private void SetupQueueConfigurationWithoutLabels(CapacitySchedulerConfiguration
                                                          conf)
        {
            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b" });
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 15);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 90);
            Log.Info("Setup top-level queues");
            // Define 2nd-level queues
            string A1 = A + ".a1";
            string A2 = A + ".a2";

            conf.SetQueues(A, new string[] { "a1", "a2" });
            conf.SetCapacity(A1, 30);
            conf.SetMaximumCapacity(A1, 45);
            conf.SetCapacity(A2, 70);
            conf.SetMaximumCapacity(A2, 85);
            string B1 = B + ".b1";
            string B2 = B + ".b2";
            string B3 = B + ".b3";

            conf.SetQueues(B, new string[] { "b1", "b2", "b3" });
            conf.SetCapacity(B1, 50);
            conf.SetMaximumCapacity(B1, 85);
            conf.SetCapacity(B2, 30);
            conf.SetMaximumCapacity(B2, 35);
            conf.SetCapacity(B3, 20);
            conf.SetMaximumCapacity(B3, 35);
        }
Exemplo n.º 12
0
        private static void LoadCapacitiesByLabelsFromConf(string queuePath, QueueCapacities
                                                           queueCapacities, CapacitySchedulerConfiguration csConf)
        {
            queueCapacities.ClearConfigurableFields();
            ICollection <string> configuredNodelabels = csConf.GetConfiguredNodeLabels(queuePath
                                                                                       );

            foreach (string label in configuredNodelabels)
            {
                if (label.Equals(CommonNodeLabelsManager.NoLabel))
                {
                    queueCapacities.SetCapacity(CommonNodeLabelsManager.NoLabel, csConf.GetNonLabeledQueueCapacity
                                                    (queuePath) / 100);
                    queueCapacities.SetMaximumCapacity(CommonNodeLabelsManager.NoLabel, csConf.GetNonLabeledQueueMaximumCapacity
                                                           (queuePath) / 100);
                }
                else
                {
                    queueCapacities.SetCapacity(label, csConf.GetLabeledQueueCapacity(queuePath, label
                                                                                      ) / 100);
                    queueCapacities.SetMaximumCapacity(label, csConf.GetLabeledQueueMaximumCapacity(queuePath
                                                                                                    , label) / 100);
                }
            }
        }
Exemplo n.º 13
0
 private void SetupQueueConfiguration(CapacitySchedulerConfiguration conf)
 {
     // Define top-level queues
     conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { Q1, Q2 });
     conf.SetCapacity(Q1Path, 10);
     conf.SetCapacity(Q2Path, 90);
     Log.Info("Setup top-level queues q1 and q2");
 }
Exemplo n.º 14
0
        private void SetupQueueConfigurationWithLabels(CapacitySchedulerConfiguration conf
                                                       )
        {
            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b" });
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "red", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "blue", 100);
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 15);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 90);
            Log.Info("Setup top-level queues");
            // Define 2nd-level queues
            string A1 = A + ".a1";
            string A2 = A + ".a2";

            conf.SetQueues(A, new string[] { "a1", "a2" });
            conf.SetAccessibleNodeLabels(A, ImmutableSet.Of("red", "blue"));
            conf.SetCapacityByLabel(A, "red", 50);
            conf.SetMaximumCapacityByLabel(A, "red", 50);
            conf.SetCapacityByLabel(A, "blue", 50);
            conf.SetCapacity(A1, 30);
            conf.SetMaximumCapacity(A1, 45);
            conf.SetCapacityByLabel(A1, "red", 50);
            conf.SetCapacityByLabel(A1, "blue", 100);
            conf.SetCapacity(A2, 70);
            conf.SetMaximumCapacity(A2, 85);
            conf.SetAccessibleNodeLabels(A2, ImmutableSet.Of("red"));
            conf.SetCapacityByLabel(A2, "red", 50);
            conf.SetMaximumCapacityByLabel(A2, "red", 60);
            string B1 = B + ".b1";
            string B2 = B + ".b2";
            string B3 = B + ".b3";

            conf.SetQueues(B, new string[] { "b1", "b2", "b3" });
            conf.SetAccessibleNodeLabels(B, ImmutableSet.Of("red", "blue"));
            conf.SetCapacityByLabel(B, "red", 50);
            conf.SetCapacityByLabel(B, "blue", 50);
            conf.SetCapacity(B1, 50);
            conf.SetMaximumCapacity(B1, 85);
            conf.SetCapacityByLabel(B1, "red", 50);
            conf.SetCapacityByLabel(B1, "blue", 50);
            conf.SetCapacity(B2, 30);
            conf.SetMaximumCapacity(B2, 35);
            conf.SetCapacityByLabel(B2, "red", 25);
            conf.SetCapacityByLabel(B2, "blue", 25);
            conf.SetCapacity(B3, 20);
            conf.SetMaximumCapacity(B3, 35);
            conf.SetCapacityByLabel(B3, "red", 25);
            conf.SetCapacityByLabel(B3, "blue", 25);
        }
Exemplo n.º 15
0
        public virtual void SetUp()
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            SetupPlanQueueConfiguration(conf);
            conf.SetClass(YarnConfiguration.RmScheduler, typeof(CapacityScheduler), typeof(ResourceScheduler
                                                                                           ));
            conf.SetBoolean(YarnConfiguration.RmReservationSystemEnable, false);
            rm = new MockRM(conf);
            rm.Start();
        }
Exemplo n.º 16
0
        private void SetupSingleLevelQueues(CapacitySchedulerConfiguration conf)
        {
            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { A, B });
            string QA = CapacitySchedulerConfiguration.Root + "." + A;

            conf.SetCapacity(QA, 30);
            string QB = CapacitySchedulerConfiguration.Root + "." + B;

            conf.SetCapacity(QB, 70);
            Log.Info("Setup top-level queues a and b");
        }
Exemplo n.º 17
0
        /// <exception cref="System.Exception"/>
        public virtual void TestMaxCapacity()
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b", "c" }
                           );
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 50);
            conf.SetMaximumCapacity(A, 60);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 50);
            conf.SetMaximumCapacity(B, 45);
            // Should throw an exception
            bool fail = false;
            CapacityScheduler capacityScheduler;

            try
            {
                capacityScheduler = new CapacityScheduler();
                capacityScheduler.SetConf(new YarnConfiguration());
                capacityScheduler.Init(conf);
                capacityScheduler.Start();
                capacityScheduler.Reinitialize(conf, null);
            }
            catch (ArgumentException)
            {
                fail = true;
            }
            NUnit.Framework.Assert.IsTrue("Didn't throw IllegalArgumentException for wrong maxCap"
                                          , fail);
            conf.SetMaximumCapacity(B, 60);
            // Now this should work
            capacityScheduler = new CapacityScheduler();
            capacityScheduler.SetConf(new YarnConfiguration());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, null);
            fail = false;
            try
            {
                LeafQueue a = (LeafQueue)capacityScheduler.GetQueue(A);
                a.SetMaxCapacity(45);
            }
            catch (ArgumentException)
            {
                fail = true;
            }
            NUnit.Framework.Assert.IsTrue("Didn't throw IllegalArgumentException for wrong "
                                          + "setMaxCap", fail);
            capacityScheduler.Stop();
        }
Exemplo n.º 18
0
        private Configuration GetConfigurationWithDefaultQueueLabels(Configuration config
                                                                     )
        {
            string A = CapacitySchedulerConfiguration.Root + ".a";
            string B = CapacitySchedulerConfiguration.Root + ".b";
            CapacitySchedulerConfiguration conf = (CapacitySchedulerConfiguration)GetConfigurationWithQueueLabels
                                                      (config);

            new CapacitySchedulerConfiguration(config);
            conf.SetDefaultNodeLabelExpression(A, "x");
            conf.SetDefaultNodeLabelExpression(B, "y");
            return(conf);
        }
Exemplo n.º 19
0
        /// <exception cref="System.Exception"/>
        public virtual void TestRootQueueParsing()
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();

            // non-100 percent value will throw IllegalArgumentException
            conf.SetCapacity(CapacitySchedulerConfiguration.Root, 90);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(new YarnConfiguration());
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, null);
            ServiceOperations.StopQuietly(capacityScheduler);
        }
Exemplo n.º 20
0
        private void SetupQueueConfiguration(CapacitySchedulerConfiguration conf)
        {
            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { A, B });
            string QA = CapacitySchedulerConfiguration.Root + "." + A;

            conf.SetCapacity(QA, 10);
            string QB = CapacitySchedulerConfiguration.Root + "." + B;

            conf.SetCapacity(QB, 90);
            conf.SetUserLimit(CapacitySchedulerConfiguration.Root + "." + A, 50);
            conf.SetUserLimitFactor(CapacitySchedulerConfiguration.Root + "." + A, 5.0f);
            Log.Info("Setup top-level queues a and b");
        }
Exemplo n.º 21
0
        private Configuration GetComplexConfigurationWithQueueLabels(Configuration config
                                                                     )
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(config);

            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b" });
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "x", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "y", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "z", 100);
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 10);
            conf.SetAccessibleNodeLabels(A, ToSet("x", "y"));
            conf.SetCapacityByLabel(A, "x", 100);
            conf.SetCapacityByLabel(A, "y", 50);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 90);
            conf.SetMaximumCapacity(B, 100);
            conf.SetAccessibleNodeLabels(B, ToSet("y", "z"));
            conf.SetCapacityByLabel(B, "y", 50);
            conf.SetCapacityByLabel(B, "z", 100);
            // Define 2nd-level queues
            string A1 = A + ".a1";

            conf.SetQueues(A, new string[] { "a1" });
            conf.SetCapacity(A1, 100);
            conf.SetMaximumCapacity(A1, 100);
            conf.SetAccessibleNodeLabels(A1, ToSet("x", "y"));
            conf.SetDefaultNodeLabelExpression(A1, "x");
            conf.SetCapacityByLabel(A1, "x", 100);
            conf.SetCapacityByLabel(A1, "y", 100);
            conf.SetQueues(B, new string[] { "b1", "b2" });
            string B1 = B + ".b1";

            conf.SetCapacity(B1, 50);
            conf.SetMaximumCapacity(B1, 50);
            conf.SetAccessibleNodeLabels(B1, RMNodeLabelsManager.EmptyStringSet);
            string B2 = B + ".b2";

            conf.SetCapacity(B2, 50);
            conf.SetMaximumCapacity(B2, 50);
            conf.SetAccessibleNodeLabels(B2, ToSet("y", "z"));
            conf.SetCapacityByLabel(B2, "y", 100);
            conf.SetCapacityByLabel(B2, "z", 100);
            return(conf);
        }
Exemplo n.º 22
0
        public virtual void TestQueueParsingWithUnusedLabels()
        {
            ImmutableSet <string> labels = ImmutableSet.Of("red", "blue");

            // Initialize a cluster with labels, but doesn't use them, reinitialize
            // shouldn't fail
            nodeLabelManager.AddToCluserNodeLabels(labels);
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();

            SetupQueueConfiguration(csConf);
            csConf.SetAccessibleNodeLabels(CapacitySchedulerConfiguration.Root, labels);
            YarnConfiguration conf = new YarnConfiguration(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();

            capacityScheduler.SetConf(conf);
            RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null, null, new
                                                        RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                        ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(conf);
            capacityScheduler.Start();
            capacityScheduler.Reinitialize(conf, rmContext);
            // check root queue's capacity by label -- they should be all zero
            CSQueue root = capacityScheduler.GetQueue(CapacitySchedulerConfiguration.Root);

            NUnit.Framework.Assert.AreEqual(0, root.GetQueueCapacities().GetCapacity("red"),
                                            Delta);
            NUnit.Framework.Assert.AreEqual(0, root.GetQueueCapacities().GetCapacity("blue"),
                                            Delta);
            CSQueue a = capacityScheduler.GetQueue("a");

            NUnit.Framework.Assert.AreEqual(0.10, a.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual(0.15, a.GetAbsoluteMaximumCapacity(), Delta);
            CSQueue b1 = capacityScheduler.GetQueue("b1");

            NUnit.Framework.Assert.AreEqual(0.2 * 0.5, b1.GetAbsoluteCapacity(), Delta);
            NUnit.Framework.Assert.AreEqual("Parent B has no MAX_CAP", 0.85, b1.GetAbsoluteMaximumCapacity
                                                (), Delta);
            CSQueue c12 = capacityScheduler.GetQueue("c12");

            NUnit.Framework.Assert.AreEqual(0.7 * 0.5 * 0.45, c12.GetAbsoluteCapacity(), Delta
                                            );
            NUnit.Framework.Assert.AreEqual(0.7 * 0.55 * 0.7, c12.GetAbsoluteMaximumCapacity(
                                                ), Delta);
            capacityScheduler.Stop();
        }
Exemplo n.º 23
0
        private Configuration GetConfigurationWithQueueLabels(Configuration config)
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(config);

            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b", "c" }
                           );
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "x", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "y", 100);
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 15);
            conf.SetAccessibleNodeLabels(A, ToSet("x"));
            conf.SetCapacityByLabel(A, "x", 100);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 20);
            conf.SetAccessibleNodeLabels(B, ToSet("y"));
            conf.SetCapacityByLabel(B, "y", 100);
            string C = CapacitySchedulerConfiguration.Root + ".c";

            conf.SetCapacity(C, 70);
            conf.SetMaximumCapacity(C, 70);
            conf.SetAccessibleNodeLabels(C, RMNodeLabelsManager.EmptyStringSet);
            // Define 2nd-level queues
            string A1 = A + ".a1";

            conf.SetQueues(A, new string[] { "a1" });
            conf.SetCapacity(A1, 100);
            conf.SetMaximumCapacity(A1, 100);
            conf.SetCapacityByLabel(A1, "x", 100);
            string B1 = B + ".b1";

            conf.SetQueues(B, new string[] { "b1" });
            conf.SetCapacity(B1, 100);
            conf.SetMaximumCapacity(B1, 100);
            conf.SetCapacityByLabel(B1, "y", 100);
            string C1 = C + ".c1";

            conf.SetQueues(C, new string[] { "c1" });
            conf.SetCapacity(C1, 100);
            conf.SetMaximumCapacity(C1, 100);
            return(conf);
        }
Exemplo n.º 24
0
        private void SetupSortedQueues(CapacitySchedulerConfiguration conf)
        {
            // Define queues
            csConf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { A, B, C, D }
                             );
            string QA = CapacitySchedulerConfiguration.Root + "." + A;

            conf.SetCapacity(QA, 25);
            string QB = CapacitySchedulerConfiguration.Root + "." + B;

            conf.SetCapacity(QB, 25);
            string QC = CapacitySchedulerConfiguration.Root + "." + C;

            conf.SetCapacity(QC, 25);
            string QD = CapacitySchedulerConfiguration.Root + "." + D;

            conf.SetCapacity(QD, 25);
        }
Exemplo n.º 25
0
        private Configuration GetConfigurationWithQueueLabels(Configuration config)
        {
            CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(config);

            // Define top-level queues
            conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a" });
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "x", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "y", 100);
            conf.SetCapacityByLabel(CapacitySchedulerConfiguration.Root, "z", 100);
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 100);
            conf.SetAccessibleNodeLabels(A, ImmutableSet.Of("x", "y", "z"));
            conf.SetCapacityByLabel(A, "x", 100);
            conf.SetCapacityByLabel(A, "y", 100);
            conf.SetCapacityByLabel(A, "z", 100);
            return(conf);
        }
Exemplo n.º 26
0
 private void SetupPlanQueueConfiguration(CapacitySchedulerConfiguration conf)
 {
     conf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { "a", "b" });
     conf.SetCapacity(A, ACapacity);
     conf.SetCapacity(B, BCapacity);
     // Define 2nd-level queues
     conf.SetQueues(B, new string[] { "b1", "b2", "b3" });
     conf.SetCapacity(B1, B1Capacity);
     conf.SetUserLimitFactor(B1, 100.0f);
     conf.SetCapacity(B2, B2Capacity);
     conf.SetUserLimitFactor(B2, 100.0f);
     conf.SetCapacity(B3, B3Capacity);
     conf.SetUserLimitFactor(B3, 100.0f);
     conf.SetReservable(A, true);
     conf.SetReservationWindow(A, 86400 * 1000);
     conf.SetAverageCapacity(A, 1.0f);
     Log.Info("Setup a as a plan queue");
 }
Exemplo n.º 27
0
        private void SetupQueueConfigurationWithSpacesShouldBeTrimmed(CapacitySchedulerConfiguration
                                                                      conf)
        {
            // Define top-level queues
            conf.Set(CapacitySchedulerConfiguration.GetQueuePrefix(CapacitySchedulerConfiguration
                                                                   .Root) + CapacitySchedulerConfiguration.Queues, " a ,b, c");
            string A = CapacitySchedulerConfiguration.Root + ".a";

            conf.SetCapacity(A, 10);
            conf.SetMaximumCapacity(A, 15);
            string B = CapacitySchedulerConfiguration.Root + ".b";

            conf.SetCapacity(B, 20);
            string C = CapacitySchedulerConfiguration.Root + ".c";

            conf.SetCapacity(C, 70);
            conf.SetMaximumCapacity(C, 70);
        }
Exemplo n.º 28
0
        public virtual void SetUp()
        {
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
            YarnConfiguration conf = new YarnConfiguration();

            SetupQueueConfiguration(csConf);
            rmContext = TestUtils.GetMockRMContext();
            CapacitySchedulerContext csContext = Org.Mockito.Mockito.Mock <CapacitySchedulerContext
                                                                           >();

            Org.Mockito.Mockito.When(csContext.GetConfiguration()).ThenReturn(csConf);
            Org.Mockito.Mockito.When(csContext.GetConf()).ThenReturn(conf);
            Org.Mockito.Mockito.When(csContext.GetMinimumResourceCapability()).ThenReturn(Resources
                                                                                          .CreateResource(Gb, 1));
            Org.Mockito.Mockito.When(csContext.GetMaximumResourceCapability()).ThenReturn(Resources
                                                                                          .CreateResource(16 * Gb, 32));
            Org.Mockito.Mockito.When(csContext.GetClusterResource()).ThenReturn(Resources.CreateResource
                                                                                    (10 * 16 * Gb, 10 * 32));
            Org.Mockito.Mockito.When(csContext.GetApplicationComparator()).ThenReturn(CapacityScheduler
                                                                                      .applicationComparator);
            Org.Mockito.Mockito.When(csContext.GetQueueComparator()).ThenReturn(CapacityScheduler
                                                                                .queueComparator);
            Org.Mockito.Mockito.When(csContext.GetResourceCalculator()).ThenReturn(resourceCalculator
                                                                                   );
            Org.Mockito.Mockito.When(csContext.GetRMContext()).ThenReturn(rmContext);
            RMContainerTokenSecretManager containerTokenSecretManager = new RMContainerTokenSecretManager
                                                                            (conf);

            containerTokenSecretManager.RollMasterKey();
            Org.Mockito.Mockito.When(csContext.GetContainerTokenSecretManager()).ThenReturn(containerTokenSecretManager
                                                                                            );
            IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>();
            CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, "root", queues
                                                        , queues, TestUtils.spyHook);

            queue = Org.Mockito.Mockito.Spy(new LeafQueue(csContext, A, root, null));
            // Stub out ACL checks
            Org.Mockito.Mockito.DoReturn(true).When(queue).HasAccess(Matchers.Any <QueueACL>()
                                                                     , Matchers.Any <UserGroupInformation>());
            // Some default values
            Org.Mockito.Mockito.DoReturn(100).When(queue).GetMaxApplications();
            Org.Mockito.Mockito.DoReturn(25).When(queue).GetMaxApplicationsPerUser();
        }
Exemplo n.º 29
0
        private void SetupMultiLevelQueues(CapacitySchedulerConfiguration conf)
        {
            // Define top-level queues
            csConf.SetQueues(CapacitySchedulerConfiguration.Root, new string[] { A, B, C, D }
                             );
            string QA = CapacitySchedulerConfiguration.Root + "." + A;

            conf.SetCapacity(QA, 10);
            string QB = CapacitySchedulerConfiguration.Root + "." + B;

            conf.SetCapacity(QB, 50);
            string QC = CapacitySchedulerConfiguration.Root + "." + C;

            conf.SetCapacity(QC, 19.5f);
            string QD = CapacitySchedulerConfiguration.Root + "." + D;

            conf.SetCapacity(QD, 20.5f);
            // Define 2-nd level queues
            conf.SetQueues(QA, new string[] { A1, A2 });
            conf.SetCapacity(QA + "." + A1, 50);
            conf.SetCapacity(QA + "." + A2, 50);
            conf.SetQueues(QB, new string[] { B1, B2, B3 });
            conf.SetCapacity(QB + "." + B1, 10);
            conf.SetCapacity(QB + "." + B2, 20);
            conf.SetCapacity(QB + "." + B3, 70);
            conf.SetQueues(QC, new string[] { C1 });
            string QC1 = QC + "." + C1;

            conf.SetCapacity(QC1, 100);
            conf.SetQueues(QC1, new string[] { C11 });
            string QC11 = QC1 + "." + C11;

            conf.SetCapacity(QC11, 100);
            conf.SetQueues(QC11, new string[] { C111 });
            string QC111 = QC11 + "." + C111;

            conf.SetCapacity(QC111, 100);
            //Leaf Queue
            conf.SetQueues(QC111, new string[] { C1111 });
            string QC1111 = QC111 + "." + C1111;

            conf.SetCapacity(QC1111, 100);
        }
Exemplo n.º 30
0
        public virtual void TestQueueParsingWithLabelsInherit()
        {
            nodeLabelManager.AddToCluserNodeLabels(ImmutableSet.Of("red", "blue"));
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfigurationWithLabelsInherit(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);

            rmContext.SetNodeLabelManager(nodeLabelManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            CheckQueueLabelsInheritConfig(capacityScheduler);
            ServiceOperations.StopQuietly(capacityScheduler);
        }