Exemplo n.º 1
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();
        }