Ejemplo n.º 1
0
        public virtual void TestOffSwitchSchedulingMultiLevelQueues()
        {
            // Setup queue configs
            SetupMultiLevelQueues(csConf);
            //B3
            IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>();
            CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, CapacitySchedulerConfiguration
                                                        .Root, queues, queues, TestUtils.spyHook);
            // Setup some nodes
            int memoryPerNode        = 10;
            int coresPerNode         = 10;
            int numNodes             = 2;
            FiCaSchedulerNode node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, memoryPerNode
                                                             * Gb);
            FiCaSchedulerNode node_1 = TestUtils.GetMockNode("host_1", DefaultRack, 0, memoryPerNode
                                                             * Gb);

            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Resources.CreateResource
                                                                              (numNodes * (memoryPerNode * Gb), numNodes * coresPerNode);
            Org.Mockito.Mockito.When(csContext.GetNumClusterNodes()).ThenReturn(numNodes);
            // Start testing
            LeafQueue b3 = (LeafQueue)queues[B3];
            LeafQueue b2 = (LeafQueue)queues[B2];

            // Simulate B3 returning a container on node_0
            StubQueueAllocation(b2, clusterResource, node_0, 0 * Gb, NodeType.OffSwitch);
            StubQueueAllocation(b3, clusterResource, node_0, 1 * Gb, NodeType.OffSwitch);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            VerifyQueueMetrics(b2, 0 * Gb, clusterResource);
            VerifyQueueMetrics(b3, 1 * Gb, clusterResource);
            // Now, B2 should get the scheduling opportunity since B2=0G/2G, B3=1G/7G
            // also, B3 gets a scheduling opportunity since B2 allocates RACK_LOCAL
            StubQueueAllocation(b2, clusterResource, node_1, 1 * Gb, NodeType.RackLocal);
            StubQueueAllocation(b3, clusterResource, node_1, 1 * Gb, NodeType.OffSwitch);
            root.AssignContainers(clusterResource, node_1, new ResourceLimits(clusterResource
                                                                              ));
            InOrder allocationOrder = Org.Mockito.Mockito.InOrder(b2, b3);

            allocationOrder.Verify(b2).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                        <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(b3).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                        <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(b2, 1 * Gb, clusterResource);
            VerifyQueueMetrics(b3, 2 * Gb, clusterResource);
            // Now, B3 should get the scheduling opportunity
            // since B2 has 1/2G while B3 has 2/7G,
            // However, since B3 returns off-switch, B2 won't get an opportunity
            StubQueueAllocation(b2, clusterResource, node_0, 1 * Gb, NodeType.NodeLocal);
            StubQueueAllocation(b3, clusterResource, node_0, 1 * Gb, NodeType.OffSwitch);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            allocationOrder = Org.Mockito.Mockito.InOrder(b3, b2);
            allocationOrder.Verify(b3).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                        <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(b2).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                        <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(b2, 1 * Gb, clusterResource);
            VerifyQueueMetrics(b3, 3 * Gb, clusterResource);
        }
Ejemplo n.º 2
0
 private CSAssignment AssignContainersToChildQueues(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                    cluster, FiCaSchedulerNode node, ResourceLimits limits)
 {
     lock (this)
     {
         CSAssignment assignment = new CSAssignment(Resources.CreateResource(0, 0), NodeType
                                                    .NodeLocal);
         PrintChildQueues();
         // Try to assign to most 'under-served' sub-queue
         for (IEnumerator <CSQueue> iter = childQueues.GetEnumerator(); iter.HasNext();)
         {
             CSQueue childQueue = iter.Next();
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("Trying to assign to queue: " + childQueue.GetQueuePath() + " stats: "
                           + childQueue);
             }
             // Get ResourceLimits of child queue before assign containers
             ResourceLimits childLimits = GetResourceLimitsOfChild(childQueue, cluster, limits
                                                                   );
             assignment = childQueue.AssignContainers(cluster, node, childLimits);
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("Assigned to queue: " + childQueue.GetQueuePath() + " stats: " + childQueue
                           + " --> " + assignment.GetResource() + ", " + assignment.GetType());
             }
             // If we do assign, remove the queue and re-insert in-order to re-sort
             if (Resources.GreaterThan(resourceCalculator, cluster, assignment.GetResource(),
                                       Resources.None()))
             {
                 // Remove and re-insert to sort
                 iter.Remove();
                 Log.Info("Re-sorting assigned queue: " + childQueue.GetQueuePath() + " stats: " +
                          childQueue);
                 childQueues.AddItem(childQueue);
                 if (Log.IsDebugEnabled())
                 {
                     PrintChildQueues();
                 }
                 break;
             }
         }
         return(assignment);
     }
 }
Ejemplo n.º 3
0
        public virtual void TestMultiLevelQueues()
        {
            /*
             * Structure of queue:
             *            Root
             *           ____________
             *          /    |   \   \
             *         A     B    C   D
             *       / |   / | \   \
             *      A1 A2 B1 B2 B3  C1
             *                        \
             *                         C11
             *                           \
             *                           C111
             *                             \
             *                              C1111
             */
            // Setup queue configs
            SetupMultiLevelQueues(csConf);
            IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>();
            CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, CapacitySchedulerConfiguration
                                                        .Root, queues, queues, TestUtils.spyHook);
            // Setup some nodes
            int memoryPerNode        = 10;
            int coresPerNode         = 16;
            int numNodes             = 3;
            FiCaSchedulerNode node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, memoryPerNode
                                                             * Gb);
            FiCaSchedulerNode node_1 = TestUtils.GetMockNode("host_1", DefaultRack, 0, memoryPerNode
                                                             * Gb);
            FiCaSchedulerNode node_2 = TestUtils.GetMockNode("host_2", DefaultRack, 0, memoryPerNode
                                                             * Gb);

            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Resources.CreateResource
                                                                              (numNodes * (memoryPerNode * Gb), numNodes * coresPerNode);
            Org.Mockito.Mockito.When(csContext.GetNumClusterNodes()).ThenReturn(numNodes);
            // Start testing
            CSQueue a  = queues[A];
            CSQueue b  = queues[B];
            CSQueue c  = queues[C];
            CSQueue d  = queues[D];
            CSQueue a1 = queues[A1];
            CSQueue a2 = queues[A2];
            CSQueue b1 = queues[B1];
            CSQueue b2 = queues[B2];
            CSQueue b3 = queues[B3];

            // Simulate C returning a container on node_0
            StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(c, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            VerifyQueueMetrics(a, 0 * Gb, clusterResource);
            VerifyQueueMetrics(b, 0 * Gb, clusterResource);
            VerifyQueueMetrics(c, 1 * Gb, clusterResource);
            VerifyQueueMetrics(d, 0 * Gb, clusterResource);
            Org.Mockito.Mockito.Reset(a);
            Org.Mockito.Mockito.Reset(b);
            Org.Mockito.Mockito.Reset(c);
            // Now get B2 to allocate
            // A = 0/3, B = 0/15, C = 1/6, D=0/6
            StubQueueAllocation(a, clusterResource, node_1, 0 * Gb);
            StubQueueAllocation(b2, clusterResource, node_1, 4 * Gb);
            StubQueueAllocation(c, clusterResource, node_1, 0 * Gb);
            root.AssignContainers(clusterResource, node_1, new ResourceLimits(clusterResource
                                                                              ));
            VerifyQueueMetrics(a, 0 * Gb, clusterResource);
            VerifyQueueMetrics(b, 4 * Gb, clusterResource);
            VerifyQueueMetrics(c, 1 * Gb, clusterResource);
            Org.Mockito.Mockito.Reset(a);
            Org.Mockito.Mockito.Reset(b);
            Org.Mockito.Mockito.Reset(c);
            // Now get both A1, C & B3 to allocate in right order
            // A = 0/3, B = 4/15, C = 1/6, D=0/6
            StubQueueAllocation(a1, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(b3, clusterResource, node_0, 2 * Gb);
            StubQueueAllocation(c, clusterResource, node_0, 2 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            InOrder allocationOrder = Org.Mockito.Mockito.InOrder(a, c, b);

            allocationOrder.Verify(a).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(c).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(a, 1 * Gb, clusterResource);
            VerifyQueueMetrics(b, 6 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            Org.Mockito.Mockito.Reset(a);
            Org.Mockito.Mockito.Reset(b);
            Org.Mockito.Mockito.Reset(c);
            // Now verify max-capacity
            // A = 1/3, B = 6/15, C = 3/6, D=0/6
            // Ensure a1 won't alloc above max-cap although it should get
            // scheduling opportunity now, right after a2
            Log.Info("here");
            ((ParentQueue)a).SetMaxCapacity(.1f);
            // a should be capped at 3/30
            StubQueueAllocation(a1, clusterResource, node_2, 1 * Gb);
            // shouldn't be
            // allocated due
            // to max-cap
            StubQueueAllocation(a2, clusterResource, node_2, 2 * Gb);
            StubQueueAllocation(b3, clusterResource, node_2, 1 * Gb);
            StubQueueAllocation(b1, clusterResource, node_2, 1 * Gb);
            StubQueueAllocation(c, clusterResource, node_2, 1 * Gb);
            root.AssignContainers(clusterResource, node_2, new ResourceLimits(clusterResource
                                                                              ));
            allocationOrder = Org.Mockito.Mockito.InOrder(a, a2, a1, b, c);
            allocationOrder.Verify(a).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(a2).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                        <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(c).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(a, 3 * Gb, clusterResource);
            VerifyQueueMetrics(b, 8 * Gb, clusterResource);
            VerifyQueueMetrics(c, 4 * Gb, clusterResource);
            Org.Mockito.Mockito.Reset(a);
            Org.Mockito.Mockito.Reset(b);
            Org.Mockito.Mockito.Reset(c);
        }
Ejemplo n.º 4
0
        public virtual void TestSingleLevelQueues()
        {
            // Setup queue configs
            SetupSingleLevelQueues(csConf);
            IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>();
            CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, CapacitySchedulerConfiguration
                                                        .Root, queues, queues, TestUtils.spyHook);
            // Setup some nodes
            int memoryPerNode        = 10;
            int coresPerNode         = 16;
            int numNodes             = 2;
            FiCaSchedulerNode node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, memoryPerNode
                                                             * Gb);
            FiCaSchedulerNode node_1 = TestUtils.GetMockNode("host_1", DefaultRack, 0, memoryPerNode
                                                             * Gb);

            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Resources.CreateResource
                                                                              (numNodes * (memoryPerNode * Gb), numNodes * coresPerNode);
            Org.Mockito.Mockito.When(csContext.GetNumClusterNodes()).ThenReturn(numNodes);
            // Start testing
            LeafQueue a = (LeafQueue)queues[A];
            LeafQueue b = (LeafQueue)queues[B];

            // Simulate B returning a container on node_0
            StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 1 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            VerifyQueueMetrics(a, 0 * Gb, clusterResource);
            VerifyQueueMetrics(b, 1 * Gb, clusterResource);
            // Now, A should get the scheduling opportunity since A=0G/6G, B=1G/14G
            StubQueueAllocation(a, clusterResource, node_1, 2 * Gb);
            StubQueueAllocation(b, clusterResource, node_1, 1 * Gb);
            root.AssignContainers(clusterResource, node_1, new ResourceLimits(clusterResource
                                                                              ));
            InOrder allocationOrder = Org.Mockito.Mockito.InOrder(a, b);

            allocationOrder.Verify(a).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(a, 2 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            // Now, B should get the scheduling opportunity
            // since A has 2/6G while B has 2/14G
            StubQueueAllocation(a, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 2 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            allocationOrder = Org.Mockito.Mockito.InOrder(b, a);
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(a).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(a, 3 * Gb, clusterResource);
            VerifyQueueMetrics(b, 4 * Gb, clusterResource);
            // Now, B should still get the scheduling opportunity
            // since A has 3/6G while B has 4/14G
            StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 4 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            allocationOrder = Org.Mockito.Mockito.InOrder(b, a);
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(a).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(a, 3 * Gb, clusterResource);
            VerifyQueueMetrics(b, 8 * Gb, clusterResource);
            // Now, A should get the scheduling opportunity
            // since A has 3/6G while B has 8/14G
            StubQueueAllocation(a, clusterResource, node_1, 1 * Gb);
            StubQueueAllocation(b, clusterResource, node_1, 1 * Gb);
            root.AssignContainers(clusterResource, node_1, new ResourceLimits(clusterResource
                                                                              ));
            allocationOrder = Org.Mockito.Mockito.InOrder(a, b);
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            allocationOrder.Verify(a).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), AnyResourceLimits());
            VerifyQueueMetrics(a, 4 * Gb, clusterResource);
            VerifyQueueMetrics(b, 9 * Gb, clusterResource);
        }
Ejemplo n.º 5
0
        public virtual void TestSortedQueues()
        {
            // Setup queue configs
            SetupSortedQueues(csConf);
            IDictionary <string, CSQueue> queues = new Dictionary <string, CSQueue>();
            CSQueue root = CapacityScheduler.ParseQueue(csContext, csConf, null, CapacitySchedulerConfiguration
                                                        .Root, queues, queues, TestUtils.spyHook);
            // Setup some nodes
            int memoryPerNode        = 10;
            int coresPerNode         = 16;
            int numNodes             = 1;
            FiCaSchedulerNode node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, memoryPerNode
                                                             * Gb);

            Org.Mockito.Mockito.DoNothing().When(node_0).ReleaseContainer(Matchers.Any <Container
                                                                                        >());
            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Resources.CreateResource
                                                                              (numNodes * (memoryPerNode * Gb), numNodes * coresPerNode);
            Org.Mockito.Mockito.When(csContext.GetNumClusterNodes()).ThenReturn(numNodes);
            // Start testing
            CSQueue a      = queues[A];
            CSQueue b      = queues[B];
            CSQueue c      = queues[C];
            CSQueue d      = queues[D];
            string  user_0 = "user_0";
            // Stub an App and its containerCompleted
            FiCaSchedulerApp app_0 = GetMockApplication(0, user_0);

            Org.Mockito.Mockito.DoReturn(true).When(app_0).ContainerCompleted(Matchers.Any <RMContainer
                                                                                            >(), Matchers.Any <ContainerStatus>(), Matchers.Any <RMContainerEventType>());
            Priority priority = TestUtils.CreateMockPriority(1);
            ContainerAllocationExpirer expirer = Org.Mockito.Mockito.Mock <ContainerAllocationExpirer
                                                                           >();
            DrainDispatcher            drainDispatcher = new DrainDispatcher();
            RMApplicationHistoryWriter writer          = Org.Mockito.Mockito.Mock <RMApplicationHistoryWriter
                                                                                   >();
            SystemMetricsPublisher publisher = Org.Mockito.Mockito.Mock <SystemMetricsPublisher
                                                                         >();
            RMContext rmContext = Org.Mockito.Mockito.Mock <RMContext>();

            Org.Mockito.Mockito.When(rmContext.GetContainerAllocationExpirer()).ThenReturn(expirer
                                                                                           );
            Org.Mockito.Mockito.When(rmContext.GetDispatcher()).ThenReturn(drainDispatcher);
            Org.Mockito.Mockito.When(rmContext.GetRMApplicationHistoryWriter()).ThenReturn(writer
                                                                                           );
            Org.Mockito.Mockito.When(rmContext.GetSystemMetricsPublisher()).ThenReturn(publisher
                                                                                       );
            Org.Mockito.Mockito.When(rmContext.GetYarnConfiguration()).ThenReturn(new YarnConfiguration
                                                                                      ());
            ApplicationAttemptId appAttemptId = BuilderUtils.NewApplicationAttemptId(app_0.GetApplicationId
                                                                                         (), 1);
            ContainerId containerId = BuilderUtils.NewContainerId(appAttemptId, 1);
            Container   container   = TestUtils.GetMockContainer(containerId, node_0.GetNodeID(),
                                                                 Resources.CreateResource(1 * Gb), priority);
            RMContainer rmContainer = new RMContainerImpl(container, appAttemptId, node_0.GetNodeID
                                                              (), "user", rmContext);

            // Assign {1,2,3,4} 1GB containers respectively to queues
            StubQueueAllocation(a, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            for (int i = 0; i < 2; i++)
            {
                StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(b, clusterResource, node_0, 1 * Gb);
                StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
                root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                                  ));
            }
            for (int i_1 = 0; i_1 < 3; i_1++)
            {
                StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(b, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(c, clusterResource, node_0, 1 * Gb);
                StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
                root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                                  ));
            }
            for (int i_2 = 0; i_2 < 4; i_2++)
            {
                StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(b, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(d, clusterResource, node_0, 1 * Gb);
                root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                                  ));
            }
            VerifyQueueMetrics(a, 1 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 4 * Gb, clusterResource);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            //Release 3 x 1GB containers from D
            for (int i_3 = 0; i_3 < 3; i_3++)
            {
                d.CompletedContainer(clusterResource, app_0, node_0, rmContainer, null, RMContainerEventType
                                     .Kill, null, true);
            }
            VerifyQueueMetrics(a, 1 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 1 * Gb, clusterResource);
            //reset manually resources on node
            node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, (memoryPerNode - 1 - 2 -
                                                                      3 - 1) * Gb);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            // Assign 2 x 1GB Containers to A
            for (int i_4 = 0; i_4 < 2; i_4++)
            {
                StubQueueAllocation(a, clusterResource, node_0, 1 * Gb);
                StubQueueAllocation(b, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
                StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
                root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                                  ));
            }
            VerifyQueueMetrics(a, 3 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 1 * Gb, clusterResource);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            //Release 1GB Container from A
            a.CompletedContainer(clusterResource, app_0, node_0, rmContainer, null, RMContainerEventType
                                 .Kill, null, true);
            VerifyQueueMetrics(a, 2 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 1 * Gb, clusterResource);
            //reset manually resources on node
            node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, (memoryPerNode - 2 - 2 -
                                                                      3 - 1) * Gb);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            // Assign 1GB container to B
            StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            VerifyQueueMetrics(a, 2 * Gb, clusterResource);
            VerifyQueueMetrics(b, 3 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 1 * Gb, clusterResource);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            //Release 1GB container resources from B
            b.CompletedContainer(clusterResource, app_0, node_0, rmContainer, null, RMContainerEventType
                                 .Kill, null, true);
            VerifyQueueMetrics(a, 2 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 1 * Gb, clusterResource);
            //reset manually resources on node
            node_0 = TestUtils.GetMockNode("host_0", DefaultRack, 0, (memoryPerNode - 2 - 2 -
                                                                      3 - 1) * Gb);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            // Assign 1GB container to A
            StubQueueAllocation(a, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(d, clusterResource, node_0, 0 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            VerifyQueueMetrics(a, 3 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 1 * Gb, clusterResource);
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
            // Now do the real test, where B and D request a 1GB container
            // D should should get the next container if the order is correct
            StubQueueAllocation(a, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(b, clusterResource, node_0, 1 * Gb);
            StubQueueAllocation(c, clusterResource, node_0, 0 * Gb);
            StubQueueAllocation(d, clusterResource, node_0, 1 * Gb);
            root.AssignContainers(clusterResource, node_0, new ResourceLimits(clusterResource
                                                                              ));
            InOrder allocationOrder = Org.Mockito.Mockito.InOrder(d, b);

            allocationOrder.Verify(d).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), Matchers.Any <ResourceLimits>());
            allocationOrder.Verify(b).AssignContainers(Matchers.Eq(clusterResource), Matchers.Any
                                                       <FiCaSchedulerNode>(), Matchers.Any <ResourceLimits>());
            VerifyQueueMetrics(a, 3 * Gb, clusterResource);
            VerifyQueueMetrics(b, 2 * Gb, clusterResource);
            VerifyQueueMetrics(c, 3 * Gb, clusterResource);
            VerifyQueueMetrics(d, 2 * Gb, clusterResource);
            //D got the container
            Log.Info("status child-queues: " + ((ParentQueue)root).GetChildQueuesToPrint());
        }