示例#1
0
        private RMNodeImpl GetRebootedNode()
        {
            NodeId     nodeId     = BuilderUtils.NewNodeId("localhost", 0);
            Resource   capability = Resource.NewInstance(4096, 4);
            RMNodeImpl node       = new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, capability,
                                                   null);

            node.Handle(new RMNodeStartedEvent(node.GetNodeID(), null, null));
            NUnit.Framework.Assert.AreEqual(NodeState.Running, node.GetState());
            node.Handle(new RMNodeEvent(node.GetNodeID(), RMNodeEventType.Rebooting));
            NUnit.Framework.Assert.AreEqual(NodeState.Rebooted, node.GetState());
            return(node);
        }
示例#2
0
        public virtual void TestReconnect()
        {
            RMNodeImpl     node                  = GetRunningNode();
            ClusterMetrics cm                    = ClusterMetrics.GetMetrics();
            int            initialActive         = cm.GetNumActiveNMs();
            int            initialLost           = cm.GetNumLostNMs();
            int            initialUnhealthy      = cm.GetUnhealthyNMs();
            int            initialDecommissioned = cm.GetNumDecommisionedNMs();
            int            initialRebooted       = cm.GetNumRebootedNMs();

            node.Handle(new RMNodeReconnectEvent(node.GetNodeID(), node, null, null));
            NUnit.Framework.Assert.AreEqual("Active Nodes", initialActive, cm.GetNumActiveNMs
                                                ());
            NUnit.Framework.Assert.AreEqual("Lost Nodes", initialLost, cm.GetNumLostNMs());
            NUnit.Framework.Assert.AreEqual("Unhealthy Nodes", initialUnhealthy, cm.GetUnhealthyNMs
                                                ());
            NUnit.Framework.Assert.AreEqual("Decommissioned Nodes", initialDecommissioned, cm
                                            .GetNumDecommisionedNMs());
            NUnit.Framework.Assert.AreEqual("Rebooted Nodes", initialRebooted, cm.GetNumRebootedNMs
                                                ());
            NUnit.Framework.Assert.AreEqual(NodeState.Running, node.GetState());
            NUnit.Framework.Assert.IsNotNull(nodesListManagerEvent);
            NUnit.Framework.Assert.AreEqual(NodesListManagerEventType.NodeUsable, nodesListManagerEvent
                                            .GetType());
        }
示例#3
0
        private RMNodeImpl GetUnhealthyNode()
        {
            RMNodeImpl       node   = GetRunningNode();
            NodeHealthStatus status = NodeHealthStatus.NewInstance(false, "sick", Runtime.CurrentTimeMillis
                                                                       ());

            node.Handle(new RMNodeStatusEvent(node.GetNodeID(), status, new AList <ContainerStatus
                                                                                   >(), null, null));
            NUnit.Framework.Assert.AreEqual(NodeState.Unhealthy, node.GetState());
            return(node);
        }
示例#4
0
        public virtual void TestUnhealthyExpireForSchedulerRemove()
        {
            RMNodeImpl node = GetUnhealthyNode();

            Org.Mockito.Mockito.Verify(scheduler, Org.Mockito.Mockito.Times(2)).Handle(Matchers.Any
                                                                                       <NodeRemovedSchedulerEvent>());
            node.Handle(new RMNodeEvent(node.GetNodeID(), RMNodeEventType.Expire));
            Org.Mockito.Mockito.Verify(scheduler, Org.Mockito.Mockito.Times(2)).Handle(Matchers.Any
                                                                                       <NodeRemovedSchedulerEvent>());
            NUnit.Framework.Assert.AreEqual(NodeState.Lost, node.GetState());
        }
示例#5
0
        public virtual void TestResourceUpdateOnRebootedNode()
        {
            RMNodeImpl node        = GetRebootedNode();
            Resource   oldCapacity = node.GetTotalCapability();

            NUnit.Framework.Assert.AreEqual("Memory resource is not match.", oldCapacity.GetMemory
                                                (), 4096);
            NUnit.Framework.Assert.AreEqual("CPU resource is not match.", oldCapacity.GetVirtualCores
                                                (), 4);
            node.Handle(new RMNodeResourceUpdateEvent(node.GetNodeID(), ResourceOption.NewInstance
                                                          (Resource.NewInstance(2048, 2), RMNode.OverCommitTimeoutMillisDefault)));
            Resource newCapacity = node.GetTotalCapability();

            NUnit.Framework.Assert.AreEqual("Memory resource is not match.", newCapacity.GetMemory
                                                (), 2048);
            NUnit.Framework.Assert.AreEqual("CPU resource is not match.", newCapacity.GetVirtualCores
                                                (), 2);
            NUnit.Framework.Assert.AreEqual(NodeState.Rebooted, node.GetState());
        }
示例#6
0
        public virtual void TestUnhealthyRebooting()
        {
            RMNodeImpl     node                  = GetUnhealthyNode();
            ClusterMetrics cm                    = ClusterMetrics.GetMetrics();
            int            initialActive         = cm.GetNumActiveNMs();
            int            initialLost           = cm.GetNumLostNMs();
            int            initialUnhealthy      = cm.GetUnhealthyNMs();
            int            initialDecommissioned = cm.GetNumDecommisionedNMs();
            int            initialRebooted       = cm.GetNumRebootedNMs();

            node.Handle(new RMNodeEvent(node.GetNodeID(), RMNodeEventType.Rebooting));
            NUnit.Framework.Assert.AreEqual("Active Nodes", initialActive, cm.GetNumActiveNMs
                                                ());
            NUnit.Framework.Assert.AreEqual("Lost Nodes", initialLost, cm.GetNumLostNMs());
            NUnit.Framework.Assert.AreEqual("Unhealthy Nodes", initialUnhealthy - 1, cm.GetUnhealthyNMs
                                                ());
            NUnit.Framework.Assert.AreEqual("Decommissioned Nodes", initialDecommissioned, cm
                                            .GetNumDecommisionedNMs());
            NUnit.Framework.Assert.AreEqual("Rebooted Nodes", initialRebooted + 1, cm.GetNumRebootedNMs
                                                ());
            NUnit.Framework.Assert.AreEqual(NodeState.Rebooted, node.GetState());
        }