/** * Removes the given app from this queue. * @return whether or not the app was runnable */ public boolean removeApp(FSAppAttempt app) { boolean runnable = false; // Remove app from runnable/nonRunnable list while holding the write lock writeLock.lock(); try { runnable = runnableApps.remove(app); if (!runnable) { // removeNonRunnableApp acquires the write lock again, which is fine if (!removeNonRunnableApp(app)) { throw new IllegalStateException("Given app to remove " + app + " does not exist in queue " + this); } } } finally { writeLock.unlock(); } // Update AM resource usage if needed if (runnable && app.isAmRunning() && app.getAMResource() != null) { Resources.subtractFrom(amResourceUsage, app.getAMResource()); } return runnable; }
/** * Removes the given app from this queue. * @return whether or not the app was runnable */ public boolean removeApp(FSAppAttempt app) { boolean runnable = false; // Remove app from runnable/nonRunnable list while holding the write lock writeLock.lock(); try { runnable = runnableApps.remove(app); if (!runnable) { // removeNonRunnableApp acquires the write lock again, which is fine if (!removeNonRunnableApp(app)) { throw new IllegalStateException("Given app to remove " + app + " does not exist in queue " + this); } } } finally { writeLock.unlock(); } // Update AM resource usage if needed if (runnable && app.isAmRunning() && app.getAMResource() != null) { Resources.subtractFrom(amResourceUsage, app.getAMResource()); } return runnable; }
/** * Removes the given app from this queue. * @return whether or not the app was runnable */ boolean removeApp(FSAppAttempt app) { boolean runnable = false; // Remove app from runnable/nonRunnable list while holding the write lock writeLock.lock(); try { runnable = runnableApps.remove(app); if (!runnable) { // removeNonRunnableApp acquires the write lock again, which is fine if (!removeNonRunnableApp(app)) { throw new IllegalStateException("Given app to remove " + app + " does not exist in queue " + this); } } } finally { writeLock.unlock(); } // Update AM resource usage if needed. If isAMRunning is true, we're not // running an unmanaged AM. if (runnable && app.isAmRunning()) { Resources.subtractFrom(amResourceUsage, app.getAMResource()); getMetrics().setAMResourceUsage(amResourceUsage); } decUsedResource(app.getResourceUsage()); return runnable; }
/** * Whether the AM container for this app is over maxAMShare limit. */ private boolean isOverAMShareLimit() { // Check the AM resource usage for the leaf queue if (!isAmRunning() && !getUnmanagedAM()) { // Return true if we have not ask, or queue is not be able to run app's AM PendingAsk ask = appSchedulingInfo.getNextPendingAsk(); if (ask.getCount() == 0 || !getQueue().canRunAppAM( ask.getPerAllocationResource())) { return true; } } return false; }
@Override public synchronized void recoverContainer(SchedulerNode node, RMContainer rmContainer) { try { writeLock.lock(); super.recoverContainer(node, rmContainer); if (!rmContainer.getState().equals(RMContainerState.COMPLETED)) { getQueue().incUsedResource(rmContainer.getContainer().getResource()); } // If not running unmanaged, the first container we recover is always // the AM. Set the amResource for this app and update the leaf queue's AM // usage if (!isAmRunning() && !getUnmanagedAM()) { Resource resource = rmContainer.getAllocatedResource(); setAMResource(resource); getQueue().addAMResourceUsage(resource); setAmRunning(true); } } finally { writeLock.unlock(); } }
if (!isAmRunning() && !getUnmanagedAM()) { setAMResource(capability); getQueue().addAMResourceUsage(capability);