private static RMContext GetMockRMContext()
        {
            RMContext           rmContext = Org.Mockito.Mockito.Mock <RMContext>();
            RMNodeLabelsManager nlm       = new NullRMNodeLabelsManager();

            nlm.Init(new Configuration(false));
            Org.Mockito.Mockito.When(rmContext.GetNodeLabelManager()).ThenReturn(nlm);
            return(rmContext);
        }
Beispiel #2
0
 /// <exception cref="Sharpen.InstantiationException"/>
 /// <exception cref="System.MemberAccessException"/>
 protected internal override RMNodeLabelsManager CreateNodeLabelManager()
 {
     if (useNullRMNodeLabelsManager)
     {
         RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();
         mgr.Init(GetConfig());
         return(mgr);
     }
     else
     {
         return(base.CreateNodeLabelManager());
     }
 }
Beispiel #3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestContainerAllocationWithSingleUserLimits()
        {
            RMNodeLabelsManager mgr = new NullRMNodeLabelsManager();

            mgr.Init(conf);
            // set node -> label
            mgr.AddToCluserNodeLabels(ImmutableSet.Of("x", "y"));
            mgr.AddLabelsToNode(ImmutableMap.Of(NodeId.NewInstance("h1", 0), ToSet("x"), NodeId
                                                .NewInstance("h2", 0), ToSet("y")));
            // inject node label manager
            MockRM rm1 = new _MockRM_471(mgr, GetConfigurationWithDefaultQueueLabels(conf));

            rm1.GetRMContext().SetNodeLabelManager(mgr);
            rm1.Start();
            MockNM nm1 = rm1.RegisterNode("h1:1234", 8000);

            // label = x
            rm1.RegisterNode("h2:1234", 8000);
            // label = y
            MockNM nm3 = rm1.RegisterNode("h3:1234", 8000);
            // label = <empty>
            // launch an app to queue a1 (label = x), and check all container will
            // be allocated in h1
            RMApp  app1 = rm1.SubmitApp(200, "app", "user", null, "a1");
            MockAM am1  = MockRM.LaunchAndRegisterAM(app1, rm1, nm1);
            // A has only 10% of x, so it can only allocate one container in label=empty
            ContainerId containerId = ContainerId.NewContainerId(am1.GetApplicationAttemptId(
                                                                     ), 2);

            am1.Allocate("*", 1024, 1, new AList <ContainerId>(), string.Empty);
            NUnit.Framework.Assert.IsTrue(rm1.WaitForState(nm3, containerId, RMContainerState
                                                           .Allocated, 10 * 1000));
            // Cannot allocate 2nd label=empty container
            containerId = ContainerId.NewContainerId(am1.GetApplicationAttemptId(), 3);
            am1.Allocate("*", 1024, 1, new AList <ContainerId>(), string.Empty);
            NUnit.Framework.Assert.IsFalse(rm1.WaitForState(nm3, containerId, RMContainerState
                                                            .Allocated, 10 * 1000));
            // A has default user limit = 100, so it can use all resource in label = x
            // We can allocate floor(8000 / 1024) = 7 containers
            for (int id = 3; id <= 8; id++)
            {
                containerId = ContainerId.NewContainerId(am1.GetApplicationAttemptId(), id);
                am1.Allocate("*", 1024, 1, new AList <ContainerId>(), "x");
                NUnit.Framework.Assert.IsTrue(rm1.WaitForState(nm1, containerId, RMContainerState
                                                               .Allocated, 10 * 1000));
            }
            rm1.Close();
        }
        public virtual void TestQueueParsingWhenLabelsNotExist()
        {
            YarnConfiguration conf = new YarnConfiguration();
            CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);

            SetupQueueConfigurationWithLabels(csConf);
            CapacityScheduler capacityScheduler = new CapacityScheduler();
            RMContextImpl     rmContext         = new RMContextImpl(null, null, null, null, null, null, new
                                                                    RMContainerTokenSecretManager(csConf), new NMTokenSecretManagerInRM(csConf), new
                                                                    ClientToAMTokenSecretManagerInRM(), null);
            RMNodeLabelsManager nodeLabelsManager = new NullRMNodeLabelsManager();

            nodeLabelsManager.Init(conf);
            nodeLabelsManager.Start();
            rmContext.SetNodeLabelManager(nodeLabelsManager);
            capacityScheduler.SetConf(csConf);
            capacityScheduler.SetRMContext(rmContext);
            capacityScheduler.Init(csConf);
            capacityScheduler.Start();
            ServiceOperations.StopQuietly(capacityScheduler);
            ServiceOperations.StopQuietly(nodeLabelsManager);
        }