[ https://issues.apache.org/jira/browse/YARN-5829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15941467#comment-15941467 ]
ASF GitHub Bot commented on YARN-5829: -------------------------------------- Github user szegedim commented on a diff in the pull request: https://github.com/apache/hadoop/pull/201#discussion_r108024673 --- Diff: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSSchedulerNode.java --- @@ -38,15 +47,45 @@ public class FSSchedulerNode extends SchedulerNode { private static final Log LOG = LogFactory.getLog(FSSchedulerNode.class); + private static final Comparator<RMContainer> comparator = + new Comparator<RMContainer>() { + @Override + public int compare(RMContainer o1, RMContainer o2) { + return Long.compare(o1.getContainerId().getContainerId(), + o2.getContainerId().getContainerId()); + } + }; private FSAppAttempt reservedAppSchedulable; - private final Set<RMContainer> containersForPreemption = - new ConcurrentSkipListSet<>(); + // Stores list of containers still to be preempted + @VisibleForTesting + final Set<RMContainer> containersForPreemption = + new ConcurrentSkipListSet<>(comparator); + // Stores amount of respources preempted and reserved for each app + @VisibleForTesting + final Map<FSAppAttempt, Resource> + resourcesPreemptedForApp = new LinkedHashMap<>(); + // Sum of resourcesPreemptedForApp values, total resources that are + // slated for preemption + Resource totalResourcesPreempted = Resource.newInstance(0, 0); public FSSchedulerNode(RMNode node, boolean usePortForNodeName) { super(node, usePortForNodeName); } + /** + * Total amount of reserved resources including reservations and preempted + * containers. + * @return total resources reserved + */ + Resource getTotalReserved() { + Resource totalReserved = getReservedContainer() != null + ? Resources.clone(getReservedContainer().getAllocatedResource()) + : Resource.newInstance(0, 0); --- End diff -- Fixed. > FS preemption should reserve a node before considering containers on it for > preemption > -------------------------------------------------------------------------------------- > > Key: YARN-5829 > URL: https://issues.apache.org/jira/browse/YARN-5829 > Project: Hadoop YARN > Issue Type: Sub-task > Components: fairscheduler > Reporter: Karthik Kambatla > Assignee: Miklos Szegedi > > FS preemption evaluates nodes for preemption, and subsequently preempts > identified containers. If this node is not reserved for a specific > application, any other application could be allocated resources on this node. > Reserving the node for the starved application before preempting containers > would help avoid this. -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org