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(); @Override String getConfigName(); 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); MockRMAppSubmissionData data3 = MockRMAppSubmissionData.Builder.createWithMemory(1 * GB, rm) .withAppName("app") .withUser("user") .withAcls(null) .withQueue("default") .withUnmanagedAM(false) .build(); MockRMAppSubmitter.submit(rm, data3); MockRMAppSubmissionData data2 = MockRMAppSubmissionData.Builder.createWithMemory(1 * GB, rm) .withAppName("app") .withUser("user") .withAcls(null) .withQueue("default") .withUnmanagedAM(false) .build(); MockRMAppSubmitter.submit(rm, data2); MockRMAppSubmissionData data1 = MockRMAppSubmissionData.Builder.createWithMemory(1 * GB, rm) .withAppName("app") .withUser("user") .withAcls(null) .withQueue("default") .withUnmanagedAM(false) .build(); MockRMAppSubmitter.submit(rm, data1); MockRMAppSubmissionData data = MockRMAppSubmissionData.Builder.createWithMemory(1 * GB, rm) .withAppName("app") .withUser("user") .withAcls(null) .withQueue("default") .withUnmanagedAM(false) .build(); MockRMAppSubmitter.submit(rm, data); 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()); }