Managing Data Operating System
Also available as:
PDF
loading table of contents...

Use Node Labels

You can use various methods to specify node labels when submitting jobs.

  • Set Node Labels when Submitting Jobs

    You can use the following methods to specify node labels when submitting jobs:

    • ApplicationSubmissionContext.setNodeLabelExpression(<node_label_expression>) -- sets the node label expression for all containers of the application.

    • ResourceRequest.setNodeLabelExpression(<node_label_expression>) -- sets the node label expression for individual resource requests. This will override the node label expression set inApplicationSubmissionContext.setNodeLabelExpression(<node_label_expression>).

    • Specify setAMContainerResourceRequest.setNodeLabelExpression in ApplicationSubmissionContext to indicate the expected node label for the ApplicationMaster container.

    You can use one of these methods to specify a node label expression, and -queue to specify a queue, when you submit YARN jobs using the distributed shell client. If the queue has a label that satisfies the label expression, it will run the job on the labeled node(s). If the label expression does not reference a label associated with the specified queue, the job will not run and an error will be returned. If no node label is specified, the job will run only on nodes without a node label, and on nodes with shareable node labels if idle resources are available.

    Note
    Note

    You can only specify one node label in the .setNodeLabelExpression methods.

    For example, the following commands run a simple YARN distributed shell "sleep for a long time" job. In this example we are asking for more containers than the cluster can run so we can see which node the job runs on. We are specifying that the job should run on queue "a1", which our user has permission to run jobs on. We are also using the -node_label_expression parameter to specify that the job will run on all nodes with label "x".

    sudo su yarn
    hadoop jar /usr/hdp/current/hadoop-yarn-client/hadoop-yarn-applications-distributedshell.jar
     -shell_command "sleep 100" -jar /usr/hdp/current/hadoop-yarn-client/hadoop-yarn-applications-distributedshell.jar
     -num_containers 30 -queue a1 -node_label_expression x 

    If we run this job on the example cluster we configured previously, containers are allocated on node-1, as this node has been assigned node label "x", and queue "a1" also has node label "x":

    The following commands run the same job that we specified for node label "x", but this time we will specify queue "b1" rather than queue "a1".

    sudo su yarn
    hadoop jar /usr/hdp/current/hadoop-yarn-client/hadoop-yarn-applications-distributedshell.jar
     -shell_command "sleep 100000" -jar /usr/hdp/current/hadoop-yarn-client/hadoop-yarn-applications-distributedshell.jar
     -num_containers 30 -queue b1 -node_label_expression x

    When we attempt to run this job on our example cluster, the job will fail with the following error message because label "x" is not associated with queue "b1".

    14/11/24 13:42:21 INFO distributedshell.Client: Submitting application to ASM
    14/11/24 13:42:21 FATAL distributedshell.Client: Error running Client
    org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException: Invalid resource request, queue=b1 doesn't 
    have permission to access all labels in resource request. labelExpression of resource request=x. Queue labels=y
  • MapReduce Jobs and Node Labels

    Currently you cannot specify a node label when submitting a MapReduce job. However, if you submit a MapReduce job to a queue that has a default node label expression, the default node label will be applied to the MapReduce job.

    Using default node label expressions tends to constrain larger portions of the cluster, which at some point starts to become counter-productive for jobs -- such as MapReduce jobs -- that benefit from the advantages offered by distributed parallel processing.