Esempio n. 1
0
 internal CapacitySchedulerLeafQueueInfo(LeafQueue q)
     : base(q)
 {
     // To add another level in the XML
     numActiveApplications  = q.GetNumActiveApplications();
     numPendingApplications = q.GetNumPendingApplications();
     numContainers          = q.GetNumContainers();
     maxApplications        = q.GetMaxApplications();
     maxApplicationsPerUser = q.GetMaxApplicationsPerUser();
     userLimit           = q.GetUserLimit();
     users               = new UsersInfo(q.GetUsers());
     userLimitFactor     = q.GetUserLimitFactor();
     AMResourceLimit     = new ResourceInfo(q.GetAMResourceLimit());
     usedAMResource      = new ResourceInfo(q.GetQueueResourceUsage().GetAMUsed());
     userAMResourceLimit = new ResourceInfo(q.GetUserAMResourceLimit());
     preemptionDisabled  = q.GetPreemptionDisabled();
 }
Esempio n. 2
0
        public virtual void TestAMResourceLimit()
        {
            string user_0 = "user_0";
            string user_1 = "user_1";

            // This uses the default 10% of cluster value for the max am resources
            // which are allowed, at 80GB = 8GB for AM's at the queue level.  The user
            // am limit is 4G initially (based on the queue absolute capacity)
            // when there is only 1 user, and drops to 2G (the userlimit) when there
            // is a second user
            Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource = Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                                          .NewInstance(80 * Gb, 40);
            queue.UpdateClusterResource(clusterResource, new ResourceLimits(clusterResource));
            ActiveUsersManager activeUsersManager = Org.Mockito.Mockito.Mock <ActiveUsersManager
                                                                              >();

            Org.Mockito.Mockito.When(queue.GetActiveUsersManager()).ThenReturn(activeUsersManager
                                                                               );
            NUnit.Framework.Assert.AreEqual(Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance
                                                (8 * Gb, 1), queue.GetAMResourceLimit());
            NUnit.Framework.Assert.AreEqual(Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance
                                                (4 * Gb, 1), queue.GetUserAMResourceLimit());
            // Two apps for user_0, both start
            int ApplicationId      = 0;
            FiCaSchedulerApp app_0 = GetMockApplication(ApplicationId++, user_0, Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                        .NewInstance(2 * Gb, 1));

            queue.SubmitApplicationAttempt(app_0, user_0);
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumActiveApplications());
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications());
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumActiveApplications(user_0));
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications(user_0));
            Org.Mockito.Mockito.When(activeUsersManager.GetNumActiveUsers()).ThenReturn(1);
            FiCaSchedulerApp app_1 = GetMockApplication(ApplicationId++, user_0, Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                        .NewInstance(2 * Gb, 1));

            queue.SubmitApplicationAttempt(app_1, user_0);
            NUnit.Framework.Assert.AreEqual(2, queue.GetNumActiveApplications());
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications());
            NUnit.Framework.Assert.AreEqual(2, queue.GetNumActiveApplications(user_0));
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications(user_0));
            // AMLimits unchanged
            NUnit.Framework.Assert.AreEqual(Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance
                                                (8 * Gb, 1), queue.GetAMResourceLimit());
            NUnit.Framework.Assert.AreEqual(Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance
                                                (4 * Gb, 1), queue.GetUserAMResourceLimit());
            // One app for user_1, starts
            FiCaSchedulerApp app_2 = GetMockApplication(ApplicationId++, user_1, Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                        .NewInstance(2 * Gb, 1));

            queue.SubmitApplicationAttempt(app_2, user_1);
            NUnit.Framework.Assert.AreEqual(3, queue.GetNumActiveApplications());
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications());
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumActiveApplications(user_1));
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications(user_1));
            Org.Mockito.Mockito.When(activeUsersManager.GetNumActiveUsers()).ThenReturn(2);
            // Now userAMResourceLimit drops to the queue configured 50% as there is
            // another user active
            NUnit.Framework.Assert.AreEqual(Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance
                                                (8 * Gb, 1), queue.GetAMResourceLimit());
            NUnit.Framework.Assert.AreEqual(Org.Apache.Hadoop.Yarn.Api.Records.Resource.NewInstance
                                                (2 * Gb, 1), queue.GetUserAMResourceLimit());
            // Second user_1 app cannot start
            FiCaSchedulerApp app_3 = GetMockApplication(ApplicationId++, user_1, Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                        .NewInstance(2 * Gb, 1));

            queue.SubmitApplicationAttempt(app_3, user_1);
            NUnit.Framework.Assert.AreEqual(3, queue.GetNumActiveApplications());
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumPendingApplications());
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumActiveApplications(user_1));
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumPendingApplications(user_1));
            // Now finish app so another should be activated
            queue.FinishApplicationAttempt(app_2, A);
            NUnit.Framework.Assert.AreEqual(3, queue.GetNumActiveApplications());
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications());
            NUnit.Framework.Assert.AreEqual(1, queue.GetNumActiveApplications(user_1));
            NUnit.Framework.Assert.AreEqual(0, queue.GetNumPendingApplications(user_1));
        }