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); }
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()); }
public virtual void TestUpdateHeartbeatResponseForCleanup() { RMNodeImpl node = GetRunningNode(); NodeId nodeId = node.GetNodeID(); // Expire a container ContainerId completedContainerId = BuilderUtils.NewContainerId(BuilderUtils.NewApplicationAttemptId (BuilderUtils.NewApplicationId(0, 0), 0), 0); node.Handle(new RMNodeCleanContainerEvent(nodeId, completedContainerId)); NUnit.Framework.Assert.AreEqual(1, node.GetContainersToCleanUp().Count); // Finish an application ApplicationId finishedAppId = BuilderUtils.NewApplicationId(0, 1); node.Handle(new RMNodeCleanAppEvent(nodeId, finishedAppId)); NUnit.Framework.Assert.AreEqual(1, node.GetAppsToCleanup().Count); // Verify status update does not clear containers/apps to cleanup // but updating heartbeat response for cleanup does RMNodeStatusEvent statusEvent = GetMockRMNodeStatusEvent(); node.Handle(statusEvent); NUnit.Framework.Assert.AreEqual(1, node.GetContainersToCleanUp().Count); NUnit.Framework.Assert.AreEqual(1, node.GetAppsToCleanup().Count); NodeHeartbeatResponse hbrsp = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeHeartbeatResponse >(); node.UpdateNodeHeartbeatResponseForCleanup(hbrsp); NUnit.Framework.Assert.AreEqual(0, node.GetContainersToCleanUp().Count); NUnit.Framework.Assert.AreEqual(0, node.GetAppsToCleanup().Count); NUnit.Framework.Assert.AreEqual(1, hbrsp.GetContainersToCleanup().Count); NUnit.Framework.Assert.AreEqual(completedContainerId, hbrsp.GetContainersToCleanup ()[0]); NUnit.Framework.Assert.AreEqual(1, hbrsp.GetApplicationsToCleanup().Count); NUnit.Framework.Assert.AreEqual(finishedAppId, hbrsp.GetApplicationsToCleanup()[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()); }
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 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()); }
public virtual void TestReconnnectUpdate() { string nmVersion1 = "nm version 1"; string nmVersion2 = "nm version 2"; RMNodeImpl node = GetRunningNode(nmVersion1); NUnit.Framework.Assert.AreEqual(nmVersion1, node.GetNodeManagerVersion()); RMNodeImpl reconnectingNode = GetRunningNode(nmVersion2); node.Handle(new RMNodeReconnectEvent(node.GetNodeID(), reconnectingNode, null, null )); NUnit.Framework.Assert.AreEqual(nmVersion2, node.GetNodeManagerVersion()); }
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()); }
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()); }