Пример #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestExcessReservationThanNodeManagerCapacity()
        {
            MockRM rm = new MockRM(conf);

            rm.Start();
            // Register node1
            MockNM nm1 = rm.RegisterNode("127.0.0.1:1234", 2 * Gb, 4);
            MockNM nm2 = rm.RegisterNode("127.0.0.1:2234", 3 * Gb, 4);

            nm1.NodeHeartbeat(true);
            nm2.NodeHeartbeat(true);
            // wait..
            int waitCount = 20;
            int size      = rm.GetRMContext().GetRMNodes().Count;

            while ((size = rm.GetRMContext().GetRMNodes().Count) != 2 && waitCount-- > 0)
            {
                Log.Info("Waiting for node managers to register : " + size);
                Sharpen.Thread.Sleep(100);
            }
            NUnit.Framework.Assert.AreEqual(2, rm.GetRMContext().GetRMNodes().Count);
            // Submit an application
            RMApp app1 = rm.SubmitApp(128);

            // kick the scheduling
            nm1.NodeHeartbeat(true);
            RMAppAttempt attempt1 = app1.GetCurrentAppAttempt();
            MockAM       am1      = rm.SendAMLaunched(attempt1.GetAppAttemptId());

            am1.RegisterAppAttempt();
            Log.Info("sending container requests ");
            am1.AddRequests(new string[] { "*" }, 2 * Gb, 1, 1);
            AllocateResponse alloc1Response = am1.Schedule();

            // send the request
            // kick the scheduler
            nm1.NodeHeartbeat(true);
            int waitCounter = 20;

            Log.Info("heartbeating nm1");
            while (alloc1Response.GetAllocatedContainers().Count < 1 && waitCounter-- > 0)
            {
                Log.Info("Waiting for containers to be created for app 1...");
                Sharpen.Thread.Sleep(500);
                alloc1Response = am1.Schedule();
            }
            Log.Info("received container : " + alloc1Response.GetAllocatedContainers().Count);
            // No container should be allocated.
            // Internally it should not been reserved.
            NUnit.Framework.Assert.IsTrue(alloc1Response.GetAllocatedContainers().Count == 0);
            Log.Info("heartbeating nm2");
            waitCounter = 20;
            nm2.NodeHeartbeat(true);
            while (alloc1Response.GetAllocatedContainers().Count < 1 && waitCounter-- > 0)
            {
                Log.Info("Waiting for containers to be created for app 1...");
                Sharpen.Thread.Sleep(500);
                alloc1Response = am1.Schedule();
            }
            Log.Info("received container : " + alloc1Response.GetAllocatedContainers().Count);
            NUnit.Framework.Assert.IsTrue(alloc1Response.GetAllocatedContainers().Count == 1);
            rm.Stop();
        }