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/fair/QueueManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/QueueManager.java index 8734877f608..f6f357e1fe6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/QueueManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/QueueManager.java @@ -49,16 +49,16 @@ @Private @Unstable public class QueueManager { - public static final Log LOG = LogFactory.getLog( - QueueManager.class.getName()); + private static final Log LOG = + LogFactory.getLog(QueueManager.class.getName()); public static final String ROOT_QUEUE = "root"; private final FairScheduler scheduler; - private final Collection leafQueues = - new CopyOnWriteArrayList(); - private final Map queues = new HashMap(); + private final Collection leafQueues = + new CopyOnWriteArrayList<>(); + private final Map queues = new HashMap<>(); private FSParentQueue rootQueue; public QueueManager(FairScheduler scheduler) { @@ -84,7 +84,8 @@ public void initialize(Configuration conf) throws IOException, } /** - * Get a leaf queue by name, creating it if the create param is true and is necessary. + * Get a leaf queue by name, creating it if the create param is + * true and is necessary. * If the queue is not or can not be a leaf queue, i.e. it already exists as a * parent queue, or one of the parents in its name is already a leaf queue, * null is returned. @@ -98,7 +99,7 @@ public FSLeafQueue getLeafQueue(String name, boolean create) { return getLeafQueue(name, create, true); } - public FSLeafQueue getLeafQueue( + private FSLeafQueue getLeafQueue( String name, boolean create, boolean recomputeSteadyShares) { @@ -115,7 +116,7 @@ public FSLeafQueue getLeafQueue( } /** - * Remove a leaf queue if empty + * Remove a leaf queue if empty. * @param name name of the queue * @return true if queue was removed or false otherwise */ @@ -126,8 +127,10 @@ public boolean removeLeafQueue(String name) { /** - * Get a parent queue by name, creating it if the create param is true and is necessary. - * If the queue is not or can not be a parent queue, i.e. it already exists as a + * Get a parent queue by name, creating it if the create param is + * true and is necessary. + * If the queue is not or can not be a parent queue, + * i.e. it already exists as a * leaf queue, or one of the parents in its name is already a leaf queue, * null is returned. * @@ -278,7 +281,8 @@ private FSQueue createNewQueues(FSQueueType queueType, SchedulingPolicy childPolicy = scheduler.getAllocationConfiguration(). getSchedulingPolicy(queueName); if (!parent.getPolicy().isChildPolicyAllowed(childPolicy)) { - LOG.error("Can't create queue '" + queueName + "'."); + LOG.error("Can't create queue '" + queueName + "'," + + "the child scheduling policy is not allowed by parent queue!"); return null; } @@ -319,8 +323,8 @@ private FSQueue createNewQueues(FSQueueType queueType, * @param child the child queue * @param queueConf the {@link AllocationConfiguration} */ - void setChildResourceLimits(FSParentQueue parent, FSQueue child, - AllocationConfiguration queueConf) { + private void setChildResourceLimits(FSParentQueue parent, FSQueue child, + AllocationConfiguration queueConf) { Map> configuredQueues = queueConf.getConfiguredQueues(); @@ -352,8 +356,8 @@ private boolean removeEmptyIncompatibleQueues(String queueToCreate, FSQueueType queueType) { queueToCreate = ensureRootPrefix(queueToCreate); - // Ensure queueToCreate is not root and doesn't have the default queue in its - // ancestry. + // Ensure queueToCreate is not root and doesn't + // have the default queue in its ancestry. if (queueToCreate.equals(ROOT_QUEUE) || queueToCreate.startsWith( ROOT_QUEUE + "." + YarnConfiguration.DEFAULT_QUEUE_NAME + ".")) { @@ -467,7 +471,7 @@ public boolean exists(String name) { } /** - * Get a collection of all leaf queues + * Get a collection of all leaf queues. */ public Collection getLeafQueues() { synchronized (queues) { @@ -476,7 +480,7 @@ public boolean exists(String name) { } /** - * Get a collection of all queues + * Get a collection of all queues. */ public Collection getQueues() { synchronized (queues) { @@ -484,7 +488,7 @@ public boolean exists(String name) { } } - private String ensureRootPrefix(String name) { + private static String ensureRootPrefix(String name) { if (!name.startsWith(ROOT_QUEUE + ".") && !name.equals(ROOT_QUEUE)) { name = ROOT_QUEUE + "." + name; } @@ -492,7 +496,8 @@ private String ensureRootPrefix(String name) { } public void updateAllocationConfiguration(AllocationConfiguration queueConf) { - // Create leaf queues and the parent queues in a leaf's ancestry if they do not exist + // Create leaf queues and the parent queues in a leaf's + // ancestry if they do not exist synchronized (queues) { // Verify and set scheduling policies for existing queues before creating // any queue, since we need parent policies to determine if we can create