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); }
public virtual void TestNodesDefaultWithUnHealthyNode() { WebResource r = Resource(); MockNM nm1 = rm.RegisterNode("h1:1234", 5120); MockNM nm2 = rm.RegisterNode("h2:1235", 5121); rm.SendNodeStarted(nm1); rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running); rm.NMwaitForState(nm2.GetNodeId(), NodeState.New); MockNM nm3 = rm.RegisterNode("h3:1236", 5122); rm.NMwaitForState(nm3.GetNodeId(), NodeState.New); rm.SendNodeStarted(nm3); rm.NMwaitForState(nm3.GetNodeId(), NodeState.Running); RMNodeImpl node = (RMNodeImpl)rm.GetRMContext().GetRMNodes()[nm3.GetNodeId()]; NodeHealthStatus nodeHealth = NodeHealthStatus.NewInstance(false, "test health report" , Runtime.CurrentTimeMillis()); node.Handle(new RMNodeStatusEvent(nm3.GetNodeId(), nodeHealth, new AList <ContainerStatus >(), null, null)); rm.NMwaitForState(nm3.GetNodeId(), NodeState.Unhealthy); ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").Accept (MediaType.ApplicationJson).Get <ClientResponse>(); NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType() ); JSONObject json = response.GetEntity <JSONObject>(); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length()); JSONObject nodes = json.GetJSONObject("nodes"); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.Length() ); JSONArray nodeArray = nodes.GetJSONArray("node"); // 3 nodes, including the unhealthy node and the new node. NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, nodeArray.Length ()); }