diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/CapacitySchedulerPlanFollower.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/CapacitySchedulerPlanFollower.java
index 551f075edb5..2e166890402 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/CapacitySchedulerPlanFollower.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/reservation/CapacitySchedulerPlanFollower.java
@@ -28,10 +28,10 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AutoCreatedLeafQueue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.PlanQueue;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ReservationQueue;
import org.apache.hadoop.yarn.util.Clock;
import org.apache.hadoop.yarn.util.resource.Resources;
import org.slf4j.Logger;
@@ -92,8 +92,8 @@ protected void addReservationQueue(
String planQueueName, Queue queue, String currResId) {
PlanQueue planQueue = (PlanQueue)queue;
try {
- ReservationQueue resQueue =
- new ReservationQueue(cs, currResId, planQueue);
+ AutoCreatedLeafQueue resQueue =
+ new AutoCreatedLeafQueue(cs, currResId, planQueue);
cs.addQueue(resQueue);
} catch (SchedulerDynamicEditException e) {
LOG.warn(
@@ -112,8 +112,8 @@ protected void createDefaultReservationQueue(
PlanQueue planQueue = (PlanQueue)queue;
if (cs.getQueue(defReservationId) == null) {
try {
- ReservationQueue defQueue =
- new ReservationQueue(cs, defReservationId, planQueue);
+ AutoCreatedLeafQueue defQueue =
+ new AutoCreatedLeafQueue(cs, defReservationId, planQueue);
cs.addQueue(defQueue);
} catch (SchedulerDynamicEditException e) {
LOG.warn(
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractManagedParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractManagedParentQueue.java
new file mode 100644
index 00000000000..4332bb647b2
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractManagedParentQueue.java
@@ -0,0 +1,236 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * A container class for automatically created child leaf queues.
+ * From the user perspective this is equivalent to a LeafQueue,
+ * but functionality wise is a sub-class of ParentQueue
+ */
+public abstract class AbstractManagedParentQueue extends ParentQueue {
+
+ private static final Logger LOG = LoggerFactory.getLogger(
+ AbstractManagedParentQueue.class);
+
+ private int maxAppsForAutoCreatedQueues;
+ private int maxAppsPerUserForAutoCreatedQueues;
+ private int userLimit;
+ private float userLimitFactor;
+
+ public AbstractManagedParentQueue(CapacitySchedulerContext cs,
+ String queueName, CSQueue parent, CSQueue old) throws IOException {
+ super(cs, queueName, parent, old);
+
+ super.setupQueueConfigs(csContext.getClusterResource());
+ initializeLeafQueueConfigs();
+
+ StringBuffer queueInfo = new StringBuffer();
+ queueInfo.append("Created Managed Parent Queue: ").append(queueName)
+ .append("\nof type : [" + getClass())
+ .append("]\nwith capacity: [")
+ .append(super.getCapacity()).append("]\nwith max capacity: [")
+ .append(super.getMaximumCapacity()).append("\nwith max apps: [")
+ .append(getMaxApplicationsForAutoCreatedQueues())
+ .append("]\nwith max apps per user: [")
+ .append(getMaxApplicationsPerUserForAutoCreatedQueues())
+ .append("]\nwith user limit: [").append(getUserLimit())
+ .append("]\nwith user limit factor: [")
+ .append(getUserLimitFactor()).append("].");
+ LOG.info(queueInfo.toString());
+ }
+
+ @Override
+ public void reinitialize(CSQueue newlyParsedQueue, Resource clusterResource)
+ throws IOException {
+ try {
+ writeLock.lock();
+
+ validate(newlyParsedQueue);
+ // Set new configs
+ setupQueueConfigs(clusterResource);
+
+ initializeLeafQueueConfigs();
+
+ // run reinitialize on each existing queue, to trigger absolute cap
+ // recomputations
+ for (CSQueue res : this.getChildQueues()) {
+ res.reinitialize(res, clusterResource);
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Initialize leaf queue configs from template configurations specified on parent queue
+ */
+ protected void initializeLeafQueueConfigs() {
+
+ CapacitySchedulerConfiguration conf = csContext.getConfiguration();
+
+ final String queuePath = super.getQueuePath();
+ int maxApps = conf.getMaximumApplicationsPerQueue(queuePath);
+ if (maxApps < 0) {
+ maxApps = (int) (
+ CapacitySchedulerConfiguration.DEFAULT_MAXIMUM_SYSTEM_APPLICATIIONS
+ * getAbsoluteCapacity());
+ }
+ userLimit = conf.getUserLimit(queuePath);
+ userLimitFactor = conf.getUserLimitFactor(queuePath);
+ maxAppsForAutoCreatedQueues = maxApps;
+ maxAppsPerUserForAutoCreatedQueues =
+ (int) (maxApps * (userLimit / 100.0f) * userLimitFactor);
+ }
+
+ /**
+ * Number of maximum applications for each of the auto created leaf queues
+ *
+ * @return maxAppsForAutoCreatedQueues
+ */
+ public int getMaxApplicationsForAutoCreatedQueues() {
+ return maxAppsForAutoCreatedQueues;
+ }
+
+ /**
+ * Number of maximum applications per user for each of the auto created leaf queues
+ *
+ * @return maxAppsPerUserForAutoCreatedQueues
+ */
+ public int getMaxApplicationsPerUserForAutoCreatedQueues() {
+ return maxAppsPerUserForAutoCreatedQueues;
+ }
+
+ /**
+ * User limit value for each of the auto created leaf queues
+ *
+ * @return userLimit
+ */
+ public int getUserLimitForAutoCreatedQueues() {
+ return userLimit;
+ }
+
+ /**
+ * User limit factor value for each of the auto created leaf queues
+ *
+ * @return userLimitFactor
+ */
+ public float getUserLimitFactor() {
+ return userLimitFactor;
+ }
+
+ public int getMaxAppsForAutoCreatedQueues() {
+ return maxAppsForAutoCreatedQueues;
+ }
+
+ public int getMaxAppsPerUserForAutoCreatedQueues() {
+ return maxAppsPerUserForAutoCreatedQueues;
+ }
+
+ public int getUserLimit() {
+ return userLimit;
+ }
+
+ /**
+ * Validate the specified queue (specific to the underlying implementation)
+ * @param newQueue
+ * @throws IOException
+ */
+ public abstract void validate(CSQueue newQueue) throws IOException;
+
+ /**
+ * Add the specified child queue
+ * @param childQueue reference to the child queue to be added
+ * @throws SchedulerDynamicEditException
+ */
+ public void addChildQueue(CSQueue childQueue)
+ throws SchedulerDynamicEditException {
+ try {
+ writeLock.lock();
+ if (childQueue.getCapacity() > 0) {
+ throw new SchedulerDynamicEditException(
+ "Queue " + childQueue + " being added has non zero capacity.");
+ }
+ boolean added = this.childQueues.add(childQueue);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("updateChildQueues (action: add queue): " + added + " "
+ + getChildQueuesToPrint());
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Remove the specified child queue
+ * @param childQueue reference to the child queue to be removed
+ * @throws SchedulerDynamicEditException
+ */
+ public void removeChildQueue(CSQueue childQueue)
+ throws SchedulerDynamicEditException {
+ try {
+ writeLock.lock();
+ if (childQueue.getCapacity() > 0) {
+ throw new SchedulerDynamicEditException(
+ "Queue " + childQueue + " being removed has non zero capacity.");
+ }
+ Iterator qiter = childQueues.iterator();
+ while (qiter.hasNext()) {
+ CSQueue cs = qiter.next();
+ if (cs.equals(childQueue)) {
+ qiter.remove();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Removed child queue: {}" + cs.getQueueName());
+ }
+ }
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Remove the specified child queue
+ * @param childQueueName name of the child queue to be removed
+ * @throws SchedulerDynamicEditException
+ */
+ public CSQueue removeChildQueue(String childQueueName)
+ throws SchedulerDynamicEditException {
+ CSQueue childQueue;
+ try {
+ writeLock.lock();
+ childQueue = this.csContext.getCapacitySchedulerQueueManager().getQueue(
+ childQueueName);
+ if (childQueue != null) {
+ removeChildQueue(childQueue);
+ } else {
+ throw new SchedulerDynamicEditException("Cannot find queue to delete " + childQueueName);
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ return childQueue;
+ }
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AutoCreatedLeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AutoCreatedLeafQueue.java
new file mode 100644
index 00000000000..676fef17347
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AutoCreatedLeafQueue.java
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
+
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class AutoCreatedLeafQueue extends LeafQueue {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(AutoCreatedLeafQueue.class);
+
+ private AbstractManagedParentQueue parent;
+
+ public AutoCreatedLeafQueue(CapacitySchedulerContext cs, String queueName,
+ AbstractManagedParentQueue parent) throws IOException {
+ super(cs, queueName, parent, null);
+
+ updateApplicationAndUserLimits(parent.getUserLimitForAutoCreatedQueues(),
+ parent.getUserLimitFactor(),
+ parent.getMaxApplicationsForAutoCreatedQueues(),
+ parent.getMaxApplicationsPerUserForAutoCreatedQueues());
+
+ this.parent = parent;
+ }
+
+ @Override
+ public void reinitialize(CSQueue newlyParsedQueue,
+ Resource clusterResource) throws IOException {
+ try {
+ writeLock.lock();
+
+ validate(newlyParsedQueue);
+
+ super.reinitialize(newlyParsedQueue, clusterResource);
+ CSQueueUtils.updateQueueStatistics(resourceCalculator, clusterResource,
+ this, labelManager, null);
+
+ updateApplicationAndUserLimits(parent.getUserLimitForAutoCreatedQueues(),
+ parent.getUserLimitFactor(),
+ parent.getMaxApplicationsForAutoCreatedQueues(),
+ parent.getMaxApplicationsPerUserForAutoCreatedQueues());
+
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ private void validate(final CSQueue newlyParsedQueue) throws IOException {
+ if (!(newlyParsedQueue instanceof AutoCreatedLeafQueue) || !newlyParsedQueue
+ .getQueuePath().equals(getQueuePath())) {
+ throw new IOException(
+ "Error trying to reinitialize " + getQueuePath() + " from "
+ + newlyParsedQueue.getQueuePath());
+ }
+
+ }
+
+ @Override
+ protected void setupConfigurableCapacities() {
+ CSQueueUtils.updateAndCheckCapacitiesByLabel(getQueuePath(),
+ queueCapacities, parent == null ? null : parent.getQueueCapacities());
+ }
+
+ private void updateApplicationAndUserLimits(int userLimit, float userLimitFactor,
+ int maxAppsForAutoCreatedQueues, int maxAppsPerUserForAutoCreatedQueues) {
+ setUserLimit(userLimit);
+ setUserLimitFactor(userLimitFactor);
+ setMaxApplications(maxAppsForAutoCreatedQueues);
+ setMaxApplicationsPerUser(maxAppsPerUserForAutoCreatedQueues);
+ }
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
index d91aa55a487..ca4f73275d7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
@@ -1921,12 +1921,12 @@ public void removeQueue(String queueName)
writeLock.lock();
LOG.info("Removing queue: " + queueName);
CSQueue q = this.getQueue(queueName);
- if (!(q instanceof ReservationQueue)) {
+ if (!(q instanceof AutoCreatedLeafQueue)) {
throw new SchedulerDynamicEditException(
"The queue that we are asked " + "to remove (" + queueName
- + ") is not a ReservationQueue");
+ + ") is not a AutoCreatedLeafQueue");
}
- ReservationQueue disposableLeafQueue = (ReservationQueue) q;
+ AutoCreatedLeafQueue disposableLeafQueue = (AutoCreatedLeafQueue) q;
// at this point we should have no more apps
if (disposableLeafQueue.getNumApplications() > 0) {
throw new SchedulerDynamicEditException(
@@ -1936,9 +1936,9 @@ public void removeQueue(String queueName)
+ " pending apps");
}
- ((PlanQueue) disposableLeafQueue.getParent()).removeChildQueue(q);
+ ((AbstractManagedParentQueue) disposableLeafQueue.getParent()).removeChildQueue(q);
this.queueManager.removeQueue(queueName);
- LOG.info("Removal of ReservationQueue " + queueName + " has succeeded");
+ LOG.info("Removal of AutoCreatedLeafQueue " + queueName + " has succeeded");
} finally {
writeLock.unlock();
}
@@ -1949,25 +1949,25 @@ public void addQueue(Queue queue)
throws SchedulerDynamicEditException {
try {
writeLock.lock();
- if (!(queue instanceof ReservationQueue)) {
+ if (!(queue instanceof AutoCreatedLeafQueue)) {
throw new SchedulerDynamicEditException(
- "Queue " + queue.getQueueName() + " is not a ReservationQueue");
+ "Queue " + queue.getQueueName() + " is not a AutoCreatedLeafQueue");
}
- ReservationQueue newQueue = (ReservationQueue) queue;
+ AutoCreatedLeafQueue newQueue = (AutoCreatedLeafQueue) queue;
- if (newQueue.getParent() == null || !(newQueue
- .getParent() instanceof PlanQueue)) {
+ if (newQueue.getParent() == null || !(AbstractManagedParentQueue.class.isAssignableFrom(newQueue
+ .getParent().getClass()))) {
throw new SchedulerDynamicEditException(
"ParentQueue for " + newQueue.getQueueName()
- + " is not properly set (should be set and be a PlanQueue)");
+ + " is not properly set (should be set and be a PlanQueue or AutoCreateEnableParentQueue)");
}
- PlanQueue parentPlan = (PlanQueue) newQueue.getParent();
+ AbstractManagedParentQueue parentPlan = (AbstractManagedParentQueue) newQueue.getParent();
String queuename = newQueue.getQueueName();
parentPlan.addChildQueue(newQueue);
this.queueManager.addQueue(queuename, newQueue);
- LOG.info("Creation of ReservationQueue " + newQueue + " succeeded");
+ LOG.info("Creation of AutoCreatedLeafQueue " + newQueue + " succeeded");
} finally {
writeLock.unlock();
}
@@ -1981,21 +1981,21 @@ public void setEntitlement(String inQueue, QueueEntitlement entitlement)
LeafQueue queue = this.queueManager.getAndCheckLeafQueue(inQueue);
ParentQueue parent = (ParentQueue) queue.getParent();
- if (!(queue instanceof ReservationQueue)) {
+ if (!(queue instanceof AutoCreatedLeafQueue)) {
throw new SchedulerDynamicEditException(
"Entitlement can not be" + " modified dynamically since queue "
- + inQueue + " is not a ReservationQueue");
+ + inQueue + " is not a AutoCreatedLeafQueue");
}
- if (!(parent instanceof PlanQueue)) {
+ if (parent == null || !(AbstractManagedParentQueue.class.isAssignableFrom(parent.getClass()))) {
throw new SchedulerDynamicEditException(
- "The parent of ReservationQueue " + inQueue
- + " must be an PlanQueue");
+ "The parent of AutoCreatedLeafQueue " + inQueue
+ + " must be a PlanQueue/AutoCreateEnabledParentQueue");
}
- ReservationQueue newQueue = (ReservationQueue) queue;
+ AutoCreatedLeafQueue newQueue = (AutoCreatedLeafQueue) queue;
- float sumChilds = ((PlanQueue) parent).sumOfChildCapacities();
+ float sumChilds = parent.sumOfChildCapacities();
float newChildCap =
sumChilds - queue.getCapacity() + entitlement.getCapacity();
@@ -2010,11 +2010,11 @@ public void setEntitlement(String inQueue, QueueEntitlement entitlement)
newQueue.setEntitlement(entitlement);
} else{
throw new SchedulerDynamicEditException(
- "Sum of child queues would exceed 100% for PlanQueue: " + parent
+ "Sum of child queues would exceed 100% for auto creating parent queue : " + parent
.getQueueName());
}
LOG.info(
- "Set entitlement for ReservationQueue " + inQueue + " to " + queue
+ "Set entitlement for AutoCreatedLeafQueue " + inQueue + " to " + queue
.getCapacity() + " request was (" + entitlement.getCapacity()
+ ")");
} finally {
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueManager.java
index 48c289f0cde..7be2529a437 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueManager.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueManager.java
@@ -238,7 +238,7 @@ static CSQueue parseQueue(
queueName + ReservationConstants.DEFAULT_QUEUE_SUFFIX;
List childQueues = new ArrayList<>();
- ReservationQueue resQueue = new ReservationQueue(csContext,
+ AutoCreatedLeafQueue resQueue = new AutoCreatedLeafQueue(csContext,
defReservationId, (PlanQueue) queue);
try {
resQueue.setEntitlement(new QueueEntitlement(1.0f, 1.0f));
@@ -303,7 +303,7 @@ private void validateQueueHierarchy(Map queues,
Map newQueues) throws IOException {
// check that all static queues are included in the newQueues list
for (Map.Entry e : queues.entrySet()) {
- if (!(e.getValue() instanceof ReservationQueue)) {
+ if (!(e.getValue() instanceof AutoCreatedLeafQueue)) {
String queueName = e.getKey();
CSQueue oldQueue = e.getValue();
CSQueue newQueue = newQueues.get(queueName);
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
index f24e30aa1ee..55d5f3bfbbc 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
@@ -65,6 +65,7 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.UsersManager.User;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.KillableContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.QueueEntitlement;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ResourceCommitRequest;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
@@ -1997,6 +1998,10 @@ public void setAbsoluteCapacity(float absoluteCapacity) {
queueCapacities.setAbsoluteCapacity(absoluteCapacity);
}
+ public void setMaxApplicationsPerUser(int maxApplications) {
+ this.maxApplicationsPerUser = maxApplications;
+ }
+
public void setMaxApplications(int maxApplications) {
this.maxApplications = maxApplications;
}
@@ -2116,4 +2121,33 @@ public long getMaximumApplicationLifetime() {
public long getDefaultApplicationLifetime() {
return defaultApplicationLifetime;
}
+
+ /**
+ * This methods to change capacity for a queue and adjusts its
+ * absoluteCapacity
+ *
+ * @param entitlement the new entitlement for the queue (capacity,
+ * maxCapacity)
+ * @throws SchedulerDynamicEditException
+ */
+ public void setEntitlement(QueueEntitlement entitlement)
+ throws SchedulerDynamicEditException {
+ try {
+ writeLock.lock();
+ float capacity = entitlement.getCapacity();
+ if (capacity < 0 || capacity > 1.0f) {
+ throw new SchedulerDynamicEditException(
+ "Capacity demand is not in the [0,1] range: " + capacity);
+ }
+ setCapacity(capacity);
+ setAbsoluteCapacity(getParent().getAbsoluteCapacity() * getCapacity());
+ setMaxCapacity(entitlement.getMaxCapacity());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("successfully changed to " + capacity + " for queue " + this
+ .getQueueName());
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
index 6800b74f8d4..7235a6e922a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.java
@@ -54,6 +54,7 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApplicationAttempt;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivitiesLogger;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.activities.ActivityDiagnosticConstant;
@@ -1080,4 +1081,17 @@ public void stopQueue() {
public QueueOrderingPolicy getQueueOrderingPolicy() {
return queueOrderingPolicy;
}
+
+ protected float sumOfChildCapacities() {
+ try {
+ writeLock.lock();
+ float ret = 0;
+ for (CSQueue l : childQueues) {
+ ret += l.getCapacity();
+ }
+ return ret;
+ } finally {
+ writeLock.unlock();
+ }
+ }
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/PlanQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/PlanQueue.java
index 882262fafcc..91bfe758caf 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/PlanQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/PlanQueue.java
@@ -19,11 +19,8 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
import java.io.IOException;
-import java.util.Iterator;
-import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystem;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,191 +30,43 @@
* reservations, but functionality wise is a sub-class of ParentQueue
*
*/
-public class PlanQueue extends ParentQueue {
+public class PlanQueue extends AbstractManagedParentQueue {
private static final Logger LOG = LoggerFactory.getLogger(PlanQueue.class);
- private int maxAppsForReservation;
- private int maxAppsPerUserForReservation;
- private int userLimit;
- private float userLimitFactor;
- protected CapacitySchedulerContext schedulerContext;
private boolean showReservationsAsQueues;
public PlanQueue(CapacitySchedulerContext cs, String queueName,
CSQueue parent, CSQueue old) throws IOException {
super(cs, queueName, parent, old);
-
- this.schedulerContext = cs;
- // Set the reservation queue attributes for the Plan
- CapacitySchedulerConfiguration conf = cs.getConfiguration();
- String queuePath = super.getQueuePath();
- int maxAppsForReservation = conf.getMaximumApplicationsPerQueue(queuePath);
- showReservationsAsQueues = conf.getShowReservationAsQueues(queuePath);
- if (maxAppsForReservation < 0) {
- maxAppsForReservation =
- (int) (CapacitySchedulerConfiguration.DEFAULT_MAXIMUM_SYSTEM_APPLICATIIONS * super
- .getAbsoluteCapacity());
- }
- int userLimit = conf.getUserLimit(queuePath);
- float userLimitFactor = conf.getUserLimitFactor(queuePath);
- int maxAppsPerUserForReservation =
- (int) (maxAppsForReservation * (userLimit / 100.0f) * userLimitFactor);
- updateQuotas(userLimit, userLimitFactor, maxAppsForReservation,
- maxAppsPerUserForReservation);
-
- StringBuffer queueInfo = new StringBuffer();
- queueInfo.append("Created Plan Queue: ").append(queueName)
- .append("\nwith capacity: [").append(super.getCapacity())
- .append("]\nwith max capacity: [").append(super.getMaximumCapacity())
- .append("\nwith max reservation apps: [").append(maxAppsForReservation)
- .append("]\nwith max reservation apps per user: [")
- .append(maxAppsPerUserForReservation).append("]\nwith user limit: [")
- .append(userLimit).append("]\nwith user limit factor: [")
- .append(userLimitFactor).append("].");
- LOG.info(queueInfo.toString());
}
@Override
- public void reinitialize(CSQueue newlyParsedQueue,
- Resource clusterResource) throws IOException {
- try {
- writeLock.lock();
- // Sanity check
- if (!(newlyParsedQueue instanceof PlanQueue) || !newlyParsedQueue
- .getQueuePath().equals(getQueuePath())) {
- throw new IOException(
- "Trying to reinitialize " + getQueuePath() + " from "
- + newlyParsedQueue.getQueuePath());
- }
-
- PlanQueue newlyParsedParentQueue = (PlanQueue) newlyParsedQueue;
-
- if (newlyParsedParentQueue.getChildQueues().size() != 1) {
- throw new IOException(
- "Reservable Queue should not have sub-queues in the"
- + "configuration expect the default reservation queue");
- }
-
- // Set new configs
- setupQueueConfigs(clusterResource);
-
- updateQuotas(newlyParsedParentQueue.userLimit,
- newlyParsedParentQueue.userLimitFactor,
- newlyParsedParentQueue.maxAppsForReservation,
- newlyParsedParentQueue.maxAppsPerUserForReservation);
-
- // run reinitialize on each existing queue, to trigger absolute cap
- // recomputations
- for (CSQueue res : this.getChildQueues()) {
- res.reinitialize(res, clusterResource);
- }
- showReservationsAsQueues =
- newlyParsedParentQueue.showReservationsAsQueues;
- } finally {
- writeLock.unlock();
- }
+ protected void initializeLeafQueueConfigs() {
+ String queuePath = super.getQueuePath();
+ showReservationsAsQueues = csContext.getConfiguration().getShowReservationAsQueues(queuePath);
+ super.initializeLeafQueueConfigs();
}
- void addChildQueue(CSQueue newQueue)
- throws SchedulerDynamicEditException {
- try {
- writeLock.lock();
- if (newQueue.getCapacity() > 0) {
- throw new SchedulerDynamicEditException(
- "Queue " + newQueue + " being added has non zero capacity.");
- }
- boolean added = this.childQueues.add(newQueue);
- if (LOG.isDebugEnabled()) {
- LOG.debug("updateChildQueues (action: add queue): " + added + " "
- + getChildQueuesToPrint());
- }
- } finally {
- writeLock.unlock();
+ @Override
+ public void validate(final CSQueue newlyParsedQueue) throws IOException {
+ // Sanity check
+ if (!(newlyParsedQueue instanceof PlanQueue) || !newlyParsedQueue
+ .getQueuePath().equals(getQueuePath())) {
+ throw new IOException(
+ "Trying to reinitialize " + getQueuePath() + " from "
+ + newlyParsedQueue.getQueuePath());
}
- }
- void removeChildQueue(CSQueue remQueue)
- throws SchedulerDynamicEditException {
- try {
- writeLock.lock();
- if (remQueue.getCapacity() > 0) {
- throw new SchedulerDynamicEditException(
- "Queue " + remQueue + " being removed has non zero capacity.");
- }
- Iterator qiter = childQueues.iterator();
- while (qiter.hasNext()) {
- CSQueue cs = qiter.next();
- if (cs.equals(remQueue)) {
- qiter.remove();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Removed child queue: {}", cs.getQueueName());
- }
- }
- }
- } finally {
- writeLock.unlock();
- }
- }
+ PlanQueue newlyParsedParentQueue = (PlanQueue) newlyParsedQueue;
- protected float sumOfChildCapacities() {
- try {
- writeLock.lock();
- float ret = 0;
- for (CSQueue l : childQueues) {
- ret += l.getCapacity();
- }
- return ret;
- } finally {
- writeLock.unlock();
+ if (newlyParsedParentQueue.getChildQueues().size() != 1) {
+ throw new IOException(
+ "Reservable Queue should not have sub-queues in the"
+ + "configuration expect the default reservation queue");
}
}
- private void updateQuotas(int userLimit, float userLimitFactor,
- int maxAppsForReservation, int maxAppsPerUserForReservation) {
- this.userLimit = userLimit;
- this.userLimitFactor = userLimitFactor;
- this.maxAppsForReservation = maxAppsForReservation;
- this.maxAppsPerUserForReservation = maxAppsPerUserForReservation;
- }
-
- /**
- * Number of maximum applications for each of the reservations in this Plan.
- *
- * @return maxAppsForreservation
- */
- public int getMaxApplicationsForReservations() {
- return maxAppsForReservation;
- }
-
- /**
- * Number of maximum applications per user for each of the reservations in
- * this Plan.
- *
- * @return maxAppsPerUserForreservation
- */
- public int getMaxApplicationsPerUserForReservation() {
- return maxAppsPerUserForReservation;
- }
-
- /**
- * User limit value for each of the reservations in this Plan.
- *
- * @return userLimit
- */
- public int getUserLimitForReservation() {
- return userLimit;
- }
-
- /**
- * User limit factor value for each of the reservations in this Plan.
- *
- * @return userLimitFactor
- */
- public float getUserLimitFactor() {
- return userLimitFactor;
- }
-
/**
* Determine whether to hide/show the ReservationQueues
*/
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ReservationQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ReservationQueue.java
deleted file mode 100644
index 3d1b7317489..00000000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ReservationQueue.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
-
-import java.io.IOException;
-
-import org.apache.hadoop.yarn.api.records.Resource;
-import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystem;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.QueueEntitlement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This represents a dynamic {@link LeafQueue} managed by the
- * {@link ReservationSystem}
- *
- */
-public class ReservationQueue extends LeafQueue {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(ReservationQueue.class);
-
- private PlanQueue parent;
-
- public ReservationQueue(CapacitySchedulerContext cs, String queueName,
- PlanQueue parent) throws IOException {
- super(cs, queueName, parent, null);
- // the following parameters are common to all reservation in the plan
- updateQuotas(parent.getUserLimitForReservation(),
- parent.getUserLimitFactor(),
- parent.getMaxApplicationsForReservations(),
- parent.getMaxApplicationsPerUserForReservation());
- this.parent = parent;
- }
-
- @Override
- public void reinitialize(CSQueue newlyParsedQueue,
- Resource clusterResource) throws IOException {
- try {
- writeLock.lock();
- // Sanity check
- if (!(newlyParsedQueue instanceof ReservationQueue) || !newlyParsedQueue
- .getQueuePath().equals(getQueuePath())) {
- throw new IOException(
- "Trying to reinitialize " + getQueuePath() + " from "
- + newlyParsedQueue.getQueuePath());
- }
- super.reinitialize(newlyParsedQueue, clusterResource);
- CSQueueUtils.updateQueueStatistics(resourceCalculator, clusterResource,
- this, labelManager, null);
-
- updateQuotas(parent.getUserLimitForReservation(),
- parent.getUserLimitFactor(),
- parent.getMaxApplicationsForReservations(),
- parent.getMaxApplicationsPerUserForReservation());
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * This methods to change capacity for a queue and adjusts its
- * absoluteCapacity
- *
- * @param entitlement the new entitlement for the queue (capacity,
- * maxCapacity, etc..)
- * @throws SchedulerDynamicEditException
- */
- public void setEntitlement(QueueEntitlement entitlement)
- throws SchedulerDynamicEditException {
- try {
- writeLock.lock();
- float capacity = entitlement.getCapacity();
- if (capacity < 0 || capacity > 1.0f) {
- throw new SchedulerDynamicEditException(
- "Capacity demand is not in the [0,1] range: " + capacity);
- }
- setCapacity(capacity);
- setAbsoluteCapacity(getParent().getAbsoluteCapacity() * getCapacity());
- // note: we currently set maxCapacity to capacity
- // this might be revised later
- setMaxCapacity(entitlement.getMaxCapacity());
- if (LOG.isDebugEnabled()) {
- LOG.debug("successfully changed to " + capacity + " for queue " + this
- .getQueueName());
- }
- } finally {
- writeLock.unlock();
- }
- }
-
- private void updateQuotas(int userLimit, float userLimitFactor,
- int maxAppsForReservation, int maxAppsPerUserForReservation) {
- setUserLimit(userLimit);
- setUserLimitFactor(userLimitFactor);
- setMaxApplications(maxAppsForReservation);
- maxApplicationsPerUser = maxAppsPerUserForReservation;
- }
-
- @Override
- protected void setupConfigurableCapacities() {
- CSQueueUtils.updateAndCheckCapacitiesByLabel(getQueuePath(),
- queueCapacities, parent == null ? null : parent.getQueueCapacities());
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservationQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedLeafQueue.java
similarity index 73%
rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservationQueue.java
rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedLeafQueue.java
index e23e93c99dd..3ed15b3db43 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservationQueue.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedLeafQueue.java
@@ -36,7 +36,7 @@
import org.junit.Before;
import org.junit.Test;
-public class TestReservationQueue {
+public class TestAutoCreatedLeafQueue {
CapacitySchedulerConfiguration csConf;
CapacitySchedulerContext csContext;
@@ -44,7 +44,7 @@
final static int GB = 1024;
private final ResourceCalculator resourceCalculator =
new DefaultResourceCalculator();
- ReservationQueue reservationQueue;
+ AutoCreatedLeafQueue autoCreatedLeafQueue;
@Before
public void setup() throws IOException {
@@ -67,43 +67,43 @@ public void setup() throws IOException {
// create a queue
PlanQueue pq = new PlanQueue(csContext, "root", null, null);
- reservationQueue = new ReservationQueue(csContext, "a", pq);
+ autoCreatedLeafQueue = new AutoCreatedLeafQueue(csContext, "a", pq);
}
- private void validateReservationQueue(double capacity) {
- assertTrue(" actual capacity: " + reservationQueue.getCapacity(),
- reservationQueue.getCapacity() - capacity < CSQueueUtils.EPSILON);
- assertEquals(reservationQueue.maxApplications, DEF_MAX_APPS);
- assertEquals(reservationQueue.maxApplicationsPerUser, DEF_MAX_APPS);
+ private void validateAutoCreatedLeafQueue(double capacity) {
+ assertTrue(" actual capacity: " + autoCreatedLeafQueue.getCapacity(),
+ autoCreatedLeafQueue.getCapacity() - capacity < CSQueueUtils.EPSILON);
+ assertEquals(autoCreatedLeafQueue.maxApplications, DEF_MAX_APPS);
+ assertEquals(autoCreatedLeafQueue.maxApplicationsPerUser, DEF_MAX_APPS);
}
@Test
public void testAddSubtractCapacity() throws Exception {
// verify that setting, adding, subtracting capacity works
- reservationQueue.setCapacity(1.0F);
- validateReservationQueue(1);
- reservationQueue.setEntitlement(new QueueEntitlement(0.9f, 1f));
- validateReservationQueue(0.9);
- reservationQueue.setEntitlement(new QueueEntitlement(1f, 1f));
- validateReservationQueue(1);
- reservationQueue.setEntitlement(new QueueEntitlement(0f, 1f));
- validateReservationQueue(0);
+ autoCreatedLeafQueue.setCapacity(1.0F);
+ validateAutoCreatedLeafQueue(1);
+ autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(0.9f, 1f));
+ validateAutoCreatedLeafQueue(0.9);
+ autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(1f, 1f));
+ validateAutoCreatedLeafQueue(1);
+ autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(0f, 1f));
+ validateAutoCreatedLeafQueue(0);
try {
- reservationQueue.setEntitlement(new QueueEntitlement(1.1f, 1f));
+ autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(1.1f, 1f));
fail();
} catch (SchedulerDynamicEditException iae) {
// expected
- validateReservationQueue(1);
+ validateAutoCreatedLeafQueue(1);
}
try {
- reservationQueue.setEntitlement(new QueueEntitlement(-0.1f, 1f));
+ autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(-0.1f, 1f));
fail();
} catch (SchedulerDynamicEditException iae) {
// expected
- validateReservationQueue(1);
+ validateAutoCreatedLeafQueue(1);
}
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerDynamicBehavior.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerDynamicBehavior.java
index 9aba30c2e88..9425d5ea89b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerDynamicBehavior.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerDynamicBehavior.java
@@ -77,21 +77,21 @@ public void testRefreshQueuesWithReservations() throws Exception {
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
//set default queue capacity to zero
- ((ReservationQueue) cs
+ ((AutoCreatedLeafQueue) cs
.getQueue("a" + ReservationConstants.DEFAULT_QUEUE_SUFFIX))
.setEntitlement(
new QueueEntitlement(0f, 1f));
// Test add one reservation dynamically and manually modify capacity
- ReservationQueue a1 =
- new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
+ AutoCreatedLeafQueue a1 =
+ new AutoCreatedLeafQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
cs.addQueue(a1);
a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f));
// Test add another reservation queue and use setEntitlement to modify
// capacity
- ReservationQueue a2 =
- new ReservationQueue(cs, "a2", (PlanQueue) cs.getQueue("a"));
+ AutoCreatedLeafQueue a2 =
+ new AutoCreatedLeafQueue(cs, "a2", (PlanQueue) cs.getQueue("a"));
cs.addQueue(a2);
cs.setEntitlement("a2", new QueueEntitlement(A2_CAPACITY / 100, 1.0f));
@@ -113,8 +113,8 @@ public void testAddQueueFailCases() throws Exception {
try {
// Test invalid addition (adding non-zero size queue)
- ReservationQueue a1 =
- new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
+ AutoCreatedLeafQueue a1 =
+ new AutoCreatedLeafQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f));
cs.addQueue(a1);
fail();
@@ -123,11 +123,11 @@ public void testAddQueueFailCases() throws Exception {
}
// Test add one reservation dynamically and manually modify capacity
- ReservationQueue a1 =
- new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
+ AutoCreatedLeafQueue a1 =
+ new AutoCreatedLeafQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
cs.addQueue(a1);
//set default queue capacity to zero
- ((ReservationQueue) cs
+ ((AutoCreatedLeafQueue) cs
.getQueue("a" + ReservationConstants.DEFAULT_QUEUE_SUFFIX))
.setEntitlement(
new QueueEntitlement(0f, 1f));
@@ -135,8 +135,8 @@ public void testAddQueueFailCases() throws Exception {
// Test add another reservation queue and use setEntitlement to modify
// capacity
- ReservationQueue a2 =
- new ReservationQueue(cs, "a2", (PlanQueue) cs.getQueue("a"));
+ AutoCreatedLeafQueue a2 =
+ new AutoCreatedLeafQueue(cs, "a2", (PlanQueue) cs.getQueue("a"));
cs.addQueue(a2);
@@ -162,8 +162,8 @@ public void testRemoveQueue() throws Exception {
CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
// Test add one reservation dynamically and manually modify capacity
- ReservationQueue a1 =
- new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
+ AutoCreatedLeafQueue a1 =
+ new AutoCreatedLeafQueue(cs, "a1", (PlanQueue) cs.getQueue("a"));
cs.addQueue(a1);
a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f));
@@ -230,8 +230,8 @@ public void testMoveAppToPlanQueue() throws Exception {
// create the default reservation queue
String defQName = "a" + ReservationConstants.DEFAULT_QUEUE_SUFFIX;
- ReservationQueue defQ =
- new ReservationQueue(scheduler, defQName,
+ AutoCreatedLeafQueue defQ =
+ new AutoCreatedLeafQueue(scheduler, defQName,
(PlanQueue) scheduler.getQueue("a"));
scheduler.addQueue(defQ);
defQ.setEntitlement(new QueueEntitlement(1f, 1f));