예제 #1
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));
        }
예제 #2
0
 /// <summary>
 /// Checks if the specified
 /// <see cref="SchedulingPolicy"/>
 /// can be used for a queue at
 /// the specified depth in the hierarchy
 /// </summary>
 /// <param name="policy">
 ///
 /// <see cref="SchedulingPolicy"/>
 /// we are checking the
 /// depth-applicability for
 /// </param>
 /// <param name="depth">queue's depth in the hierarchy</param>
 /// <returns>true if policy is applicable to passed depth, false otherwise</returns>
 public static bool IsApplicableTo(SchedulingPolicy policy, byte depth)
 {
     return(((policy.GetApplicableDepth() & depth) == depth) ? true : false);
 }