示例#1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestContainerUpdate()
        {
            //Start the node
            node.Handle(new RMNodeStartedEvent(null, null, null));
            NodeId     nodeId = BuilderUtils.NewNodeId("localhost:1", 1);
            RMNodeImpl node2  = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null
                                               );

            node2.Handle(new RMNodeStartedEvent(null, null, null));
            ContainerId completedContainerIdFromNode1 = BuilderUtils.NewContainerId(BuilderUtils
                                                                                    .NewApplicationAttemptId(BuilderUtils.NewApplicationId(0, 0), 0), 0);
            ContainerId completedContainerIdFromNode2_1 = BuilderUtils.NewContainerId(BuilderUtils
                                                                                      .NewApplicationAttemptId(BuilderUtils.NewApplicationId(1, 1), 1), 1);
            ContainerId completedContainerIdFromNode2_2 = BuilderUtils.NewContainerId(BuilderUtils
                                                                                      .NewApplicationAttemptId(BuilderUtils.NewApplicationId(1, 1), 1), 2);
            RMNodeStatusEvent statusEventFromNode1     = GetMockRMNodeStatusEvent();
            RMNodeStatusEvent statusEventFromNode2_1   = GetMockRMNodeStatusEvent();
            RMNodeStatusEvent statusEventFromNode2_2   = GetMockRMNodeStatusEvent();
            ContainerStatus   containerStatusFromNode1 = Org.Mockito.Mockito.Mock <ContainerStatus
                                                                                   >();
            ContainerStatus containerStatusFromNode2_1 = Org.Mockito.Mockito.Mock <ContainerStatus
                                                                                   >();
            ContainerStatus containerStatusFromNode2_2 = Org.Mockito.Mockito.Mock <ContainerStatus
                                                                                   >();

            Org.Mockito.Mockito.DoReturn(completedContainerIdFromNode1).When(containerStatusFromNode1
                                                                             ).GetContainerId();
            Org.Mockito.Mockito.DoReturn(Sharpen.Collections.SingletonList(containerStatusFromNode1
                                                                           )).When(statusEventFromNode1).GetContainers();
            node.Handle(statusEventFromNode1);
            NUnit.Framework.Assert.AreEqual(1, completedContainers.Count);
            NUnit.Framework.Assert.AreEqual(completedContainerIdFromNode1, completedContainers
                                            [0].GetContainerId());
            completedContainers.Clear();
            Org.Mockito.Mockito.DoReturn(completedContainerIdFromNode2_1).When(containerStatusFromNode2_1
                                                                               ).GetContainerId();
            Org.Mockito.Mockito.DoReturn(Sharpen.Collections.SingletonList(containerStatusFromNode2_1
                                                                           )).When(statusEventFromNode2_1).GetContainers();
            Org.Mockito.Mockito.DoReturn(completedContainerIdFromNode2_2).When(containerStatusFromNode2_2
                                                                               ).GetContainerId();
            Org.Mockito.Mockito.DoReturn(Sharpen.Collections.SingletonList(containerStatusFromNode2_2
                                                                           )).When(statusEventFromNode2_2).GetContainers();
            node2.SetNextHeartBeat(false);
            node2.Handle(statusEventFromNode2_1);
            node2.SetNextHeartBeat(true);
            node2.Handle(statusEventFromNode2_2);
            NUnit.Framework.Assert.AreEqual(2, completedContainers.Count);
            NUnit.Framework.Assert.AreEqual(completedContainerIdFromNode2_1, completedContainers
                                            [0].GetContainerId());
            NUnit.Framework.Assert.AreEqual(completedContainerIdFromNode2_2, completedContainers
                                            [1].GetContainerId());
        }
示例#2
0
        public virtual void TestStatusChange()
        {
            //Start the node
            node.Handle(new RMNodeStartedEvent(null, null, null));
            //Add info to the queue first
            node.SetNextHeartBeat(false);
            ContainerId completedContainerId1 = BuilderUtils.NewContainerId(BuilderUtils.NewApplicationAttemptId
                                                                                (BuilderUtils.NewApplicationId(0, 0), 0), 0);
            ContainerId completedContainerId2 = BuilderUtils.NewContainerId(BuilderUtils.NewApplicationAttemptId
                                                                                (BuilderUtils.NewApplicationId(1, 1), 1), 1);
            RMNodeStatusEvent statusEvent1     = GetMockRMNodeStatusEvent();
            RMNodeStatusEvent statusEvent2     = GetMockRMNodeStatusEvent();
            ContainerStatus   containerStatus1 = Org.Mockito.Mockito.Mock <ContainerStatus>();
            ContainerStatus   containerStatus2 = Org.Mockito.Mockito.Mock <ContainerStatus>();

            Org.Mockito.Mockito.DoReturn(completedContainerId1).When(containerStatus1).GetContainerId
                ();
            Org.Mockito.Mockito.DoReturn(Sharpen.Collections.SingletonList(containerStatus1))
            .When(statusEvent1).GetContainers();
            Org.Mockito.Mockito.DoReturn(completedContainerId2).When(containerStatus2).GetContainerId
                ();
            Org.Mockito.Mockito.DoReturn(Sharpen.Collections.SingletonList(containerStatus2))
            .When(statusEvent2).GetContainers();
            Org.Mockito.Mockito.Verify(scheduler, Org.Mockito.Mockito.Times(1)).Handle(Matchers.Any
                                                                                       <NodeUpdateSchedulerEvent>());
            node.Handle(statusEvent1);
            node.Handle(statusEvent2);
            Org.Mockito.Mockito.Verify(scheduler, Org.Mockito.Mockito.Times(1)).Handle(Matchers.Any
                                                                                       <NodeUpdateSchedulerEvent>());
            NUnit.Framework.Assert.AreEqual(2, node.GetQueueSize());
            node.Handle(new RMNodeEvent(node.GetNodeID(), RMNodeEventType.Expire));
            NUnit.Framework.Assert.AreEqual(0, node.GetQueueSize());
        }