/// <exception cref="System.Exception"/> public virtual void TestReconnectedNode() { CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); conf.SetQueues("default", new string[] { "default" }); conf.SetCapacity("default", 100); FifoScheduler fs = new FifoScheduler(); fs.Init(conf); fs.Start(); // mock rmContext to avoid NPE. RMContext context = Org.Mockito.Mockito.Mock <RMContext>(); fs.Reinitialize(conf, null); fs.SetRMContext(context); RMNode n1 = MockNodes.NewNodeInfo(0, MockNodes.NewResource(4 * Gb), 1, "127.0.0.2" ); RMNode n2 = MockNodes.NewNodeInfo(0, MockNodes.NewResource(2 * Gb), 2, "127.0.0.3" ); fs.Handle(new NodeAddedSchedulerEvent(n1)); fs.Handle(new NodeAddedSchedulerEvent(n2)); fs.Handle(new NodeUpdateSchedulerEvent(n1)); NUnit.Framework.Assert.AreEqual(6 * Gb, fs.GetRootQueueMetrics().GetAvailableMB() ); // reconnect n1 with downgraded memory n1 = MockNodes.NewNodeInfo(0, MockNodes.NewResource(2 * Gb), 1, "127.0.0.2"); fs.Handle(new NodeRemovedSchedulerEvent(n1)); fs.Handle(new NodeAddedSchedulerEvent(n1)); fs.Handle(new NodeUpdateSchedulerEvent(n1)); NUnit.Framework.Assert.AreEqual(4 * Gb, fs.GetRootQueueMetrics().GetAvailableMB() ); fs.Stop(); }
public virtual void TestNodeUpdateBeforeAppAttemptInit() { FifoScheduler scheduler = new FifoScheduler(); MockRM rm = new MockRM(conf); scheduler.SetRMContext(rm.GetRMContext()); scheduler.Init(conf); scheduler.Start(); scheduler.Reinitialize(conf, rm.GetRMContext()); RMNode node = MockNodes.NewNodeInfo(1, Resources.CreateResource(1024, 4), 1, "127.0.0.1" ); scheduler.Handle(new NodeAddedSchedulerEvent(node)); ApplicationId appId = ApplicationId.NewInstance(0, 1); scheduler.AddApplication(appId, "queue1", "user1", false); NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node); try { scheduler.Handle(updateEvent); } catch (ArgumentNullException) { NUnit.Framework.Assert.Fail(); } ApplicationAttemptId attId = ApplicationAttemptId.NewInstance(appId, 1); scheduler.AddApplicationAttempt(attId, false, false); rm.Stop(); }