/** * 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; }
/** * Removes all empty dynamic queues (including empty dynamic parent queues). */ public void removeEmptyDynamicQueues() { synchronized (queues) { Set<FSParentQueue> parentQueuesToCheck = new HashSet<>(); for (FSQueue queue : getQueues()) { if (queue.isDynamic() && queue.getChildQueues().isEmpty()) { boolean removed = removeQueueIfEmpty(queue); if (removed && queue.getParent().isDynamic()) { parentQueuesToCheck.add(queue.getParent()); } } } while (!parentQueuesToCheck.isEmpty()) { FSParentQueue queue = parentQueuesToCheck.iterator().next(); if (queue.getChildQueues().isEmpty()) { removeQueue(queue); if (queue.getParent().isDynamic()) { parentQueuesToCheck.add(queue.getParent()); } } parentQueuesToCheck.remove(queue); } } }
/** * 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 a queue and all its descendents. */ private void removeQueue(FSQueue queue) { if (queue instanceof FSLeafQueue) { leafQueues.remove(queue); } else { List<FSQueue> childQueues = queue.getChildQueues(); while (!childQueues.isEmpty()) { removeQueue(childQueues.get(0)); } } queues.remove(queue.getName()); queue.getParent().getChildQueues().remove(queue); }
/** * Remove a queue and all its descendents. */ private void removeQueue(FSQueue queue) { if (queue instanceof FSLeafQueue) { leafQueues.remove(queue); } else { List<FSQueue> childQueues = queue.getChildQueues(); while (!childQueues.isEmpty()) { removeQueue(childQueues.get(0)); } } queues.remove(queue.getName()); queue.getParent().getChildQueues().remove(queue); }
/** * Remove a queue and all its descendents. */ private void removeQueue(FSQueue queue) { synchronized (queues) { if (queue instanceof FSLeafQueue) { leafQueues.remove(queue); } else { for (FSQueue childQueue:queue.getChildQueues()) { removeQueue(childQueue); } } queues.remove(queue.getName()); FSParentQueue parent = queue.getParent(); parent.removeChildQueue(queue); } }