private static List<RMApp> newRMApps(int n, long time, RMAppState state) { List<RMApp> list = Lists.newArrayList(); for (int i = 0; i < n; ++i) { list.add(new MockRMApp(i, time, state)); } return list; }
app.setCurrentAppAttempt(attempt); applicationsMaps.put(app.getApplicationId(), app); i++;
private static List<RMApp> newRMAppsMixedLogAggregationStatus(int n, long time, RMAppState state) { List<RMApp> list = Lists.newArrayList(); for (int i = 0; i < n; ++i) { MockRMApp rmApp = new MockRMApp(i, time, state); rmApp.setLogAggregationEnabled(true); rmApp.setLogAggregationFinished(i % 2 == 0); list.add(rmApp); } return list; }
public static List<RMApp> newRMApps(int n, long time, RMAppState state) { List<RMApp> list = Lists.newArrayList(); for (int i = 0; i < n; ++i) { list.add(new MockRMApp(i, time, state)); } return list; }
app.setCurrentAppAttempt(attempt); applicationsMaps.put(app.getApplicationId(), app); i++;
@Test public void testAssignToBadDefaultQueue() throws Exception { conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml version=\"1.0\"?>"); out.println("<allocations>"); out.println("<queuePlacementPolicy>"); out.println("<rule name=\"specified\" create=\"false\" />"); out.println("<rule name=\"default\" create=\"false\" />"); out.println("</queuePlacementPolicy>"); out.println("</allocations>"); out.close(); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); try { FSLeafQueue queue1 = scheduler.assignToQueue(rmApp1, "default", "asterix"); } catch (IllegalStateException ise) { fail("Bad queue placement policy terminal rule should not throw " + "exception "); } }
@Test public void testNestedUserQueue() throws IOException { conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, SimpleGroupsMapping.class, GroupMappingServiceProvider.class); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml version=\"1.0\"?>"); out.println("<allocations>"); out.println("<queue name=\"user1group\" type=\"parent\">"); out.println("<minResources>1024mb,0vcores</minResources>"); out.println("</queue>"); out.println("<queuePlacementPolicy>"); out.println("<rule name=\"specified\" create=\"false\" />"); out.println("<rule name=\"nestedUserQueue\">"); out.println(" <rule name=\"primaryGroup\" create=\"false\" />"); out.println("</rule>"); out.println("<rule name=\"default\" />"); out.println("</queuePlacementPolicy>"); out.println("</allocations>"); out.close(); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); FSLeafQueue user1Leaf = scheduler.assignToQueue(rmApp1, "root.default", "user1"); assertEquals("root.user1group.user1", user1Leaf.getName()); }
@Test public void testNestedUserQueue() throws IOException { conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE); conf.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING, SimpleGroupsMapping.class, GroupMappingServiceProvider.class); PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE)); out.println("<?xml version=\"1.0\"?>"); out.println("<allocations>"); out.println("<queue name=\"user1group\" type=\"parent\">"); out.println("<minResources>1024mb,0vcores</minResources>"); out.println("</queue>"); out.println("<queuePlacementPolicy>"); out.println("<rule name=\"specified\" create=\"false\" />"); out.println("<rule name=\"nestedUserQueue\">"); out.println(" <rule name=\"primaryGroup\" create=\"false\" />"); out.println("</rule>"); out.println("<rule name=\"default\" />"); out.println("</queuePlacementPolicy>"); out.println("</allocations>"); out.close(); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); FSLeafQueue user1Leaf = scheduler.assignToQueue(rmApp1, "root.default", "user1"); assertEquals("root.user1group.user1", user1Leaf.getName()); }
RMApp app = new MockRMApp(0, now - 20000, RMAppState.KILLED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(1, now - 200000, RMAppState.FAILED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(2, now - 30000, RMAppState.FINISHED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(3, now - 20000, RMAppState.RUNNING); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(4, now - 20000, RMAppState.NEW); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(5, now - 10001, RMAppState.KILLED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(6, now - 30000, RMAppState.ACCEPTED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(7, now - 20000, RMAppState.SUBMITTED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(8, now - 10001, RMAppState.FAILED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(9, now - 20000, RMAppState.FAILED); rmContext.getRMApps().put(app.getApplicationId(), app);
RMApp app = new MockRMApp(0, now - 20000, RMAppState.KILLED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(1, now - 200000, RMAppState.FAILED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(2, now - 30000, RMAppState.FINISHED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(3, now - 20000, RMAppState.RUNNING); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(4, now - 20000, RMAppState.NEW); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(5, now - 10001, RMAppState.KILLED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(6, now - 30000, RMAppState.ACCEPTED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(7, now - 20000, RMAppState.SUBMITTED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(8, now - 10001, RMAppState.FAILED); rmContext.getRMApps().put(app.getApplicationId(), app); app = new MockRMApp(9, now - 20000, RMAppState.FAILED); rmContext.getRMApps().put(app.getApplicationId(), app);
@Test public void testAssignToNonLeafQueueReturnsNull() throws Exception { conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true"); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); scheduler.getQueueManager().getLeafQueue("root.child1.granchild", true); scheduler.getQueueManager().getLeafQueue("root.child2", true); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW); // Trying to assign to non leaf queue would return null assertNull(scheduler.assignToQueue(rmApp1, "root.child1", "tintin")); assertNotNull(scheduler.assignToQueue(rmApp2, "root.child2", "snowy")); }
@Test public void testAssignToNonLeafQueueReturnsNull() throws Exception { conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true"); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); scheduler.getQueueManager().getLeafQueue("root.child1.granchild", true); scheduler.getQueueManager().getLeafQueue("root.child2", true); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW); // Trying to assign to non leaf queue would return null assertNull(scheduler.assignToQueue(rmApp1, "root.child1", "tintin")); assertNotNull(scheduler.assignToQueue(rmApp2, "root.child2", "snowy")); }
@Test public void testAssignToQueue() throws Exception { conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true"); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW); FSLeafQueue queue1 = scheduler.assignToQueue(rmApp1, "default", "asterix"); FSLeafQueue queue2 = scheduler.assignToQueue(rmApp2, "notdefault", "obelix"); // assert FSLeafQueue's name is the correct name is the one set in the RMApp assertEquals(rmApp1.getQueue(), queue1.getName()); assertEquals("root.asterix", rmApp1.getQueue()); assertEquals(rmApp2.getQueue(), queue2.getName()); assertEquals("root.notdefault", rmApp2.getQueue()); }
@Test public void testAssignToQueue() throws Exception { conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true"); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW); RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW); FSLeafQueue queue1 = scheduler.assignToQueue(rmApp1, "default", "asterix"); FSLeafQueue queue2 = scheduler.assignToQueue(rmApp2, "notdefault", "obelix"); // assert FSLeafQueue's name is the correct name is the one set in the RMApp assertEquals(rmApp1.getQueue(), queue1.getName()); assertEquals("root.asterix", rmApp1.getQueue()); assertEquals(rmApp2.getQueue(), queue2.getName()); assertEquals("root.notdefault", rmApp2.getQueue()); }
new MockRMApp(125, System.currentTimeMillis(), RMAppState.NEW); SchedulerApplication<FiCaSchedulerApp> application = new SchedulerApplication<FiCaSchedulerApp>(null, mockAPp.getUser());
allApps.put(app1, new MockRMApp(123, 1000, RMAppState.NEW, "userA", ImmutableSet.of(""))); allApps.put(app2, new MockRMApp(124, 1001, RMAppState.NEW, "userA", ImmutableSet.of(""))); allApps.put(app3, new MockRMApp(125, 1002, RMAppState.NEW, "userA", ImmutableSet.of(""))); Mockito.when(mockContext.getRMApps()).thenReturn(allApps);