/** * 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; }
if (!getQueue().canRunAppAM(getAMResource())) { return Resources.none();
if (!getQueue().canRunAppAM(getAMResource())) { return Resources.none();
scheduler.handle(updateEvent); assertEquals("Application1's AM requests 1024 MB memory", 1024, app1.getAMResource().getMemory()); assertEquals("Application1's AM should be running", 1, app1.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application2's AM requests 1024 MB memory", 1024, app2.getAMResource().getMemory()); assertEquals("Application2's AM should not be running", 0, app2.getLiveContainers().size());
scheduler.handle(updateEvent); assertEquals("Application1's AM requests 1024 MB memory", 1024, app1.getAMResource().getMemorySize()); assertEquals("Application1's AM should be running", 1, app1.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application2's AM resource shouldn't be updated", 0, app2.getAMResource().getMemorySize()); assertEquals("Application2's AM should not be running", 0, app2.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application3's AM resource shouldn't be updated", 0, app3.getAMResource().getMemorySize()); assertEquals("Application3's AM should not be running", 0, app3.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application4's AM resource shouldn't be updated", 0, app4.getAMResource().getMemorySize()); assertEquals("Application4's AM should not be running", 0, app4.getLiveContainers().size());
scheduler.handle(updateEvent); assertEquals("Application1's AM requests 1024 MB memory", 1024, app1.getAMResource().getMemory()); assertEquals("Application1's AM should be running", 1, app1.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application2's AM requests 1024 MB memory", 1024, app2.getAMResource().getMemory()); assertEquals("Application2's AM should be running", 1, app2.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application3's AM requests 1024 MB memory", 1024, app3.getAMResource().getMemory()); assertEquals("Application3's AM should not be running", 0, app3.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application4's AM requests 2048 MB memory", 2048, app4.getAMResource().getMemory()); assertEquals("Application4's AM should not be running", 0, app4.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application5's AM requests 2048 MB memory", 2048, app5.getAMResource().getMemory()); assertEquals("Application5's AM should not be running", 0, app5.getLiveContainers().size());
scheduler.handle(updateEvent); assertEquals("Application1's AM requests 1024 MB memory", 1024, app1.getAMResource().getMemorySize()); assertEquals("Application1's AM should be running", 1, app1.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application2's AM requests 1024 MB memory", 1024, app2.getAMResource().getMemorySize()); assertEquals("Application2's AM should be running", 1, app2.getLiveContainers().size()); scheduler.handle(updateEvent); assertEquals("Application3's AM resource shouldn't be updated", 0, app3.getAMResource().getMemorySize()); assertEquals("Application3's AM should not be running", 0, app3.getLiveContainers().size()); 1, app3.getLiveContainers().size()); assertEquals("Application3's AM requests 1024 MB memory", 1024, app3.getAMResource().getMemorySize()); assertEquals("Queue1's AM resource usage should be 2048 MB memory", 2048, queue1.getAmResourceUsage().getMemorySize()); scheduler.handle(updateEvent); assertEquals("Application4's AM resource shouldn't be updated", 0, app4.getAMResource().getMemorySize()); assertEquals("Application4's AM should not be running", 0, app4.getLiveContainers().size());
1024, app1.getAMResource().getMemorySize()); assertEquals("Application1's AM should be running", 1, app1.getLiveContainers().size()); 1024, app2.getAMResource().getMemorySize()); assertEquals("Application2's AM should be running", 1, app2.getLiveContainers().size()); 0, app3.getAMResource().getMemorySize()); assertEquals("Application3's AM should not be running", 0, app3.getLiveContainers().size()); 0, app4.getAMResource().getMemorySize()); assertEquals("Application4's AM should not be running", 0, app4.getLiveContainers().size()); 5120, app4.getAMResource().getMemorySize()); assertEquals("Application4's AM should be running", 1, app4.getLiveContainers().size()); 1024, app5.getAMResource().getMemorySize()); assertEquals("Application5's AM should be running", 1, app5.getLiveContainers().size()); 0, app6.getAMResource().getMemorySize()); assertEquals("Application6's AM should not be running", 0, app6.getLiveContainers().size()); 1024, app7.getAMResource().getMemorySize());