YARN-3547. FairScheduler: Apps that have no resource demand should not participate scheduling. (Xianyin Xin via kasha)

This commit is contained in:
Karthik Kambatla 2015-05-29 15:17:02 -07:00
parent 7673d4f205
commit 3ae2a62501
2 changed files with 24 additions and 22 deletions

View File

@ -291,6 +291,9 @@ Release 2.8.0 - UNRELEASED
YARN-3006. Improve the error message when attempting manual failover with YARN-3006. Improve the error message when attempting manual failover with
auto-failover enabled. (Akira AJISAKA via wangda) auto-failover enabled. (Akira AJISAKA via wangda)
YARN-3547. FairScheduler: Apps that have no resource demand should not participate
scheduling. (Xianyin Xin via kasha)
BUG FIXES BUG FIXES
YARN-3197. Confusing log generated by CapacityScheduler. (Varun Saxena YARN-3197. Confusing log generated by CapacityScheduler. (Varun Saxena

View File

@ -26,6 +26,7 @@ import java.util.List;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.TreeSet;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -314,35 +315,33 @@ public class FSLeafQueue extends FSQueue {
return assigned; return assigned;
} }
Comparator<Schedulable> comparator = policy.getComparator(); // Apps that have resource demands.
writeLock.lock(); TreeSet<FSAppAttempt> pendingForResourceApps =
try { new TreeSet<FSAppAttempt>(policy.getComparator());
Collections.sort(runnableApps, comparator);
} finally {
writeLock.unlock();
}
// Release write lock here for better performance and avoiding deadlocks.
// runnableApps can be in unsorted state because of this section,
// but we can accept it in practice since the probability is low.
readLock.lock(); readLock.lock();
try { try {
for (FSAppAttempt sched : runnableApps) { for (FSAppAttempt app : runnableApps) {
if (SchedulerAppUtils.isBlacklisted(sched, node, LOG)) { Resource pending = app.getAppAttemptResourceUsage().getPending();
continue; if (!pending.equals(Resources.none())) {
} pendingForResourceApps.add(app);
assigned = sched.assignContainer(node);
if (!assigned.equals(Resources.none())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Assigned container in queue:" + getName() + " " +
"container:" + assigned);
}
break;
} }
} }
} finally { } finally {
readLock.unlock(); readLock.unlock();
} }
for (FSAppAttempt sched : pendingForResourceApps) {
if (SchedulerAppUtils.isBlacklisted(sched, node, LOG)) {
continue;
}
assigned = sched.assignContainer(node);
if (!assigned.equals(Resources.none())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Assigned container in queue:" + getName() + " " +
"container:" + assigned);
}
break;
}
}
return assigned; return assigned;
} }