public FairScheduler() { super(FairScheduler.class.getName()); context = new FSContext(this); allocsLoader = new AllocationFileLoaderService(); queueMgr = new QueueManager(this); maxRunningEnforcer = new MaxRunningAppsEnforcer(this); }
boolean wasRunnable = oldQueue.removeApp(attempt); boolean nowRunnable = maxRunningEnforcer.canAppBeRunnable(newQueue, attempt.getUser()); if (wasRunnable && !nowRunnable) { maxRunningEnforcer.untrackRunnableApp(attempt); } else if (nowRunnable) { maxRunningEnforcer.untrackNonRunnableApp(attempt); maxRunningEnforcer.trackRunnableApp(attempt); maxRunningEnforcer.updateRunnabilityOnAppRemoval(attempt, oldQueue);
/** * This is called after reloading the allocation configuration when the * scheduler is reinitilized * * Checks to see whether any non-runnable applications become runnable * now that the max running apps of given queue has been changed * * Runs in O(n) where n is the number of apps that are non-runnable and in * the queues that went from having no slack to having slack. */ public void updateRunnabilityOnReload() { FSParentQueue rootQueue = scheduler.getQueueManager().getRootQueue(); List<List<FSAppAttempt>> appsNowMaybeRunnable = new ArrayList<List<FSAppAttempt>>(); gatherPossiblyRunnableAppLists(rootQueue, appsNowMaybeRunnable); updateAppsRunnability(appsNowMaybeRunnable, Integer.MAX_VALUE); }
private FSAppAttempt addApp(FSLeafQueue queue, String user) { ApplicationId appId = ApplicationId.newInstance(0l, appNum++); ApplicationAttemptId attId = ApplicationAttemptId.newInstance(appId, 0); FSAppAttempt app = new FSAppAttempt(scheduler, attId, user, queue, null, rmContext); boolean runnable = maxAppsEnforcer.canAppBeRunnable(queue, app); queue.addApp(app, runnable); if (runnable) { maxAppsEnforcer.trackRunnableApp(app); } else { maxAppsEnforcer.trackNonRunnableApp(app); } return app; }
maxRunningEnforcer.untrackRunnableApp(attempt); maxRunningEnforcer.updateRunnabilityOnAppRemoval(attempt, attempt.getQueue()); } else{ maxRunningEnforcer.untrackNonRunnableApp(attempt);
if (canAppBeRunnable(next.getQueue(), next)) { trackRunnableApp(next); FSAppAttempt appSched = next; next.getQueue().addApp(appSched, true);
private void removeApp(FSAppAttempt app) { app.getQueue().removeApp(app); maxAppsEnforcer.untrackRunnableApp(app); maxAppsEnforcer.updateRunnabilityOnAppRemoval(app, app.getQueue()); }
@Override public void onReload(AllocationConfiguration queueInfo) { // Commit the reload; also create any queue defined in the alloc file // if it does not already exist, so it can be displayed on the web UI. synchronized (FairScheduler.this) { allocConf = queueInfo; allocConf.getDefaultSchedulingPolicy().initialize(clusterResource); queueMgr.updateAllocationConfiguration(allocConf); maxRunningEnforcer.updateRunnabilityOnReload(); } } }
/** * Traverses the queue hierarchy under the given queue to gather all lists * of non-runnable applications. */ private void gatherPossiblyRunnableAppLists(FSQueue queue, List<List<FSAppAttempt>> appLists) { if (queue.getNumRunnableApps() < queue.getMaxRunningApps()) { if (queue instanceof FSLeafQueue) { appLists.add( ((FSLeafQueue)queue).getCopyOfNonRunnableAppSchedulables()); } else { for (FSQueue child : queue.getChildQueues()) { gatherPossiblyRunnableAppLists(child, appLists); } } } }
private FSAppAttempt addApp(FSLeafQueue queue, String user) { ApplicationId appId = ApplicationId.newInstance(0l, appNum++); ApplicationAttemptId attId = ApplicationAttemptId.newInstance(appId, 0); boolean runnable = maxAppsEnforcer.canAppBeRunnable(queue, user); FSAppAttempt app = new FSAppAttempt(scheduler, attId, user, queue, null, rmContext); queue.addApp(app, runnable); if (runnable) { maxAppsEnforcer.trackRunnableApp(app); } else { maxAppsEnforcer.trackNonRunnableApp(app); } return app; }
maxRunningEnforcer.untrackRunnableApp(attempt); maxRunningEnforcer.updateRunnabilityOnAppRemoval(attempt, attempt.getQueue()); } else { maxRunningEnforcer.untrackNonRunnableApp(attempt);
if (canAppBeRunnable(next.getQueue(), next.getUser())) { trackRunnableApp(next); FSAppAttempt appSched = next; next.getQueue().addApp(appSched, true);
private void removeApp(FSAppAttempt app) { app.getQueue().removeApp(app); maxAppsEnforcer.untrackRunnableApp(app); maxAppsEnforcer.updateRunnabilityOnAppRemoval(app, app.getQueue()); }
@Override public void onReload(AllocationConfiguration queueInfo) { // Commit the reload; also create any queue defined in the alloc file // if it does not already exist, so it can be displayed on the web UI. synchronized (FairScheduler.this) { allocConf = queueInfo; allocConf.getDefaultSchedulingPolicy().initialize(clusterResource); queueMgr.updateAllocationConfiguration(allocConf); maxRunningEnforcer.updateRunnabilityOnReload(); } } }
/** * Traverses the queue hierarchy under the given queue to gather all lists * of non-runnable applications. */ private void gatherPossiblyRunnableAppLists(FSQueue queue, List<List<FSAppAttempt>> appLists) { if (queue.getNumRunnableApps() < scheduler.getAllocationConfiguration() .getQueueMaxApps(queue.getName())) { if (queue instanceof FSLeafQueue) { appLists.add( ((FSLeafQueue)queue).getCopyOfNonRunnableAppSchedulables()); } else { for (FSQueue child : queue.getChildQueues()) { gatherPossiblyRunnableAppLists(child, appLists); } } } }
boolean wasRunnable = oldQueue.removeApp(attempt); boolean nowRunnable = maxRunningEnforcer.canAppBeRunnable(newQueue, attempt.getUser()); if (wasRunnable && !nowRunnable) { maxRunningEnforcer.untrackRunnableApp(attempt); } else if (nowRunnable) { maxRunningEnforcer.untrackNonRunnableApp(attempt); maxRunningEnforcer.trackRunnableApp(attempt); maxRunningEnforcer.updateRunnabilityOnAppRemoval(attempt, oldQueue);
boolean runnable = maxRunningEnforcer.canAppBeRunnable(queue, attempt); queue.addApp(attempt, runnable); if (runnable) { maxRunningEnforcer.trackRunnableApp(attempt); } else{ maxRunningEnforcer.trackNonRunnableApp(attempt);
maxRunningEnforcer.untrackRunnableApp(attempt); maxRunningEnforcer.updateRunnabilityOnAppRemoval(attempt, attempt.getQueue()); } else { maxRunningEnforcer.untrackNonRunnableApp(attempt);
if (canAppBeRunnable(next.getQueue(), next.getUser())) { trackRunnableApp(next); FSAppAttempt appSched = next; next.getQueue().addApp(appSched, true);
/** * This is called after reloading the allocation configuration when the * scheduler is reinitilized * * Checks to see whether any non-runnable applications become runnable * now that the max running apps of given queue has been changed * * Runs in O(n) where n is the number of apps that are non-runnable and in * the queues that went from having no slack to having slack. */ public void updateRunnabilityOnReload() { FSParentQueue rootQueue = scheduler.getQueueManager().getRootQueue(); List<List<FSAppAttempt>> appsNowMaybeRunnable = new ArrayList<List<FSAppAttempt>>(); gatherPossiblyRunnableAppLists(rootQueue, appsNowMaybeRunnable); updateAppsRunnability(appsNowMaybeRunnable, Integer.MAX_VALUE); }