YARN-11084. Introduce new config to specify AM default node-label when not specified. Contributed by Junfan Zhang.
This commit is contained in:
parent
45ce1cce50
commit
921267ca31
|
@ -4409,6 +4409,9 @@ public class YarnConfiguration extends Configuration {
|
||||||
private static final String RM_NODE_LABELS_PREFIX = RM_PREFIX
|
private static final String RM_NODE_LABELS_PREFIX = RM_PREFIX
|
||||||
+ "node-labels.";
|
+ "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 =
|
public static final String RM_NODE_LABELS_PROVIDER_CONFIG =
|
||||||
RM_NODE_LABELS_PREFIX + "provider";
|
RM_NODE_LABELS_PREFIX + "provider";
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,9 @@ import org.apache.hadoop.classification.VisibleForTesting;
|
||||||
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture;
|
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.SettableFuture;
|
||||||
import org.apache.hadoop.yarn.util.StringHelper;
|
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.
|
* This class manages the list of applications for the resource manager.
|
||||||
*/
|
*/
|
||||||
|
@ -106,6 +109,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
|
||||||
private boolean timelineServiceV2Enabled;
|
private boolean timelineServiceV2Enabled;
|
||||||
private boolean nodeLabelsEnabled;
|
private boolean nodeLabelsEnabled;
|
||||||
private Set<String> exclusiveEnforcedPartitions;
|
private Set<String> exclusiveEnforcedPartitions;
|
||||||
|
private String amDefaultNodeLabel;
|
||||||
|
|
||||||
private static final String USER_ID_PREFIX = "userid=";
|
private static final String USER_ID_PREFIX = "userid=";
|
||||||
|
|
||||||
|
@ -134,6 +138,8 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
|
||||||
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
|
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
|
||||||
this.exclusiveEnforcedPartitions = YarnConfiguration
|
this.exclusiveEnforcedPartitions = YarnConfiguration
|
||||||
.getExclusiveEnforcedPartitions(rmContext.getYarnConfiguration());
|
.getExclusiveEnforcedPartitions(rmContext.getYarnConfiguration());
|
||||||
|
this.amDefaultNodeLabel = conf
|
||||||
|
.get(YarnConfiguration.AM_DEFAULT_NODE_LABEL, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -622,9 +628,12 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// set label expression for AM ANY request if not set
|
// set label expression for AM ANY request if not set
|
||||||
if (null == anyReq.getNodeLabelExpression()) {
|
if (isEmpty(anyReq.getNodeLabelExpression())) {
|
||||||
anyReq.setNodeLabelExpression(submissionContext
|
if (isNotEmpty(amDefaultNodeLabel)) {
|
||||||
.getNodeLabelExpression());
|
anyReq.setNodeLabelExpression(amDefaultNodeLabel);
|
||||||
|
} else {
|
||||||
|
anyReq.setNodeLabelExpression(submissionContext.getNodeLabelExpression());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put ANY request at the front
|
// Put ANY request at the front
|
||||||
|
|
|
@ -729,6 +729,33 @@ public class TestAppManager extends AppManagerTestBase{
|
||||||
app.getAMResourceRequests());
|
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
|
@Test
|
||||||
public void testRMAppSubmitResource() throws Exception {
|
public void testRMAppSubmitResource() throws Exception {
|
||||||
asContext.setResource(Resources.createResource(1024));
|
asContext.setResource(Resources.createResource(1024));
|
||||||
|
@ -836,6 +863,10 @@ public class TestAppManager extends AppManagerTestBase{
|
||||||
|
|
||||||
private RMApp testRMAppSubmit() throws Exception {
|
private RMApp testRMAppSubmit() throws Exception {
|
||||||
appMonitor.submitApplication(asContext, "test");
|
appMonitor.submitApplication(asContext, "test");
|
||||||
|
return waitUntilEventProcessed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private RMApp waitUntilEventProcessed() throws InterruptedException {
|
||||||
RMApp app = rmContext.getRMApps().get(appId);
|
RMApp app = rmContext.getRMApps().get(appId);
|
||||||
Assert.assertNotNull("app is null", app);
|
Assert.assertNotNull("app is null", app);
|
||||||
Assert.assertEquals("app id doesn't match", appId, app.getApplicationId());
|
Assert.assertEquals("app id doesn't match", appId, app.getApplicationId());
|
||||||
|
|
|
@ -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
|
* `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.
|
* 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
|
Monitoring
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue