@Test public void testContainerOrdering(){ List<RMContainer> containers = new ArrayList<RMContainer>(); ApplicationAttemptId appAttId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(TS, 10), 0); RMContainer rm1 = mockContainer(appAttId, 5, mock(Resource.class), 3); RMContainer rm2 = mockContainer(appAttId, 3, mock(Resource.class), 3); RMContainer rm3 = mockContainer(appAttId, 2, mock(Resource.class), 2); RMContainer rm4 = mockContainer(appAttId, 1, mock(Resource.class), 2); RMContainer rm5 = mockContainer(appAttId, 4, mock(Resource.class), 1); containers.add(rm3); containers.add(rm2); containers.add(rm1); containers.add(rm5); containers.add(rm4); ProportionalCapacityPreemptionPolicy.sortContainers(containers); assert containers.get(0).equals(rm1); assert containers.get(1).equals(rm2); assert containers.get(2).equals(rm3); assert containers.get(3).equals(rm4); assert containers.get(4).equals(rm5); }
@VisibleForTesting static void sortContainers(List<RMContainer> containers){ Collections.sort(containers, new Comparator<RMContainer>() { @Override public int compare(RMContainer a, RMContainer b) { Comparator<Priority> c = new org.apache.hadoop.yarn.server .resourcemanager.resource.Priority.Comparator(); int priorityComp = c.compare(b.getContainer().getPriority(), a.getContainer().getPriority()); if (priorityComp != 0) { return priorityComp; } return b.getContainerId().compareTo(a.getContainerId()); } }); }
ProportionalCapacityPreemptionPolicy implements SchedulingEditPolicy { @VisibleForTesting static void sortContainers(List<RMContainer> containers){ Collections.sort(containers, new Comparator<RMContainer>() { @Override public int compare(RMContainer a, RMContainer b) { Comparator<Priority> c = new org.apache.hadoop.yarn.server .resourcemanager.resource.Priority.Comparator(); int priorityComp = c.compare(b.getContainer().getPriority(), a.getContainer().getPriority()); if (priorityComp != 0) { return priorityComp; } return b.getContainerId().compareTo(a.getContainerId()); } }); } }
ProportionalCapacityPreemptionPolicy implements SchedulingEditPolicy { @VisibleForTesting static void sortContainers(List<RMContainer> containers){ Collections.sort(containers, new Comparator<RMContainer>() { @Override public int compare(RMContainer a, RMContainer b) { Comparator<Priority> c = new org.apache.hadoop.yarn.server .resourcemanager.resource.Priority.Comparator(); int priorityComp = c.compare(b.getContainer().getPriority(), a.getContainer().getPriority()); if (priorityComp != 0) { return priorityComp; } return b.getContainerId().compareTo(a.getContainerId()); } }); } ProportionalCapacityPreemptionPolicy();  ProportionalCapacityPreemptionPolicy(Configuration config,
      EventHandler<ContainerPreemptEvent> dispatcher,
      CapacityScheduler scheduler);  ProportionalCapacityPreemptionPolicy(Configuration config,
      EventHandler<ContainerPreemptEvent> dispatcher,
      CapacityScheduler scheduler, Clock clock); }
ProportionalCapacityPreemptionPolicy implements SchedulingEditPolicy { @VisibleForTesting static void sortContainers(List<RMContainer> containers){ Collections.sort(containers, new Comparator<RMContainer>() { @Override public int compare(RMContainer a, RMContainer b) { Comparator<Priority> c = new org.apache.hadoop.yarn.server .resourcemanager.resource.Priority.Comparator(); int priorityComp = c.compare(b.getContainer().getPriority(), a.getContainer().getPriority()); if (priorityComp != 0) { return priorityComp; } return b.getContainerId().compareTo(a.getContainerId()); } }); } ProportionalCapacityPreemptionPolicy();  ProportionalCapacityPreemptionPolicy(Configuration config,
      EventHandler<ContainerPreemptEvent> dispatcher,
      CapacityScheduler scheduler);  ProportionalCapacityPreemptionPolicy(Configuration config,
      EventHandler<ContainerPreemptEvent> dispatcher,
      CapacityScheduler scheduler, Clock clock); void init(Configuration config,
      EventHandler<ContainerPreemptEvent> disp,
      PreemptableResourceScheduler sched); @VisibleForTesting ResourceCalculator getResourceCalculator(); @Override void editSchedule(); void setNodeLabels(Map<NodeId, Set<String>> nodelabels); @Override long getMonitoringInterval(); @Override String getPolicyName(); }
ProportionalCapacityPreemptionPolicy implements SchedulingEditPolicy { @VisibleForTesting static void sortContainers(List<RMContainer> containers){ Collections.sort(containers, new Comparator<RMContainer>() { @Override public int compare(RMContainer a, RMContainer b) { Comparator<Priority> c = new org.apache.hadoop.yarn.server .resourcemanager.resource.Priority.Comparator(); int priorityComp = c.compare(b.getContainer().getPriority(), a.getContainer().getPriority()); if (priorityComp != 0) { return priorityComp; } return b.getContainerId().compareTo(a.getContainerId()); } }); } ProportionalCapacityPreemptionPolicy();  ProportionalCapacityPreemptionPolicy(Configuration config,
      EventHandler<ContainerPreemptEvent> dispatcher,
      CapacityScheduler scheduler);  ProportionalCapacityPreemptionPolicy(Configuration config,
      EventHandler<ContainerPreemptEvent> dispatcher,
      CapacityScheduler scheduler, Clock clock); void init(Configuration config,
      EventHandler<ContainerPreemptEvent> disp,
      PreemptableResourceScheduler sched); @VisibleForTesting ResourceCalculator getResourceCalculator(); @Override void editSchedule(); void setNodeLabels(Map<NodeId, Set<String>> nodelabels); @Override long getMonitoringInterval(); @Override String getPolicyName(); static final String OBSERVE_ONLY; static final String MONITORING_INTERVAL; static final String WAIT_TIME_BEFORE_KILL; static final String TOTAL_PREEMPTION_PER_ROUND; static final String MAX_IGNORED_OVER_CAPACITY; static final String NATURAL_TERMINATION_FACTOR; public EventHandler<ContainerPreemptEvent> dispatcher; }