use of org.apache.hadoop.yarn.api.records.NodeState in project alluxio by Alluxio.
the class ContainerAllocatorTest method setup.
/*
* Creates a container allocator for allocating the specified numContainers with the specified
* maxContainersPerHost.
*
* The yarn client is mocked to make it look like there are numHosts different hosts in the
* system, and the resource manager client is mocked to allocate containers when they are
* requested.
*/
private ContainerAllocator setup(int numHosts, int maxContainersPerHost, int numContainers) throws Exception {
ContainerAllocator containerAllocator = new ContainerAllocator(CONTAINER_NAME, numContainers, maxContainersPerHost, mResource, mYarnClient, mRMClient);
List<NodeReport> nodeReports = new ArrayList<>();
for (int i = 0; i < numHosts; i++) {
NodeReport nodeReport = Records.newRecord(NodeReport.class);
nodeReport.setNodeId(NodeId.newInstance("host" + i, 0));
nodeReports.add(nodeReport);
}
when(mYarnClient.getNodeReports(Matchers.<NodeState[]>anyVararg())).thenReturn(nodeReports);
doAnswer(allocateFirstHostAnswer(containerAllocator)).when(mRMClient).addContainerRequest(any(ContainerRequest.class));
return containerAllocator;
}
use of org.apache.hadoop.yarn.api.records.NodeState in project hadoop by apache.
the class RMNodeImpl method handle.
public void handle(RMNodeEvent event) {
LOG.debug("Processing " + event.getNodeId() + " of type " + event.getType());
try {
writeLock.lock();
NodeState oldState = getState();
try {
stateMachine.doTransition(event.getType(), event);
} catch (InvalidStateTransitionException e) {
LOG.error("Can't handle this event at current state", e);
LOG.error("Invalid event " + event.getType() + " on Node " + this.nodeId + " oldState " + oldState);
}
if (oldState != getState()) {
LOG.info(nodeId + " Node Transitioned from " + oldState + " to " + getState());
}
} finally {
writeLock.unlock();
}
}
use of org.apache.hadoop.yarn.api.records.NodeState in project hadoop by apache.
the class RMNodeImpl method reportNodeUnusable.
/**
* Report node is UNUSABLE and update metrics.
* @param rmNode
* @param finalState
*/
public static void reportNodeUnusable(RMNodeImpl rmNode, NodeState finalState) {
// Inform the scheduler
rmNode.nodeUpdateQueue.clear();
// If the current state is NodeState.UNHEALTHY
// Then node is already been removed from the
// Scheduler
NodeState initialState = rmNode.getState();
if (!initialState.equals(NodeState.UNHEALTHY)) {
rmNode.context.getDispatcher().getEventHandler().handle(new NodeRemovedSchedulerEvent(rmNode));
}
rmNode.context.getDispatcher().getEventHandler().handle(new NodesListManagerEvent(NodesListManagerEventType.NODE_UNUSABLE, rmNode));
//Update the metrics
rmNode.updateMetricsForDeactivatedNode(initialState, finalState);
}
use of org.apache.hadoop.yarn.api.records.NodeState in project hadoop by apache.
the class TestResourceTrackerService method testAddNewIncludePathToConfiguration.
/**
* Decommissioning using a post-configured include hosts file
*/
@Test
public void testAddNewIncludePathToConfiguration() throws Exception {
Configuration conf = new Configuration();
rm = new MockRM(conf);
rm.start();
MockNM nm1 = rm.registerNode("host1:1234", 5120);
MockNM nm2 = rm.registerNode("host2:5678", 10240);
ClusterMetrics metrics = ClusterMetrics.getMetrics();
assert (metrics != null);
int initialMetricCount = metrics.getNumShutdownNMs();
NodeHeartbeatResponse nodeHeartbeat = nm1.nodeHeartbeat(true);
Assert.assertEquals(NodeAction.NORMAL, nodeHeartbeat.getNodeAction());
nodeHeartbeat = nm2.nodeHeartbeat(true);
Assert.assertEquals(NodeAction.NORMAL, nodeHeartbeat.getNodeAction());
writeToHostsFile("host1");
conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH, hostFile.getAbsolutePath());
rm.getNodesListManager().refreshNodes(conf);
checkShutdownNMCount(rm, ++initialMetricCount);
nodeHeartbeat = nm1.nodeHeartbeat(true);
Assert.assertEquals("Node should not have been shutdown.", NodeAction.NORMAL, nodeHeartbeat.getNodeAction());
NodeState nodeState = rm.getRMContext().getInactiveRMNodes().get(nm2.getNodeId()).getState();
Assert.assertEquals("Node should have been shutdown but is in state" + nodeState, NodeState.SHUTDOWN, nodeState);
}
use of org.apache.hadoop.yarn.api.records.NodeState in project hadoop by apache.
the class RMAppImpl method processNodeUpdate.
private void processNodeUpdate(RMAppNodeUpdateType type, RMNode node) {
NodeState nodeState = node.getState();
updatedNodes.add(node);
LOG.debug("Received node update event:" + type + " for node:" + node + " with state:" + nodeState);
}
Aggregations