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

(cherry picked from commit 43572fc7f8)
This commit is contained in:
Brahma Reddy Battula 2020-09-09 17:08:13 +05:30
parent 262c575fab
commit ea37a05d4b
3 changed files with 18 additions and 2 deletions

View File

@ -884,6 +884,15 @@ public abstract class AbstractYarnScheduler
+ " does not support reservations"); + " 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) { protected void refreshMaximumAllocation(Resource newMaxAlloc) {
nodeTracker.setConfiguredMaxAllocation(newMaxAlloc); nodeTracker.setConfiguredMaxAllocation(newMaxAlloc);
} }

View File

@ -3285,4 +3285,12 @@ public class CapacityScheduler extends
public void setMaxRunningAppsEnforcer(CSMaxRunningAppsEnforcer enforcer) { public void setMaxRunningAppsEnforcer(CSMaxRunningAppsEnforcer enforcer) {
this.maxRunningEnforcer = 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.AllocateRequest;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -39,7 +38,7 @@ public class SchedulerPlacementProcessor extends AbstractPlacementProcessor {
AllocateRequest request, AllocateResponse response) throws YarnException { AllocateRequest request, AllocateResponse response) throws YarnException {
if (request.getSchedulingRequests() != null if (request.getSchedulingRequests() != null
&& !request.getSchedulingRequests().isEmpty()) { && !request.getSchedulingRequests().isEmpty()) {
if (!(scheduler instanceof CapacityScheduler)) { if (!scheduler.placementConstraintEnabled()) {
String message = "Found non empty SchedulingRequest of " String message = "Found non empty SchedulingRequest of "
+ "AllocateRequest for application=" + appAttemptId.toString() + "AllocateRequest for application=" + appAttemptId.toString()
+ ", however the configured scheduler=" + ", however the configured scheduler="