|
@@ -35,10 +35,12 @@ import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
|
|
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
|
|
+import org.apache.hadoop.conf.Configurable;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.yarn.Clock;
|
|
|
import org.apache.hadoop.yarn.SystemClock;
|
|
|
+import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
|
import org.apache.hadoop.yarn.api.records.Container;
|
|
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
@@ -109,7 +111,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSe
|
|
|
@Unstable
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public class FairScheduler implements ResourceScheduler {
|
|
|
-
|
|
|
private boolean initialized;
|
|
|
private FairSchedulerConfiguration conf;
|
|
|
private RMContext rmContext;
|
|
@@ -185,6 +186,44 @@ public class FairScheduler implements ResourceScheduler {
|
|
|
queueMgr = new QueueManager(this);
|
|
|
}
|
|
|
|
|
|
+ private void validateConf(Configuration conf) {
|
|
|
+ // validate scheduler memory allocation setting
|
|
|
+ int minMem = conf.getInt(
|
|
|
+ YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB);
|
|
|
+ int maxMem = conf.getInt(
|
|
|
+ YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB);
|
|
|
+
|
|
|
+ if (minMem < 0 || minMem > maxMem) {
|
|
|
+ throw new YarnRuntimeException("Invalid resource scheduler memory"
|
|
|
+ + " allocation configuration"
|
|
|
+ + ", " + YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB
|
|
|
+ + "=" + minMem
|
|
|
+ + ", " + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB
|
|
|
+ + "=" + maxMem + ", min should equal greater than 0"
|
|
|
+ + ", max should be no smaller than min.");
|
|
|
+ }
|
|
|
+
|
|
|
+ // validate scheduler vcores allocation setting
|
|
|
+ int minVcores = conf.getInt(
|
|
|
+ YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES,
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES);
|
|
|
+ int maxVcores = conf.getInt(
|
|
|
+ YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES);
|
|
|
+
|
|
|
+ if (minVcores < 0 || minVcores > maxVcores) {
|
|
|
+ throw new YarnRuntimeException("Invalid resource scheduler vcores"
|
|
|
+ + " allocation configuration"
|
|
|
+ + ", " + YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES
|
|
|
+ + "=" + minVcores
|
|
|
+ + ", " + YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES
|
|
|
+ + "=" + maxVcores + ", min should equal greater than 0"
|
|
|
+ + ", max should be no smaller than min.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public FairSchedulerConfiguration getConf() {
|
|
|
return conf;
|
|
|
}
|
|
@@ -986,6 +1025,7 @@ public class FairScheduler implements ResourceScheduler {
|
|
|
public synchronized void reinitialize(Configuration conf, RMContext rmContext)
|
|
|
throws IOException {
|
|
|
this.conf = new FairSchedulerConfiguration(conf);
|
|
|
+ validateConf(this.conf);
|
|
|
minimumAllocation = this.conf.getMinimumAllocation();
|
|
|
maximumAllocation = this.conf.getMaximumAllocation();
|
|
|
userAsDefaultQueue = this.conf.getUserAsDefaultQueue();
|