FairOrderingPolicy extends AbstractComparatorOrderingPolicy<S> { @VisibleForTesting public void setSizeBasedWeight(boolean sizeBasedWeight) { this.sizeBasedWeight = 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 testSizeBasedWeight() { FairOrderingPolicy<MockSchedulableEntity> policy = new FairOrderingPolicy<MockSchedulableEntity>(); policy.setSizeBasedWeight(true); MockSchedulableEntity r1 = new MockSchedulableEntity(); MockSchedulableEntity r2 = new MockSchedulableEntity(); Assert.assertTrue(policy.getComparator().compare(r1, r2) == 0); r1.setUsed(Resources.createResource(4 * GB)); r2.setUsed(Resources.createResource(4 * GB)); r1.setPending(Resources.createResource(4 * GB)); r2.setPending(Resources.createResource(4 * GB)); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( r1.getSchedulingResourceUsage()); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( r2.getSchedulingResourceUsage()); Assert.assertTrue(policy.getComparator().compare(r1, r2) == 0); r2.setUsed(Resources.createResource(5 * GB)); r2.setPending(Resources.createResource(5 * GB)); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( r2.getSchedulingResourceUsage()); Assert.assertTrue(policy.getComparator().compare(r1, r2) < 0); r2.setPending(Resources.createResource(100 * GB)); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( r2.getSchedulingResourceUsage()); Assert.assertTrue(policy.getComparator().compare(r1, r2) > 0); }