Search in sources :

Example 6 with NodeState

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;
}
Also used : NodeState(org.apache.hadoop.yarn.api.records.NodeState) ArrayList(java.util.ArrayList) ContainerRequest(org.apache.hadoop.yarn.client.api.AMRMClient.ContainerRequest) NodeReport(org.apache.hadoop.yarn.api.records.NodeReport)

Example 7 with NodeState

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();
    }
}
Also used : NodeState(org.apache.hadoop.yarn.api.records.NodeState) InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException)

Example 8 with NodeState

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);
}
Also used : NodesListManagerEvent(org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent) NodeState(org.apache.hadoop.yarn.api.records.NodeState) NodeRemovedSchedulerEvent(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent)

Example 9 with NodeState

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);
}
Also used : NodeState(org.apache.hadoop.yarn.api.records.NodeState) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) NodeHeartbeatResponse(org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse) Test(org.junit.Test)

Example 10 with 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);
}
Also used : NodeState(org.apache.hadoop.yarn.api.records.NodeState)

Aggregations

NodeState (org.apache.hadoop.yarn.api.records.NodeState)15 NodeReport (org.apache.hadoop.yarn.api.records.NodeReport)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)4 PrintWriter (java.io.PrintWriter)3 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)3 OutputStreamWriter (java.io.OutputStreamWriter)2 HashMap (java.util.HashMap)2 GetClusterNodesResponse (org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 CommandLine (org.apache.commons.cli.CommandLine)1 GnuParser (org.apache.commons.cli.GnuParser)1