/** * Get a parent queue by name, creating it if the create param is * <code>true</code> and the queue does not exist. * 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, <code>null</code> is returned. * * The root part of the name is optional, so a queue underneath the root * named "queue1" could be referred to as just "queue1", and a queue named * "queue2" underneath a parent named "parent1" that is underneath the root * could be referred to as just "parent1.queue2". * @param name name of the queue * @param create <code>true</code> if the queue must be created if it does * not exist, <code>false</code> otherwise * @return the parent queue or <code>null</code> if the queue cannot be found */ public FSParentQueue getParentQueue(String name, boolean create) { return getParentQueue(name, create, true); }
@Override protected Queue getPlanQueue(String planQueueName) { Queue planQueue = fs.getQueueManager().getParentQueue(planQueueName, false); if (planQueue == null) { LOG.error("The queue " + planQueueName + " cannot be found or is not a " + "ParentQueue"); } return planQueue; }
@Override protected Queue getPlanQueue(String planQueueName) { Queue planQueue = fs.getQueueManager().getParentQueue(planQueueName, false); if (planQueue == null) { LOG.error("The queue " + planQueueName + " cannot be found or is not a " + "ParentQueue"); } return planQueue; }
@Override protected Queue getPlanQueue(String planQueueName) { Queue planQueue = fs.getQueueManager().getParentQueue(planQueueName, false); if (planQueue == null) { LOG.error("The queue " + planQueueName + " cannot be found or is not a " + "ParentQueue"); } return planQueue; }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { return fairScheduler.getQueueManager().getParentQueue(planQueueName, false) .getSteadyFairShare(); }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { return fairScheduler.getQueueManager().getParentQueue(planQueueName, false) .getSteadyFairShare(); }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { return fairScheduler.getQueueManager().getParentQueue(planQueueName, false) .getSteadyFairShare(); }
@Test public void testLowestCommonAncestorDeeperHierarchy() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); FSQueue aQueue = mock(FSLeafQueue.class); FSQueue bQueue = mock(FSLeafQueue.class); FSQueue a1Queue = mock(FSLeafQueue.class); FSQueue b1Queue = mock(FSLeafQueue.class); when(a1Queue.getName()).thenReturn("root.queue1.a.a1"); when(b1Queue.getName()).thenReturn("root.queue1.b.b1"); when(aQueue.getChildQueues()).thenReturn(Arrays.asList(a1Queue)); when(bQueue.getChildQueues()).thenReturn(Arrays.asList(b1Queue)); QueueManager queueManager = scheduler.getQueueManager(); FSParentQueue queue1 = queueManager.getParentQueue("queue1", true); queue1.addChildQueue(aQueue); queue1.addChildQueue(bQueue); FSQueue ancestorQueue = scheduler.findLowestCommonAncestorQueue(a1Queue, b1Queue); assertEquals(ancestorQueue, queue1); }
@Test public void testLowestCommonAncestorForNonRootParent() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); FSLeafQueue aQueue = mock(FSLeafQueue.class); FSLeafQueue bQueue = mock(FSLeafQueue.class); when(aQueue.getName()).thenReturn("root.queue1.a"); when(bQueue.getName()).thenReturn("root.queue1.b"); QueueManager queueManager = scheduler.getQueueManager(); FSParentQueue queue1 = queueManager.getParentQueue("queue1", true); queue1.addChildQueue(aQueue); queue1.addChildQueue(bQueue); FSQueue ancestorQueue = scheduler.findLowestCommonAncestorQueue(aQueue, bQueue); assertEquals(ancestorQueue, queue1); }
@Test public void testLowestCommonAncestorRootParent() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); FSLeafQueue aQueue = mock(FSLeafQueue.class); FSLeafQueue bQueue = mock(FSLeafQueue.class); when(aQueue.getName()).thenReturn("root.a"); when(bQueue.getName()).thenReturn("root.b"); QueueManager queueManager = scheduler.getQueueManager(); FSParentQueue queue1 = queueManager.getParentQueue("root", false); queue1.addChildQueue(aQueue); queue1.addChildQueue(bQueue); FSQueue ancestorQueue = scheduler.findLowestCommonAncestorQueue(aQueue, bQueue); assertEquals(ancestorQueue, queue1); }
@Test public void testLowestCommonAncestorRootParent() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); FSLeafQueue aQueue = mock(FSLeafQueue.class); FSLeafQueue bQueue = mock(FSLeafQueue.class); when(aQueue.getName()).thenReturn("root.a"); when(bQueue.getName()).thenReturn("root.b"); QueueManager queueManager = scheduler.getQueueManager(); FSParentQueue queue1 = queueManager.getParentQueue("root", false); queue1.addChildQueue(aQueue); queue1.addChildQueue(bQueue); FSQueue ancestorQueue = scheduler.findLowestCommonAncestorQueue(aQueue, bQueue); assertEquals(ancestorQueue, queue1); }
@Test public void testLowestCommonAncestorForNonRootParent() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); FSLeafQueue aQueue = mock(FSLeafQueue.class); FSLeafQueue bQueue = mock(FSLeafQueue.class); when(aQueue.getName()).thenReturn("root.queue1.a"); when(bQueue.getName()).thenReturn("root.queue1.b"); QueueManager queueManager = scheduler.getQueueManager(); FSParentQueue queue1 = queueManager.getParentQueue("queue1", true); queue1.addChildQueue(aQueue); queue1.addChildQueue(bQueue); FSQueue ancestorQueue = scheduler.findLowestCommonAncestorQueue(aQueue, bQueue); assertEquals(ancestorQueue, queue1); }
/** * Test creation of a parent queue and its parent. */ @Test public void testCreateParentQueueAndParent() { AllocationConfiguration allocConf = scheduler.getAllocationConfiguration(); queueManager.updateAllocationConfiguration(allocConf); FSQueue q2 = queueManager.createQueue("root.queue1.queue2", FSQueueType.PARENT); assertNotNull("Parent queue root.queue1 was not created", queueManager.getParentQueue("root.queue1", false)); assertNotNull("Leaf queue root.queue1.queue2 was not created", queueManager.getParentQueue("root.queue1.queue2", false)); assertEquals("createQueue() returned wrong queue", "root.queue1.queue2", q2.getName()); }
@Test public void testConcurrentChangeToGetChildQueue() { queueManager.getLeafQueue("parent.child", true); queueManager.getLeafQueue("parent.child2", true); FSParentQueue test = queueManager.getParentQueue("parent", false); assertEquals(2, test.getChildQueues().size()); boolean first = true; int childQueuesFound = 0; for (FSQueue childQueue:test.getChildQueues()) { if (first) { first = false; queueManager.getLeafQueue("parent.child3", true); } childQueuesFound++; } assertEquals(2, childQueuesFound); assertEquals(3, test.getChildQueues().size()); } }
/** * Test creation of a simple parent queue. */ @Test public void testCreateParentQueue() { AllocationConfiguration allocConf = scheduler.getAllocationConfiguration(); queueManager.updateAllocationConfiguration(allocConf); FSQueue q1 = queueManager.createQueue("root.queue1", FSQueueType.PARENT); assertNotNull("Parent queue root.queue1 was not created", queueManager.getParentQueue("root.queue1", false)); assertEquals("createQueue() returned wrong queue", "root.queue1", q1.getName()); }
@Test public void testRemovalOfDynamicParentQueue() { AllocationConfiguration allocConf = scheduler.getAllocationConfiguration(); queueManager.updateAllocationConfiguration(allocConf); FSQueue q1 = queueManager.getLeafQueue("root.parent1.dynamic1", true); assertNotNull("Queue root.parent1.dynamic1 was not created", q1); assertEquals("createQueue() returned wrong queue", "root.parent1.dynamic1", q1.getName()); assertTrue("root.parent1.dynamic1 is not a dynamic queue", q1.isDynamic()); FSQueue p1 = queueManager.getParentQueue("root.parent1", false); assertNotNull("Queue root.parent1 was not created", p1); assertTrue("root.parent1 is not a dynamic queue", p1.isDynamic()); queueManager.removePendingIncompatibleQueues(); queueManager.removeEmptyDynamicQueues(); q1 = queueManager.getLeafQueue("root.parent1.dynamic1", false); p1 = queueManager.getParentQueue("root.parent1", false); assertNull("Queue root.parent1.dynamic1 was not deleted", q1); assertNull("Queue root.parent1 was not deleted", p1); }
/** * Test creation of a leaf queue and its parent. */ @Test public void testCreateLeafQueueAndParent() { AllocationConfiguration allocConf = scheduler.getAllocationConfiguration(); queueManager.updateAllocationConfiguration(allocConf); FSQueue q2 = queueManager.createQueue("root.queue1.queue2", FSQueueType.LEAF); assertNotNull("Parent queue root.queue1 was not created", queueManager.getParentQueue("root.queue1", false)); assertNotNull("Leaf queue root.queue1.queue2 was not created", queueManager.getLeafQueue("root.queue1.queue2", false)); assertEquals("createQueue() returned wrong queue", "root.queue1.queue2", q2.getName()); }
@Test public void testRemoveEnablesAppOnCousinQueue() { FSLeafQueue leaf1 = queueManager.getLeafQueue("root.queue1.subqueue1.leaf1", true); FSLeafQueue leaf2 = queueManager.getLeafQueue("root.queue1.subqueue2.leaf2", true); FSParentQueue queue1 = queueManager.getParentQueue("root.queue1", true); queue1.setMaxRunningApps(2); FSAppAttempt app1 = addApp(leaf1, "user"); addApp(leaf2, "user"); addApp(leaf2, "user"); assertEquals(1, leaf1.getNumRunnableApps()); assertEquals(1, leaf2.getNumRunnableApps()); assertEquals(1, leaf2.getNumNonRunnableApps()); removeApp(app1); assertEquals(0, leaf1.getNumRunnableApps()); assertEquals(2, leaf2.getNumRunnableApps()); assertEquals(0, leaf2.getNumNonRunnableApps()); }
@Test public void testMultipleAppsWaitingOnCousinQueue() { FSLeafQueue leaf1 = queueManager.getLeafQueue("root.queue1.subqueue1.leaf1", true); FSLeafQueue leaf2 = queueManager.getLeafQueue("root.queue1.subqueue2.leaf2", true); FSParentQueue queue1 = queueManager.getParentQueue("root.queue1", true); queue1.setMaxRunningApps(2); FSAppAttempt app1 = addApp(leaf1, "user"); addApp(leaf2, "user"); addApp(leaf2, "user"); addApp(leaf2, "user"); assertEquals(1, leaf1.getNumRunnableApps()); assertEquals(1, leaf2.getNumRunnableApps()); assertEquals(2, leaf2.getNumNonRunnableApps()); removeApp(app1); assertEquals(0, leaf1.getNumRunnableApps()); assertEquals(2, leaf2.getNumRunnableApps()); assertEquals(1, leaf2.getNumNonRunnableApps()); }
@Test public void testRemoveEnablingOrderedByStartTime() { FSLeafQueue leaf1 = queueManager.getLeafQueue("root.queue1.subqueue1.leaf1", true); FSLeafQueue leaf2 = queueManager.getLeafQueue("root.queue1.subqueue2.leaf2", true); FSParentQueue queue1 = queueManager.getParentQueue("root.queue1", true); queue1.setMaxRunningApps(2); FSAppAttempt app1 = addApp(leaf1, "user"); addApp(leaf2, "user"); addApp(leaf2, "user"); clock.tickSec(20); addApp(leaf1, "user"); assertEquals(1, leaf1.getNumRunnableApps()); assertEquals(1, leaf2.getNumRunnableApps()); assertEquals(1, leaf1.getNumNonRunnableApps()); assertEquals(1, leaf2.getNumNonRunnableApps()); removeApp(app1); assertEquals(0, leaf1.getNumRunnableApps()); assertEquals(2, leaf2.getNumRunnableApps()); assertEquals(0, leaf2.getNumNonRunnableApps()); }