FairOrderingPolicy extends AbstractComparatorOrderingPolicy<S> { @VisibleForTesting public boolean getSizeBasedWeight() { return sizeBasedWeight; } FairOrderingPolicy(); @VisibleForTesting boolean getSizeBasedWeight(); @VisibleForTesting void setSizeBasedWeight(boolean sizeBasedWeight); @Override void configure(Map<String, String> conf); @Override void containerAllocated(S schedulableEntity,
    RMContainer r); @Override void containerReleased(S schedulableEntity,
    RMContainer r); @Override void demandUpdated(S schedulableEntity); @Override String getInfo(); static final String ENABLE_SIZE_BASED_WEIGHT; }
@Test public void testSizeBasedWeightNotAffectAppActivation() throws Exception { CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); String queuePath = CapacitySchedulerConfiguration.ROOT + ".default"; csConf.set(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class.getCanonicalName()); csConf.setOrderingPolicy(queuePath, CapacitySchedulerConfiguration.FAIR_APP_ORDERING_POLICY); csConf.setOrderingPolicyParameter(queuePath, FairOrderingPolicy.ENABLE_SIZE_BASED_WEIGHT, "true"); csConf.setMaximumApplicationMasterResourcePerQueuePercent(queuePath, 0.1f); MockRM rm = new MockRM(csConf); rm.start(); CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler(); LeafQueue lq = (LeafQueue) cs.getQueue("default"); OrderingPolicy<FiCaSchedulerApp> policy = lq.getOrderingPolicy(); Assert.assertTrue(policy instanceof FairOrderingPolicy); Assert.assertTrue(((FairOrderingPolicy<FiCaSchedulerApp>)policy).getSizeBasedWeight()); rm.registerNode("h1:1234", 10 * GB); rm.submitApp(1 * GB, "app", "user", null, "default"); rm.submitApp(1 * GB, "app", "user", null, "default"); rm.submitApp(1 * GB, "app", "user", null, "default"); rm.submitApp(1 * GB, "app", "user", null, "default"); Assert.assertEquals(1, lq.getNumActiveApplications()); Assert.assertEquals(3, lq.getNumPendingApplications()); cs.handle(new NodeUpdateSchedulerEvent( rm.getRMContext().getRMNodes().get(NodeId.newInstance("h1", 1234)))); Assert.assertEquals(1, lq.getNumActiveApplications()); Assert.assertEquals(3, lq.getNumPendingApplications()); }