Search in sources :

Example 21 with NodeLabel

use of org.apache.hadoop.yarn.api.records.NodeLabel in project hadoop by apache.

the class NodeHeartbeatRequestPBImpl method mergeLocalToBuilder.

private void mergeLocalToBuilder() {
    if (this.nodeStatus != null) {
        builder.setNodeStatus(convertToProtoFormat(this.nodeStatus));
    }
    if (this.lastKnownContainerTokenMasterKey != null) {
        builder.setLastKnownContainerTokenMasterKey(convertToProtoFormat(this.lastKnownContainerTokenMasterKey));
    }
    if (this.lastKnownNMTokenMasterKey != null) {
        builder.setLastKnownNmTokenMasterKey(convertToProtoFormat(this.lastKnownNMTokenMasterKey));
    }
    if (this.labels != null) {
        builder.clearNodeLabels();
        Builder newBuilder = NodeLabelsProto.newBuilder();
        for (NodeLabel label : labels) {
            newBuilder.addNodeLabels(convertToProtoFormat(label));
        }
        builder.setNodeLabels(newBuilder.build());
    }
    if (this.logAggregationReportsForApps != null) {
        addLogAggregationStatusForAppsToProto();
    }
    if (this.registeredCollectors != null) {
        addRegisteredCollectorsToProto();
    }
}
Also used : NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) Builder(org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.NodeLabelsProto.Builder) NodeHeartbeatRequestProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.NodeHeartbeatRequestProtoOrBuilder)

Example 22 with NodeLabel

use of org.apache.hadoop.yarn.api.records.NodeLabel in project hadoop by apache.

the class RegisterNodeManagerRequestPBImpl method mergeLocalToBuilder.

private synchronized void mergeLocalToBuilder() {
    if (this.containerStatuses != null) {
        addNMContainerStatusesToProto();
    }
    if (this.runningApplications != null) {
        addRunningApplicationsToProto();
    }
    if (this.resource != null) {
        builder.setResource(convertToProtoFormat(this.resource));
    }
    if (this.nodeId != null) {
        builder.setNodeId(convertToProtoFormat(this.nodeId));
    }
    if (this.labels != null) {
        builder.clearNodeLabels();
        Builder newBuilder = NodeLabelsProto.newBuilder();
        for (NodeLabel label : labels) {
            newBuilder.addNodeLabels(convertToProtoFormat(label));
        }
        builder.setNodeLabels(newBuilder.build());
    }
    if (this.physicalResource != null) {
        builder.setPhysicalResource(convertToProtoFormat(this.physicalResource));
    }
}
Also used : NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) Builder(org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.NodeLabelsProto.Builder) RegisterNodeManagerRequestProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.RegisterNodeManagerRequestProtoOrBuilder)

Example 23 with NodeLabel

use of org.apache.hadoop.yarn.api.records.NodeLabel in project hadoop by apache.

the class RegisterNodeManagerRequestPBImpl method initNodeLabels.

private synchronized void initNodeLabels() {
    if (this.labels != null) {
        return;
    }
    RegisterNodeManagerRequestProtoOrBuilder p = viaProto ? proto : builder;
    if (!p.hasNodeLabels()) {
        labels = null;
        return;
    }
    NodeLabelsProto nodeLabels = p.getNodeLabels();
    labels = new HashSet<NodeLabel>();
    for (NodeLabelProto nlp : nodeLabels.getNodeLabelsList()) {
        labels.add(convertFromProtoFormat(nlp));
    }
}
Also used : NodeLabelsProto(org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.NodeLabelsProto) NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) NodeLabelProto(org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto) RegisterNodeManagerRequestProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServerCommonServiceProtos.RegisterNodeManagerRequestProtoOrBuilder)

Example 24 with NodeLabel

use of org.apache.hadoop.yarn.api.records.NodeLabel in project hadoop by apache.

the class TestYarnServerApiClasses method testNodeHeartbeatRequestPBImpl.

/**
   * Test NodeHeartbeatRequestPBImpl.
   */
@Test
public void testNodeHeartbeatRequestPBImpl() {
    NodeHeartbeatRequestPBImpl original = new NodeHeartbeatRequestPBImpl();
    original.setLastKnownContainerTokenMasterKey(getMasterKey());
    original.setLastKnownNMTokenMasterKey(getMasterKey());
    original.setNodeStatus(getNodeStatus());
    original.setNodeLabels(getValidNodeLabels());
    Map<ApplicationId, String> collectors = getCollectors();
    original.setRegisteredCollectors(collectors);
    NodeHeartbeatRequestPBImpl copy = new NodeHeartbeatRequestPBImpl(original.getProto());
    assertEquals(1, copy.getLastKnownContainerTokenMasterKey().getKeyId());
    assertEquals(1, copy.getLastKnownNMTokenMasterKey().getKeyId());
    assertEquals("localhost", copy.getNodeStatus().getNodeId().getHost());
    assertEquals(collectors, copy.getRegisteredCollectors());
    // check labels are coming with valid values
    Assert.assertTrue(original.getNodeLabels().containsAll(copy.getNodeLabels()));
    // check for empty labels
    original.setNodeLabels(new HashSet<NodeLabel>());
    copy = new NodeHeartbeatRequestPBImpl(original.getProto());
    Assert.assertNotNull(copy.getNodeLabels());
    Assert.assertEquals(0, copy.getNodeLabels().size());
}
Also used : NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) NodeHeartbeatRequestPBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 25 with NodeLabel

use of org.apache.hadoop.yarn.api.records.NodeLabel in project hadoop by apache.

the class NodeStatusUpdaterImpl method registerWithRM.

@VisibleForTesting
protected void registerWithRM() throws YarnException, IOException {
    RegisterNodeManagerResponse regNMResponse;
    Set<NodeLabel> nodeLabels = nodeLabelsHandler.getNodeLabelsForRegistration();
    // during RM recovery
    synchronized (this.context) {
        List<NMContainerStatus> containerReports = getNMContainerStatuses();
        RegisterNodeManagerRequest request = RegisterNodeManagerRequest.newInstance(nodeId, httpPort, totalResource, nodeManagerVersionId, containerReports, getRunningApplications(), nodeLabels, physicalResource);
        if (containerReports != null) {
            LOG.info("Registering with RM using containers :" + containerReports);
        }
        regNMResponse = resourceTracker.registerNodeManager(request);
        // Make sure rmIdentifier is set before we release the lock
        this.rmIdentifier = regNMResponse.getRMIdentifier();
    }
    // if the Resource Manager instructs NM to shutdown.
    if (NodeAction.SHUTDOWN.equals(regNMResponse.getNodeAction())) {
        String message = "Message from ResourceManager: " + regNMResponse.getDiagnosticsMessage();
        throw new YarnRuntimeException("Recieved SHUTDOWN signal from Resourcemanager, Registration of NodeManager failed, " + message);
    }
    // if ResourceManager version is too old then shutdown
    if (!minimumResourceManagerVersion.equals("NONE")) {
        if (minimumResourceManagerVersion.equals("EqualToNM")) {
            minimumResourceManagerVersion = nodeManagerVersionId;
        }
        String rmVersion = regNMResponse.getRMVersion();
        if (rmVersion == null) {
            String message = "The Resource Manager's did not return a version. " + "Valid version cannot be checked.";
            throw new YarnRuntimeException("Shutting down the Node Manager. " + message);
        }
        if (VersionUtil.compareVersions(rmVersion, minimumResourceManagerVersion) < 0) {
            String message = "The Resource Manager's version (" + rmVersion + ") is less than the minimum " + "allowed version " + minimumResourceManagerVersion;
            throw new YarnRuntimeException("Shutting down the Node Manager on RM " + "version error, " + message);
        }
    }
    this.registeredWithRM = true;
    MasterKey masterKey = regNMResponse.getContainerTokenMasterKey();
    // StatusUpdater#start().
    if (masterKey != null) {
        this.context.getContainerTokenSecretManager().setMasterKey(masterKey);
    }
    masterKey = regNMResponse.getNMTokenMasterKey();
    if (masterKey != null) {
        this.context.getNMTokenSecretManager().setMasterKey(masterKey);
    }
    StringBuilder successfullRegistrationMsg = new StringBuilder();
    successfullRegistrationMsg.append("Registered with ResourceManager as ").append(this.nodeId);
    Resource newResource = regNMResponse.getResource();
    if (newResource != null) {
        updateNMResource(newResource);
        successfullRegistrationMsg.append(" with updated total resource of ").append(this.totalResource);
    } else {
        successfullRegistrationMsg.append(" with total resource of ").append(this.totalResource);
    }
    successfullRegistrationMsg.append(nodeLabelsHandler.verifyRMRegistrationResponseForNodeLabels(regNMResponse));
    LOG.info(successfullRegistrationMsg);
    LOG.info("Notifying ContainerManager to unblock new container-requests");
    this.context.getContainerManager().setBlockNewContainerRequests(false);
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) UnRegisterNodeManagerRequest(org.apache.hadoop.yarn.server.api.protocolrecords.UnRegisterNodeManagerRequest) RegisterNodeManagerRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest) NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) NMContainerStatus(org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus) MasterKey(org.apache.hadoop.yarn.server.api.records.MasterKey) RegisterNodeManagerResponse(org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerResponse) Resource(org.apache.hadoop.yarn.api.records.Resource) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

NodeLabel (org.apache.hadoop.yarn.api.records.NodeLabel)25 NodeId (org.apache.hadoop.yarn.api.records.NodeId)9 HashSet (java.util.HashSet)7 Set (java.util.Set)7 ArrayList (java.util.ArrayList)6 NodeLabelProto (org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto)6 EnumSet (java.util.EnumSet)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 NodeLabelsInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo)3 InetSocketAddress (java.net.InetSocketAddress)2 Configuration (org.apache.hadoop.conf.Configuration)2 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)2 GetClusterNodeLabelsResponse (org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsResponse)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2