|
@@ -28,6 +28,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import com.google.common.annotations.VisibleForTesting;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
@@ -99,6 +100,9 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
|
|
|
private final Map<String, Set<String>> reservations = new HashMap<>();
|
|
|
|
|
|
private final List<FSSchedulerNode> blacklistNodeIds = new ArrayList<>();
|
|
|
+
|
|
|
+ private boolean enableAMPreemption;
|
|
|
+
|
|
|
/**
|
|
|
* Delay scheduling: We often want to prioritize scheduling of node-local
|
|
|
* containers over rack-local or off-switch containers. To achieve this
|
|
@@ -121,6 +125,8 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
|
|
|
this.startTime = scheduler.getClock().getTime();
|
|
|
this.lastTimeAtFairShare = this.startTime;
|
|
|
this.appPriority = Priority.newInstance(1);
|
|
|
+ this.enableAMPreemption = scheduler.getConf()
|
|
|
+ .getAMPreemptionEnabled(getQueue().getQueueName());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -589,6 +595,10 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if (container.isAMContainer() && !enableAMPreemption) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
// Sanity check that the app owns this container
|
|
|
if (!getLiveContainersMap().containsKey(container.getContainerId()) &&
|
|
|
!newlyAllocatedContainers.contains(container)) {
|
|
@@ -1416,4 +1426,9 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
|
|
|
public boolean isPreemptable() {
|
|
|
return getQueue().isPreemptable();
|
|
|
}
|
|
|
+
|
|
|
+ @VisibleForTesting
|
|
|
+ public void setEnableAMPreemption(boolean enableAMPreemption) {
|
|
|
+ this.enableAMPreemption = enableAMPreemption;
|
|
|
+ }
|
|
|
}
|