|
@@ -22,7 +22,6 @@ import org.apache.hadoop.classification.VisibleForTesting;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AbstractLeafQueue;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueueUtils;
|
|
@@ -42,8 +41,6 @@ import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.Iterator;
|
|
@@ -253,33 +250,6 @@ public class GuaranteedOrZeroCapacityOverTimePolicy
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Comparator that orders applications by their submit time
|
|
|
- */
|
|
|
- private class PendingApplicationComparator
|
|
|
- implements Comparator<FiCaSchedulerApp> {
|
|
|
-
|
|
|
- @Override
|
|
|
- public int compare(FiCaSchedulerApp app1, FiCaSchedulerApp app2) {
|
|
|
- RMApp rmApp1 = managedParentQueue.getQueueContext().getRMApp(
|
|
|
- app1.getApplicationId());
|
|
|
- RMApp rmApp2 = managedParentQueue.getQueueContext().getRMApp(
|
|
|
- app2.getApplicationId());
|
|
|
- if (rmApp1 != null && rmApp2 != null) {
|
|
|
- return Long.compare(rmApp1.getSubmitTime(), rmApp2.getSubmitTime());
|
|
|
- } else if (rmApp1 != null) {
|
|
|
- return -1;
|
|
|
- } else if (rmApp2 != null) {
|
|
|
- return 1;
|
|
|
- } else{
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private PendingApplicationComparator applicationComparator =
|
|
|
- new PendingApplicationComparator();
|
|
|
-
|
|
|
@Override
|
|
|
public void init(final ParentQueue parentQueue) throws IOException {
|
|
|
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
|
@@ -809,7 +779,7 @@ public class GuaranteedOrZeroCapacityOverTimePolicy
|
|
|
private List<FiCaSchedulerApp> getSortedPendingApplications() {
|
|
|
List<FiCaSchedulerApp> apps = new ArrayList<>(
|
|
|
managedParentQueue.getAllApplications());
|
|
|
- Collections.sort(apps, applicationComparator);
|
|
|
+ apps.sort(managedParentQueue.getQueueContext().getApplicationComparator());
|
|
|
return apps;
|
|
|
}
|
|
|
|