FairOrderingPolicy extends AbstractComparatorOrderingPolicy<S> { @Override public void containerAllocated(S schedulableEntity, RMContainer r) { entityRequiresReordering(schedulableEntity); } 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 testIterators() { OrderingPolicy<MockSchedulableEntity> schedOrder = new FairOrderingPolicy<MockSchedulableEntity>(); MockSchedulableEntity msp1 = new MockSchedulableEntity(); MockSchedulableEntity msp2 = new MockSchedulableEntity(); MockSchedulableEntity msp3 = new MockSchedulableEntity(); msp1.setId("1"); msp2.setId("2"); msp3.setId("3"); msp1.setUsed(Resources.createResource(3)); msp2.setUsed(Resources.createResource(2)); msp3.setUsed(Resources.createResource(1)); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( msp1.getSchedulingResourceUsage()); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( msp2.getSchedulingResourceUsage()); AbstractComparatorOrderingPolicy.updateSchedulingResourceUsage( msp2.getSchedulingResourceUsage()); schedOrder.addSchedulableEntity(msp1); schedOrder.addSchedulableEntity(msp2); schedOrder.addSchedulableEntity(msp3); checkIds(schedOrder.getAssignmentIterator( IteratorSelector.EMPTY_ITERATOR_SELECTOR), new String[]{"3", "2", "1"}); checkIds(schedOrder.getPreemptionIterator(), new String[]{"1", "2", "3"}); msp2.setUsed(Resources.createResource(6)); checkIds(schedOrder.getAssignmentIterator( IteratorSelector.EMPTY_ITERATOR_SELECTOR), new String[]{"3", "2", "1"}); checkIds(schedOrder.getPreemptionIterator(), new String[]{"1", "2", "3"}); schedOrder.containerAllocated(msp2, null); checkIds(schedOrder.getAssignmentIterator( IteratorSelector.EMPTY_ITERATOR_SELECTOR), new String[]{"3", "1", "2"}); checkIds(schedOrder.getPreemptionIterator(), new String[]{"2", "1", "3"}); }