@Override public String getName() { return getApplicationId().toString(); }
@Override public String getName() { return getApplicationId().toString(); }
@Override public String getName() { return getApplicationId().toString(); }
void addApp(FSAppAttempt app, boolean runnable) { writeLock.lock(); try { if (runnable) { runnableApps.add(app); } else { nonRunnableApps.add(app); } // when an appAttempt is created for an application, we'd like to move // it over from assignedApps to either runnableApps or nonRunnableApps assignedApps.remove(app.getApplicationId()); incUsedResource(app.getResourceUsage()); } finally { writeLock.unlock(); } }
private synchronized void unreserveInternal( Priority priority, FSSchedulerNode node) { Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(priority); RMContainer reservedContainer = reservedContainers.remove(node.getNodeID()); if (reservedContainers.isEmpty()) { this.reservedContainers.remove(priority); } // Reset the re-reservation count resetReReservations(priority); Resource resource = reservedContainer.getContainer().getResource(); Resources.subtractFrom(currentReservation, resource); LOG.info("Application " + getApplicationId() + " unreserved " + " on node " + node + ", currently has " + reservedContainers.size() + " at priority " + priority + "; currentReservation " + currentReservation); }
private synchronized void unreserveInternal( Priority priority, FSSchedulerNode node) { Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(priority); RMContainer reservedContainer = reservedContainers.remove(node.getNodeID()); if (reservedContainers.isEmpty()) { this.reservedContainers.remove(priority); } // Reset the re-reservation count resetReReservations(priority); Resource resource = reservedContainer.getContainer().getResource(); Resources.subtractFrom(currentReservation, resource); LOG.info("Application " + getApplicationId() + " unreserved " + " on node " + node + ", currently has " + reservedContainers.size() + " at priority " + priority + "; currentReservation " + currentReservation); }
private void unreserveInternal( SchedulerRequestKey schedulerKey, FSSchedulerNode node) { try { writeLock.lock(); Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get( schedulerKey); RMContainer reservedContainer = reservedContainers.remove( node.getNodeID()); if (reservedContainers.isEmpty()) { this.reservedContainers.remove(schedulerKey); } // Reset the re-reservation count resetReReservations(schedulerKey); Resource resource = reservedContainer.getContainer().getResource(); this.attemptResourceUsage.decReserved(resource); LOG.info( "Application " + getApplicationId() + " unreserved " + " on node " + node + ", currently has " + reservedContainers.size() + " at priority " + schedulerKey.getPriority() + "; currentReservation " + this.attemptResourceUsage .getReserved()); } finally { writeLock.unlock(); } }
private boolean reservationExceedsThreshold(FSSchedulerNode node, NodeType type) { // Only if not node-local if (type != NodeType.NODE_LOCAL) { int existingReservations = getNumReservations(node.getRackName(), type == NodeType.OFF_SWITCH); int totalAvailNodes = (type == NodeType.OFF_SWITCH) ? scheduler.getNumClusterNodes() : scheduler.getNumNodesInRack(node.getRackName()); int numAllowedReservations = (int)Math.ceil( totalAvailNodes * scheduler.getReservableNodesRatio()); if (existingReservations >= numAllowedReservations) { DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2); if (LOG.isDebugEnabled()) { LOG.debug("Reservation Exceeds Allowed number of nodes:" + " app_id=" + getApplicationId() + " existingReservations=" + existingReservations + " totalAvailableNodes=" + totalAvailNodes + " reservableNodesRatio=" + df.format( scheduler.getReservableNodesRatio()) + " numAllowedReservations=" + numAllowedReservations); } return true; } } return false; }
boolean canContainerBePreempted(RMContainer container, Resource alreadyConsideringForPreemption) { if (!isPreemptable()) { return false; } // Sanity check that the app owns this container if (!getLiveContainersMap().containsKey(container.getContainerId()) && !newlyAllocatedContainers.contains(container)) { LOG.error("Looking to preempt container " + container + ". Container does not belong to app " + getApplicationId()); return false; } synchronized (preemptionVariablesLock) { if (containersToBePreempted.contains(container)) { // The container is already under consideration for preemption return false; } } // Check if the app's allocation will be over its fairshare even // after preempting this container Resource usageAfterPreemption = getUsageAfterPreemptingContainer( container.getAllocatedResource(), alreadyConsideringForPreemption); return !isUsageBelowShare(usageAfterPreemption, getFairShare()); }
public int compare(FSAppAttempt a1, FSAppAttempt a2) { int res = a1.getPriority().compareTo(a2.getPriority()); if (res == 0) { if (a1.getStartTime() < a2.getStartTime()) { res = -1; } else { res = (a1.getStartTime() == a2.getStartTime() ? 0 : 1); } } if (res == 0) { // If there is a tie, break it by app ID to get a deterministic order res = a1.getApplicationId().compareTo(a2.getApplicationId()); } return res; } }
public int compare(FSAppAttempt a1, FSAppAttempt a2) { int res = a1.getPriority().compareTo(a2.getPriority()); if (res == 0) { if (a1.getStartTime() < a2.getStartTime()) { res = -1; } else { res = (a1.getStartTime() == a2.getStartTime() ? 0 : 1); } } if (res == 0) { // If there is a tie, break it by app ID to get a deterministic order res = a1.getApplicationId().compareTo(a2.getApplicationId()); } return res; } }
public int compare(FSAppAttempt a1, FSAppAttempt a2) { int res = a1.getPriority().compareTo(a2.getPriority()); if (res == 0) { if (a1.getStartTime() < a2.getStartTime()) { res = -1; } else { res = (a1.getStartTime() == a2.getStartTime() ? 0 : 1); } } if (res == 0) { // If there is a tie, break it by app ID to get a deterministic order res = a1.getApplicationId().compareTo(a2.getApplicationId()); } return res; } }
"SchedulerApp", getApplicationId(), containerId, containerResource);
/** * Reserve a spot for {@code container} on this {@code node}. If * the container is {@code alreadyReserved} on the node, simply * update relevant bookeeping. This dispatches ro relevant handlers * in {@link FSSchedulerNode}.. */ private void reserve(Priority priority, FSSchedulerNode node, Container container, boolean alreadyReserved) { LOG.info("Making reservation: node=" + node.getNodeName() + " app_id=" + getApplicationId()); if (!alreadyReserved) { getMetrics().reserveResource(getUser(), container.getResource()); RMContainer rmContainer = super.reserve(node, priority, null, container); node.reserveResource(this, priority, rmContainer); } else { RMContainer rmContainer = node.getReservedContainer(); super.reserve(node, priority, rmContainer, container); node.reserveResource(this, priority, rmContainer); } }
/** * Reserve a spot for {@code container} on this {@code node}. If * the container is {@code alreadyReserved} on the node, simply * update relevant bookeeping. This dispatches ro relevant handlers * in {@link FSSchedulerNode}.. */ private void reserve(Priority priority, FSSchedulerNode node, Container container, boolean alreadyReserved) { LOG.info("Making reservation: node=" + node.getNodeName() + " app_id=" + getApplicationId()); if (!alreadyReserved) { getMetrics().reserveResource(getUser(), container.getResource()); RMContainer rmContainer = super.reserve(node, priority, null, container); node.reserveResource(this, priority, rmContainer); } else { RMContainer rmContainer = node.getReservedContainer(); super.reserve(node, priority, rmContainer, container); node.reserveResource(this, priority, rmContainer); } }
if (wasRunnable && !nowRunnable) { throw new IllegalStateException("Should have already verified that app " + attempt.getApplicationId() + " would be runnable in new queue");
if (wasRunnable && !nowRunnable) { throw new IllegalStateException("Should have already verified that app " + attempt.getApplicationId() + " would be runnable in new queue");
if (reservableForThisApp &&!reservationExceedsThreshold(node, type)) { LOG.info("Making reservation: node=" + node.getNodeName() + " app_id=" + getApplicationId()); if (reservedContainer == null) { reservedContainer =