Source:
<code>private Resource assignContainer( FSSchedulerNode node, PendingAsk pendingAsk, NodeType type, boolean reserved, SchedulerRequestKey schedulerKey) { Resource capability = pendingAsk.getPerAllocationResource(); Resource available = node.getUnallocatedResource(); Container reservedContainer = null; if (reserved) { reservedContainer = node.getReservedContainer().getContainer(); } if (Resources.fitsIn(capability, available)) { RMContainer allocatedContainer = allocate(type, node, schedulerKey, pendingAsk, reservedContainer); if (allocatedContainer == null) { if (reserved) { unreserve(schedulerKey, node); } return Resources.none(); } if (reserved) { unreserve(schedulerKey, node); } node.allocateContainer(allocatedContainer); if (!isAmRunning() && !getUnmanagedAM()) { setAMResource(capability); getQueue().addAMResourceUsage(capability); setAmRunning(true); } return capability; } <START> if (!scheduler.getConf().getPreemptionEnabled() && <END> isReservable(capability) && reserve(pendingAsk.getPerAllocationResource(), node, reservedContainer, type, schedulerKey)) { if (isWaitingForAMContainer()) { updateAMDiagnosticMsg(capability, " exceed the available resources of the node and the request is" + " reserved"); } return FairScheduler.CONTAINER_RESERVED; } else { if (isWaitingForAMContainer()) { updateAMDiagnosticMsg(capability, " exceed the available resources of the node and the request cannot" + " be reserved"); } if (LOG.isDebugEnabled()) { LOG.debug("Couldn't creating reservation for " + getName() + ",at priority " + schedulerKey.getPriority()); } return Resources.none(); } }</code><technical_language>This bad. if preemption is enabled, containers preempted. However, if apps requesting large containers fit in free resources created smaller containers finishing, apps end starved forever</technical_language>

Target:
private Resource assignContainer( FSSchedulerNode node, PendingAsk pendingAsk, NodeType type, boolean reserved, SchedulerRequestKey schedulerKey) { Resource capability = pendingAsk.getPerAllocationResource(); Resource available = node.getUnallocatedResource(); Container reservedContainer = null; if (reserved) { reservedContainer = node.getReservedContainer().getContainer(); } if (Resources.fitsIn(capability, available)) { RMContainer allocatedContainer = allocate(type, node, schedulerKey, pendingAsk, reservedContainer); if (allocatedContainer == null) { if (reserved) { unreserve(schedulerKey, node); } return Resources.none(); } if (reserved) { unreserve(schedulerKey, node); } node.allocateContainer(allocatedContainer); if (!isAmRunning() && !getUnmanagedAM()) { setAMResource(capability); getQueue().addAMResourceUsage(capability); setAmRunning(true); } return capability; } if (LOG.isDebugEnabled()) { LOG.debug("Resource request: " + capability + " exceeds the available" + " resources of the node."); } if (isReservable(capability) && reserve(pendingAsk.getPerAllocationResource(), node, reservedContainer, type, schedulerKey)) { updateAMDiagnosticMsg(capability, " exceeds the available resources of " + "the node and the request is reserved)"); if (LOG.isDebugEnabled()) { LOG.debug(getName() + "'s resource request is reserved."); } return FairScheduler.CONTAINER_RESERVED; } else { updateAMDiagnosticMsg(capability, " exceeds the available resources of " + "the node and the request cannot be reserved)"); if (LOG.isDebugEnabled()) { LOG.debug("Couldn't create reservation for app: " + getName() + ", at priority " + schedulerKey.getPriority()); } return Resources.none(); } }