/** * Remove the queue if it and its descendents are all empty. * @param queue * @return true if removed, false otherwise */ private boolean removeQueueIfEmpty(FSQueue queue) { if (isEmpty(queue)) { removeQueue(queue); return true; } return false; }
/** * Remove the queue if it and its descendents are all empty. * @param queue * @return true if removed, false otherwise */ private boolean removeQueueIfEmpty(FSQueue queue) { if (isEmpty(queue)) { removeQueue(queue); return true; } return false; }
/** * Remove the queue if it and its descendents are all empty. * @param queue * @return true if removed, false otherwise */ private boolean removeQueueIfEmpty(FSQueue queue) { if (isEmpty(queue)) { removeQueue(queue); return true; } return false; }
/** * Returns true if there are no applications, running or not, in the given * queue or any of its descendents. */ protected boolean isEmpty(FSQueue queue) { if (queue instanceof FSLeafQueue) { FSLeafQueue leafQueue = (FSLeafQueue)queue; return queue.getNumRunnableApps() == 0 && leafQueue.getNumNonRunnableApps() == 0; } else { for (FSQueue child : queue.getChildQueues()) { if (!isEmpty(child)) { return false; } } return true; } }
/** * Returns true if there are no applications, running or not, in the given * queue or any of its descendents. */ protected boolean isEmpty(FSQueue queue) { if (queue instanceof FSLeafQueue) { FSLeafQueue leafQueue = (FSLeafQueue)queue; return queue.getNumRunnableApps() == 0 && leafQueue.getNumNonRunnableApps() == 0; } else { for (FSQueue child : queue.getChildQueues()) { if (!isEmpty(child)) { return false; } } return true; } }
/** * Returns true if there are no applications, running or not, in the given * queue or any of its descendents. */ protected boolean isEmpty(FSQueue queue) { if (queue instanceof FSLeafQueue) { FSLeafQueue leafQueue = (FSLeafQueue)queue; return queue.getNumRunnableApps() == 0 && leafQueue.getNumNonRunnableApps() == 0 && leafQueue.getNumAssignedApps() == 0; } else { for (FSQueue child : queue.getChildQueues()) { if (!isEmpty(child)) { return false; } } return true; } }
assertTrue("root.a is not empty", queueManager.isEmpty(q)); q = queueManager.getLeafQueue("root.a", false); assertNotNull("root.a does not exist", q); assertFalse("root.a is empty", queueManager.isEmpty(q)); assertFalse("root.a is empty", queueManager.isEmpty(q)); q = queueManager.getLeafQueue("root.a", false); assertNotNull("root.a has been removed", q); assertFalse("root.a is empty", queueManager.isEmpty(q));
assertTrue("root.leaf1 is not empty", queueManager.isEmpty(q)); q.addAssignedApp(applicationId); q = queueManager.getLeafQueue("root.leaf1", false); assertFalse("root.leaf1 is empty", queueManager.isEmpty(q)); q = queueManager.getLeafQueue("root.leaf1", false); assertNotNull("root.leaf1 has been removed", q); assertFalse("root.leaf1 is empty", queueManager.isEmpty(q)); q = queueManager.getLeafQueue("root.leaf1", false); assertNotNull("root.leaf1 has been removed", q); assertFalse("root.leaf1 is empty", queueManager.isEmpty(q)); assertTrue("root.leaf1 is not empty", queueManager.isEmpty(q));