@Override public Integer getValue() { return app.getFairShare().getVirtualCores(); } }
@Override public Integer getValue() { return app.getFairShare().getVirtualCores(); } }
/** * Get the fair share assigned to the appAttemptId. * @param appAttemptId * @return The fair share assigned to the appAttemptId, * <code>FairSchedulerInfo#INVALID_FAIR_SHARE</code> if the scheduler does * not know about this application attempt. */ public long getAppFairShare(ApplicationAttemptId appAttemptId) { FSAppAttempt fsAppAttempt = scheduler.getSchedulerApp(appAttemptId); return fsAppAttempt == null ? INVALID_FAIR_SHARE : fsAppAttempt.getFairShare().getMemorySize(); }
/** * Get the fair share assigned to the appAttemptId. * @param appAttemptId * @return The fair share assigned to the appAttemptId, * <code>FairSchedulerInfo#INVALID_FAIR_SHARE</code> if the scheduler does * not know about this application attempt. */ public int getAppFairShare(ApplicationAttemptId appAttemptId) { FSAppAttempt fsAppAttempt = scheduler.getSchedulerApp(appAttemptId); return fsAppAttempt == null ? INVALID_FAIR_SHARE : fsAppAttempt.getFairShare().getMemory(); }
/** * Helper method that captures if this app is identified to be starved. * @return true if the app is starved for fairshare, false otherwise */ boolean isStarvedForFairShare() { return isUsageBelowShare(getResourceUsage(), getFairShare()); }
/** * Get the fair share assigned to the appAttemptId. * @param appAttemptId * @return The fair share assigned to the appAttemptId, * <code>FairSchedulerInfo#INVALID_FAIR_SHARE</code> if the scheduler does * not know about this application attempt. */ public int getAppFairShare(ApplicationAttemptId appAttemptId) { FSAppAttempt fsAppAttempt = scheduler.getSchedulerApp(appAttemptId); return fsAppAttempt == null ? INVALID_FAIR_SHARE : fsAppAttempt.getFairShare().getMemory(); }
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()); }
/** * Helper method that computes the extent of fairshare starvation. * @return freshly computed fairshare starvation */ Resource fairShareStarvation() { long now = scheduler.getClock().getTime(); Resource threshold = Resources.multiply( getFairShare(), getQueue().getFairSharePreemptionThreshold()); Resource fairDemand = Resources.componentwiseMin(threshold, demand); // Check if the queue is starved for fairshare boolean starved = isUsageBelowShare(getResourceUsage(), fairDemand); if (!starved) { lastTimeAtFairShare = now; } if (!starved || now - lastTimeAtFairShare < getQueue().getFairSharePreemptionTimeout()) { fairshareStarvation = Resources.none(); } else { // The app has been starved for longer than preemption-timeout. fairshareStarvation = Resources.subtractFromNonNegative(fairDemand, getResourceUsage()); } return fairshareStarvation; }