Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4409,6 +4409,9 @@ public static boolean areNodeLabelsEnabled(
private static final String RM_NODE_LABELS_PREFIX = RM_PREFIX
+ "node-labels.";

public static final String AM_DEFAULT_NODE_LABEL =
RM_NODE_LABELS_PREFIX + "am.default-node-label-expression";

public static final String RM_NODE_LABELS_PROVIDER_CONFIG =
RM_NODE_LABELS_PREFIX + "provider";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3452,6 +3452,14 @@
<value>30000</value>
</property>

<property>
<description>
Overwrites default-node-label-expression only for the ApplicationMaster
container. It is disabled by default.
</description>
<name>yarn.resourcemanager.node-labels.am.default-node-label-expression</name>
</property>

<!-- Distributed Node Attributes Configuration -->
<property>
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture;
import org.apache.hadoop.yarn.util.StringHelper;

import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isNotEmpty;

/**
* This class manages the list of applications for the resource manager.
*/
Expand All @@ -106,6 +109,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
private boolean timelineServiceV2Enabled;
private boolean nodeLabelsEnabled;
private Set<String> exclusiveEnforcedPartitions;
private String amDefaultNodeLabel;

private static final String USER_ID_PREFIX = "userid=";

Expand Down Expand Up @@ -134,6 +138,8 @@ public RMAppManager(RMContext context,
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
this.exclusiveEnforcedPartitions = YarnConfiguration
.getExclusiveEnforcedPartitions(rmContext.getYarnConfiguration());
this.amDefaultNodeLabel = conf
.get(YarnConfiguration.AM_DEFAULT_NODE_LABEL, null);
}

/**
Expand Down Expand Up @@ -622,9 +628,12 @@ private List<ResourceRequest> validateAndCreateResourceRequest(
}

// set label expression for AM ANY request if not set
if (null == anyReq.getNodeLabelExpression()) {
anyReq.setNodeLabelExpression(submissionContext
.getNodeLabelExpression());
if (isEmpty(anyReq.getNodeLabelExpression())) {
if (isNotEmpty(amDefaultNodeLabel)) {
anyReq.setNodeLabelExpression(amDefaultNodeLabel);
} else {
anyReq.setNodeLabelExpression(submissionContext.getNodeLabelExpression());
}
}

// Put ANY request at the front
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,33 @@ public void testRMAppSubmitAMContainerResourceRequest() throws Exception {
app.getAMResourceRequests());
}

@Test
public void testRMAppSubmitAMContainerWithNoLabelByRMDefaultAMNodeLabel() throws Exception {
List<ResourceRequest> reqs = new ArrayList<>();
ResourceRequest anyReq = ResourceRequest.newInstance(
Priority.newInstance(1),
ResourceRequest.ANY, Resources.createResource(1024), 1, false, null,
ExecutionTypeRequest.newInstance(ExecutionType.GUARANTEED));
reqs.add(anyReq);
asContext.setAMContainerResourceRequests(cloneResourceRequests(reqs));
asContext.setNodeLabelExpression("fixed");

Configuration conf = new Configuration(false);
String defaultAMNodeLabel = "core";
conf.set(YarnConfiguration.AM_DEFAULT_NODE_LABEL, defaultAMNodeLabel);

when(mockDefaultQueueInfo.getAccessibleNodeLabels()).thenReturn
(new HashSet<String>() {{ add("core"); }});

TestRMAppManager newAppMonitor = createAppManager(rmContext, conf);
newAppMonitor.submitApplication(asContext, "test");

RMApp app = rmContext.getRMApps().get(appId);
waitUntilEventProcessed();
Assert.assertEquals(defaultAMNodeLabel,
app.getAMResourceRequests().get(0).getNodeLabelExpression());
}

@Test
public void testRMAppSubmitResource() throws Exception {
asContext.setResource(Resources.createResource(1024));
Expand Down Expand Up @@ -836,6 +863,10 @@ public void testRMAppSubmitAMContainerResourceRequestsTwoManyAny()

private RMApp testRMAppSubmit() throws Exception {
appMonitor.submitApplication(asContext, "test");
return waitUntilEventProcessed();
}

private RMApp waitUntilEventProcessed() throws InterruptedException {
RMApp app = rmContext.getRMApps().get(appId);
Assert.assertNotNull("app is null", app);
Assert.assertEquals("app id doesn't match", appId, app.getApplicationId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ Applications can use following Java APIs to specify node label to request
* `ResourceRequest.setNodeLabelExpression(..)` to set node label expression for individual resource requests. This can overwrite node label expression set in ApplicationSubmissionContext
* Specify `setAMContainerResourceRequest.setNodeLabelExpression` in `ApplicationSubmissionContext` to indicate expected node label for application master container.

__Default AM node-label Configuration__

Property | Value
----- | ------
yarn.resourcemanager.node-labels.am.default-node-label-expression | Overwrites default-node-label-expression only for the ApplicationMaster container. It is disabled by default.



Monitoring
----------

Expand Down