/// <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(); }