YARN-9508. YarnConfiguration areNodeLabel enabled is costly in allocation flow. Contributed by Bilwa S T.
This commit is contained in:
parent
2de1e30658
commit
570fa2da20
@ -117,6 +117,7 @@ final class DefaultAMSProcessor implements ApplicationMasterServiceProcessor {
|
|||||||
private RMContext rmContext;
|
private RMContext rmContext;
|
||||||
private ResourceProfilesManager resourceProfilesManager;
|
private ResourceProfilesManager resourceProfilesManager;
|
||||||
private boolean timelineServiceV2Enabled;
|
private boolean timelineServiceV2Enabled;
|
||||||
|
private boolean nodelabelsEnabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ApplicationMasterServiceContext amsContext,
|
public void init(ApplicationMasterServiceContext amsContext,
|
||||||
@ -125,6 +126,8 @@ public void init(ApplicationMasterServiceContext amsContext,
|
|||||||
this.resourceProfilesManager = rmContext.getResourceProfilesManager();
|
this.resourceProfilesManager = rmContext.getResourceProfilesManager();
|
||||||
this.timelineServiceV2Enabled = YarnConfiguration.
|
this.timelineServiceV2Enabled = YarnConfiguration.
|
||||||
timelineServiceV2Enabled(rmContext.getYarnConfiguration());
|
timelineServiceV2Enabled(rmContext.getYarnConfiguration());
|
||||||
|
this.nodelabelsEnabled = YarnConfiguration
|
||||||
|
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -242,7 +245,7 @@ public void allocate(ApplicationAttemptId appAttemptId,
|
|||||||
try {
|
try {
|
||||||
RMServerUtils.normalizeAndValidateRequests(ask,
|
RMServerUtils.normalizeAndValidateRequests(ask,
|
||||||
maximumCapacity, app.getQueue(),
|
maximumCapacity, app.getQueue(),
|
||||||
getScheduler(), getRmContext());
|
getScheduler(), getRmContext(), nodelabelsEnabled);
|
||||||
} catch (InvalidResourceRequestException e) {
|
} catch (InvalidResourceRequestException e) {
|
||||||
RMAppAttempt rmAppAttempt = app.getRMAppAttempt(appAttemptId);
|
RMAppAttempt rmAppAttempt = app.getRMAppAttempt(appAttemptId);
|
||||||
handleInvalidResourceException(e, rmAppAttempt);
|
handleInvalidResourceException(e, rmAppAttempt);
|
||||||
|
@ -99,6 +99,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
|
|||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
private YarnAuthorizationProvider authorizer;
|
private YarnAuthorizationProvider authorizer;
|
||||||
private boolean timelineServiceV2Enabled;
|
private boolean timelineServiceV2Enabled;
|
||||||
|
private boolean nodeLabelsEnabled;
|
||||||
|
|
||||||
public RMAppManager(RMContext context,
|
public RMAppManager(RMContext context,
|
||||||
YarnScheduler scheduler, ApplicationMasterService masterService,
|
YarnScheduler scheduler, ApplicationMasterService masterService,
|
||||||
@ -121,6 +122,8 @@ public RMAppManager(RMContext context,
|
|||||||
this.authorizer = YarnAuthorizationProvider.getInstance(conf);
|
this.authorizer = YarnAuthorizationProvider.getInstance(conf);
|
||||||
this.timelineServiceV2Enabled = YarnConfiguration.
|
this.timelineServiceV2Enabled = YarnConfiguration.
|
||||||
timelineServiceV2Enabled(conf);
|
timelineServiceV2Enabled(conf);
|
||||||
|
this.nodeLabelsEnabled = YarnConfiguration
|
||||||
|
.areNodeLabelsEnabled(rmContext.getYarnConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -602,7 +605,7 @@ private List<ResourceRequest> validateAndCreateResourceRequest(
|
|||||||
Resource maxAllocation = scheduler.getMaximumResourceCapability(queue);
|
Resource maxAllocation = scheduler.getMaximumResourceCapability(queue);
|
||||||
for (ResourceRequest amReq : amReqs) {
|
for (ResourceRequest amReq : amReqs) {
|
||||||
SchedulerUtils.normalizeAndValidateRequest(amReq, maxAllocation,
|
SchedulerUtils.normalizeAndValidateRequest(amReq, maxAllocation,
|
||||||
queue, scheduler, isRecovery, rmContext, null);
|
queue, isRecovery, rmContext, null, nodeLabelsEnabled);
|
||||||
|
|
||||||
amReq.setCapability(scheduler.getNormalizedResource(
|
amReq.setCapability(scheduler.getNormalizedResource(
|
||||||
amReq.getCapability(), maxAllocation));
|
amReq.getCapability(), maxAllocation));
|
||||||
|
@ -245,7 +245,8 @@ private static String validateContainerIdAndVersion(
|
|||||||
*/
|
*/
|
||||||
public static void normalizeAndValidateRequests(List<ResourceRequest> ask,
|
public static void normalizeAndValidateRequests(List<ResourceRequest> ask,
|
||||||
Resource maximumAllocation, String queueName, YarnScheduler scheduler,
|
Resource maximumAllocation, String queueName, YarnScheduler scheduler,
|
||||||
RMContext rmContext) throws InvalidResourceRequestException {
|
RMContext rmContext, boolean nodeLabelsEnabled)
|
||||||
|
throws InvalidResourceRequestException {
|
||||||
// Get queue from scheduler
|
// Get queue from scheduler
|
||||||
QueueInfo queueInfo = null;
|
QueueInfo queueInfo = null;
|
||||||
try {
|
try {
|
||||||
@ -257,7 +258,7 @@ public static void normalizeAndValidateRequests(List<ResourceRequest> ask,
|
|||||||
|
|
||||||
for (ResourceRequest resReq : ask) {
|
for (ResourceRequest resReq : ask) {
|
||||||
SchedulerUtils.normalizeAndValidateRequest(resReq, maximumAllocation,
|
SchedulerUtils.normalizeAndValidateRequest(resReq, maximumAllocation,
|
||||||
queueName, scheduler, rmContext, queueInfo);
|
queueName, rmContext, queueInfo, nodeLabelsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
import org.apache.hadoop.yarn.api.records.ResourceInformation;
|
||||||
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
||||||
import org.apache.hadoop.yarn.exceptions.InvalidLabelResourceRequestException;
|
import org.apache.hadoop.yarn.exceptions.InvalidLabelResourceRequestException;
|
||||||
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
|
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
|
||||||
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException
|
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException
|
||||||
@ -259,12 +258,12 @@ private static void normalizeNodeLabelExpressionInRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void normalizeAndValidateRequest(ResourceRequest resReq,
|
public static void normalizeAndValidateRequest(ResourceRequest resReq,
|
||||||
Resource maximumAllocation, String queueName, YarnScheduler scheduler,
|
Resource maximumAllocation, String queueName, boolean isRecovery,
|
||||||
boolean isRecovery, RMContext rmContext, QueueInfo queueInfo)
|
RMContext rmContext, QueueInfo queueInfo, boolean nodeLabelsEnabled)
|
||||||
throws InvalidResourceRequestException {
|
throws InvalidResourceRequestException {
|
||||||
Configuration conf = rmContext.getYarnConfiguration();
|
Configuration conf = rmContext.getYarnConfiguration();
|
||||||
// If Node label is not enabled throw exception
|
// If Node label is not enabled throw exception
|
||||||
if (null != conf && !YarnConfiguration.areNodeLabelsEnabled(conf)) {
|
if (null != conf && !nodeLabelsEnabled) {
|
||||||
String labelExp = resReq.getNodeLabelExpression();
|
String labelExp = resReq.getNodeLabelExpression();
|
||||||
if (!(RMNodeLabelsManager.NO_LABEL.equals(labelExp)
|
if (!(RMNodeLabelsManager.NO_LABEL.equals(labelExp)
|
||||||
|| null == labelExp)) {
|
|| null == labelExp)) {
|
||||||
@ -280,7 +279,8 @@ public static void normalizeAndValidateRequest(ResourceRequest resReq,
|
|||||||
}
|
}
|
||||||
if (null == queueInfo) {
|
if (null == queueInfo) {
|
||||||
try {
|
try {
|
||||||
queueInfo = scheduler.getQueueInfo(queueName, false, false);
|
queueInfo = rmContext.getScheduler().getQueueInfo(queueName, false,
|
||||||
|
false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
//Queue may not exist since it could be auto-created in case of
|
//Queue may not exist since it could be auto-created in case of
|
||||||
// dynamic queues
|
// dynamic queues
|
||||||
@ -294,11 +294,11 @@ public static void normalizeAndValidateRequest(ResourceRequest resReq,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void normalizeAndValidateRequest(ResourceRequest resReq,
|
public static void normalizeAndValidateRequest(ResourceRequest resReq,
|
||||||
Resource maximumAllocation, String queueName, YarnScheduler scheduler,
|
Resource maximumAllocation, String queueName, RMContext rmContext,
|
||||||
RMContext rmContext, QueueInfo queueInfo)
|
QueueInfo queueInfo, boolean nodeLabelsEnabled)
|
||||||
throws InvalidResourceRequestException {
|
throws InvalidResourceRequestException {
|
||||||
normalizeAndValidateRequest(resReq, maximumAllocation, queueName, scheduler,
|
normalizeAndValidateRequest(resReq, maximumAllocation, queueName, false,
|
||||||
false, rmContext, queueInfo);
|
rmContext, queueInfo, nodeLabelsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,6 +204,7 @@ public ConcurrentMap<ApplicationId, RMApp> getRMApps() {
|
|||||||
metricsPublisher = mock(SystemMetricsPublisher.class);
|
metricsPublisher = mock(SystemMetricsPublisher.class);
|
||||||
context.setSystemMetricsPublisher(metricsPublisher);
|
context.setSystemMetricsPublisher(metricsPublisher);
|
||||||
context.setRMApplicationHistoryWriter(writer);
|
context.setRMApplicationHistoryWriter(writer);
|
||||||
|
((RMContextImpl)context).setYarnConfiguration(new YarnConfiguration());
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,7 +1020,8 @@ private static void normalizeAndvalidateRequest(ResourceRequest resReq,
|
|||||||
Resource maxAllocation)
|
Resource maxAllocation)
|
||||||
throws InvalidResourceRequestException {
|
throws InvalidResourceRequestException {
|
||||||
SchedulerUtils.normalizeAndValidateRequest(resReq, maxAllocation, queueName,
|
SchedulerUtils.normalizeAndValidateRequest(resReq, maxAllocation, queueName,
|
||||||
scheduler, rmContext, null);
|
rmContext, null, YarnConfiguration
|
||||||
|
.areNodeLabelsEnabled(rmContext.getYarnConfiguration()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InvalidResourceRequestExceptionMessageGenerator {
|
private static class InvalidResourceRequestExceptionMessageGenerator {
|
||||||
|
Loading…
Reference in New Issue
Block a user