Ejemplo n.º 1
0
        public virtual void TestDelayScheduling()
        {
            FSLeafQueue queue = Org.Mockito.Mockito.Mock <FSLeafQueue>();
            Priority    prio  = Org.Mockito.Mockito.Mock <Priority>();

            Org.Mockito.Mockito.When(prio.GetPriority()).ThenReturn(1);
            double nodeLocalityThreshold = .5;
            double rackLocalityThreshold = .6;
            ApplicationAttemptId applicationAttemptId = CreateAppAttemptId(1, 1);
            RMContext            rmContext            = resourceManager.GetRMContext();
            FSAppAttempt         schedulerApp         = new FSAppAttempt(scheduler, applicationAttemptId, "user1"
                                                                         , queue, null, rmContext);

            // Default level should be node-local
            NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevel
                                                (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            // First five scheduling opportunities should remain node local
            for (int i = 0; i < 5; i++)
            {
                schedulerApp.AddSchedulingOpportunity(prio);
                NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevel
                                                    (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            }
            // After five it should switch to rack local
            schedulerApp.AddSchedulingOpportunity(prio);
            NUnit.Framework.Assert.AreEqual(NodeType.RackLocal, schedulerApp.GetAllowedLocalityLevel
                                                (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            // Manually set back to node local
            schedulerApp.ResetAllowedLocalityLevel(prio, NodeType.NodeLocal);
            schedulerApp.ResetSchedulingOpportunities(prio);
            NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevel
                                                (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            // Now escalate again to rack-local, then to off-switch
            for (int i_1 = 0; i_1 < 5; i_1++)
            {
                schedulerApp.AddSchedulingOpportunity(prio);
                NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevel
                                                    (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            }
            schedulerApp.AddSchedulingOpportunity(prio);
            NUnit.Framework.Assert.AreEqual(NodeType.RackLocal, schedulerApp.GetAllowedLocalityLevel
                                                (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            for (int i_2 = 0; i_2 < 6; i_2++)
            {
                schedulerApp.AddSchedulingOpportunity(prio);
                NUnit.Framework.Assert.AreEqual(NodeType.RackLocal, schedulerApp.GetAllowedLocalityLevel
                                                    (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
            }
            schedulerApp.AddSchedulingOpportunity(prio);
            NUnit.Framework.Assert.AreEqual(NodeType.OffSwitch, schedulerApp.GetAllowedLocalityLevel
                                                (prio, 10, nodeLocalityThreshold, rackLocalityThreshold));
        }
Ejemplo n.º 2
0
        public virtual void TestDelaySchedulingForContinuousScheduling()
        {
            FSLeafQueue queue = scheduler.GetQueueManager().GetLeafQueue("queue", true);
            Priority    prio  = Org.Mockito.Mockito.Mock <Priority>();

            Org.Mockito.Mockito.When(prio.GetPriority()).ThenReturn(1);
            TestFSAppAttempt.MockClock clock = new TestFSAppAttempt.MockClock(this);
            scheduler.SetClock(clock);
            long nodeLocalityDelayMs = 5 * 1000L;
            // 5 seconds
            long rackLocalityDelayMs = 6 * 1000L;
            // 6 seconds
            RMContext            rmContext            = resourceManager.GetRMContext();
            ApplicationAttemptId applicationAttemptId = CreateAppAttemptId(1, 1);
            FSAppAttempt         schedulerApp         = new FSAppAttempt(scheduler, applicationAttemptId, "user1"
                                                                         , queue, null, rmContext);

            // Default level should be node-local
            NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevelByTime
                                                (prio, nodeLocalityDelayMs, rackLocalityDelayMs, clock.GetTime()));
            // after 4 seconds should remain node local
            clock.Tick(4);
            NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevelByTime
                                                (prio, nodeLocalityDelayMs, rackLocalityDelayMs, clock.GetTime()));
            // after 6 seconds should switch to rack local
            clock.Tick(2);
            NUnit.Framework.Assert.AreEqual(NodeType.RackLocal, schedulerApp.GetAllowedLocalityLevelByTime
                                                (prio, nodeLocalityDelayMs, rackLocalityDelayMs, clock.GetTime()));
            // manually set back to node local
            schedulerApp.ResetAllowedLocalityLevel(prio, NodeType.NodeLocal);
            schedulerApp.ResetSchedulingOpportunities(prio, clock.GetTime());
            NUnit.Framework.Assert.AreEqual(NodeType.NodeLocal, schedulerApp.GetAllowedLocalityLevelByTime
                                                (prio, nodeLocalityDelayMs, rackLocalityDelayMs, clock.GetTime()));
            // Now escalate again to rack-local, then to off-switch
            clock.Tick(6);
            NUnit.Framework.Assert.AreEqual(NodeType.RackLocal, schedulerApp.GetAllowedLocalityLevelByTime
                                                (prio, nodeLocalityDelayMs, rackLocalityDelayMs, clock.GetTime()));
            clock.Tick(7);
            NUnit.Framework.Assert.AreEqual(NodeType.OffSwitch, schedulerApp.GetAllowedLocalityLevelByTime
                                                (prio, nodeLocalityDelayMs, rackLocalityDelayMs, clock.GetTime()));
        }