示例#1
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.AllocationConfigurationException
 ///     "/>
 public override void SetPolicy(SchedulingPolicy policy)
 {
     if (!SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy.DepthLeaf))
     {
         ThrowPolicyDoesnotApplyException(policy);
     }
     base.policy = policy;
 }
示例#2
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.AllocationConfigurationException
        ///     "/>
        public override void SetPolicy(SchedulingPolicy policy)
        {
            bool allowed = SchedulingPolicy.IsApplicableTo(policy, (parent == null) ? SchedulingPolicy
                                                           .DepthRoot : SchedulingPolicy.DepthIntermediate);

            if (!allowed)
            {
                ThrowPolicyDoesnotApplyException(policy);
            }
            base.policy = policy;
        }
示例#3
0
        /// <summary>
        /// Trivial tests that make sure
        /// <see cref="SchedulingPolicy.IsApplicableTo(SchedulingPolicy, byte)"/>
        /// works as
        /// expected for the possible values of depth
        /// </summary>
        /// <exception cref="AllocationConfigurationException"/>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Fair.AllocationConfigurationException
        ///     "/>
        public virtual void TestIsApplicableTo()
        {
            string Err = "Broken SchedulingPolicy#isApplicableTo";
            // fifo
            SchedulingPolicy policy = SchedulingPolicy.Parse("fifo");

            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthLeaf));
            NUnit.Framework.Assert.IsFalse(Err, SchedulingPolicy.IsApplicableTo(SchedulingPolicy
                                                                                .Parse("fifo"), SchedulingPolicy.DepthIntermediate));
            NUnit.Framework.Assert.IsFalse(Err, SchedulingPolicy.IsApplicableTo(SchedulingPolicy
                                                                                .Parse("fifo"), SchedulingPolicy.DepthRoot));
            // fair
            policy = SchedulingPolicy.Parse("fair");
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthLeaf));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthIntermediate));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthRoot));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthParent));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthAny));
            // drf
            policy = SchedulingPolicy.Parse("drf");
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthLeaf));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthIntermediate));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthRoot));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthParent));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthAny));
            policy = Org.Mockito.Mockito.Mock <SchedulingPolicy>();
            Org.Mockito.Mockito.When(policy.GetApplicableDepth()).ThenReturn(SchedulingPolicy
                                                                             .DepthParent);
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthIntermediate));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthRoot));
            NUnit.Framework.Assert.IsTrue(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                               .DepthParent));
            NUnit.Framework.Assert.IsFalse(Err, SchedulingPolicy.IsApplicableTo(policy, SchedulingPolicy
                                                                                .DepthAny));
        }