YARN-10397. SchedulerRequest should be forwarded to scheduler if custom scheduler supports placement constraints. Contributed by Bilwa S T.

This commit is contained in:
Brahma Reddy Battula 2020-09-09 17:08:13 +05:30
parent 2029556dbb
commit 43572fc7f8
3 changed files with 18 additions and 2 deletions

View File

@ -884,6 +884,15 @@ public Set<String> getPlanQueues() throws YarnException {
+ " does not support reservations");
}
/**
* By default placement constraint is disabled. Schedulers which support
* placement constraint can override this value.
* @return enabled or not
*/
public boolean placementConstraintEnabled() {
return false;
}
protected void refreshMaximumAllocation(Resource newMaxAlloc) {
nodeTracker.setConfiguredMaxAllocation(newMaxAlloc);
}

View File

@ -3284,4 +3284,12 @@ public int getNumAsyncSchedulerThreads() {
public void setMaxRunningAppsEnforcer(CSMaxRunningAppsEnforcer enforcer) {
this.maxRunningEnforcer = enforcer;
}
/**
* Returning true as capacity scheduler supports placement constraints.
*/
@Override
public boolean placementConstraintEnabled() {
return true;
}
}

View File

@ -22,7 +22,6 @@
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,7 +38,7 @@ public void allocate(ApplicationAttemptId appAttemptId,
AllocateRequest request, AllocateResponse response) throws YarnException {
if (request.getSchedulingRequests() != null
&& !request.getSchedulingRequests().isEmpty()) {
if (!(scheduler instanceof CapacityScheduler)) {
if (!scheduler.placementConstraintEnabled()) {
String message = "Found non empty SchedulingRequest of "
+ "AllocateRequest for application=" + appAttemptId.toString()
+ ", however the configured scheduler="