YARN-2155. FairScheduler: Incorrect threshold check for preemption. (Wei Yan via kasha)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1602295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Karthik Kambatla 2014-06-12 21:23:32 +00:00
parent 6aef8fec70
commit 4bc91b44c9
3 changed files with 22 additions and 3 deletions

View File

@ -239,6 +239,9 @@ Release 2.5.0 - UNRELEASED
YARN-2075. Fixed the test failure of TestRMAdminCLI. (Kenji Kikushima via YARN-2075. Fixed the test failure of TestRMAdminCLI. (Kenji Kikushima via
zjshen) zjshen)
YARN-2155. FairScheduler: Incorrect threshold check for preemption.
(Wei Yan via kasha)
Release 2.4.1 - UNRELEASED Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1072,8 +1072,8 @@ private void updateRootQueueMetrics() {
private boolean shouldAttemptPreemption() { private boolean shouldAttemptPreemption() {
if (preemptionEnabled) { if (preemptionEnabled) {
return (preemptionUtilizationThreshold < Math.max( return (preemptionUtilizationThreshold < Math.max(
(float) rootMetrics.getAvailableMB() / clusterResource.getMemory(), (float) rootMetrics.getAllocatedMB() / clusterResource.getMemory(),
(float) rootMetrics.getAvailableVirtualCores() / (float) rootMetrics.getAllocatedVirtualCores() /
clusterResource.getVirtualCores())); clusterResource.getVirtualCores()));
} }
return false; return false;

View File

@ -146,7 +146,7 @@ public void testPreemptionWithFreeResources() throws Exception {
// Create node with 4GB memory and 4 vcores // Create node with 4GB memory and 4 vcores
registerNodeAndSubmitApp(4 * 1024, 4, 2, 1024); registerNodeAndSubmitApp(4 * 1024, 4, 2, 1024);
// Verify submitting another request doesn't trigger preemption // Verify submitting another request triggers preemption
createSchedulingRequest(1024, "queueB", "user1", 1, 1); createSchedulingRequest(1024, "queueB", "user1", 1, 1);
scheduler.update(); scheduler.update();
clock.tick(6); clock.tick(6);
@ -171,5 +171,21 @@ public void testPreemptionWithFreeResources() throws Exception {
scheduler.preemptTasksIfNecessary(); scheduler.preemptTasksIfNecessary();
assertEquals("preemptResources() should not have been called", -1, assertEquals("preemptResources() should not have been called", -1,
((StubbedFairScheduler) scheduler).lastPreemptMemory); ((StubbedFairScheduler) scheduler).lastPreemptMemory);
resourceManager.stop();
startResourceManager(0.7f);
// Create node with 4GB memory and 4 vcores
registerNodeAndSubmitApp(4 * 1024, 4, 3, 1024);
// Verify submitting another request triggers preemption
createSchedulingRequest(1024, "queueB", "user1", 1, 1);
scheduler.update();
clock.tick(6);
((StubbedFairScheduler) scheduler).resetLastPreemptResources();
scheduler.preemptTasksIfNecessary();
assertEquals("preemptResources() should have been called", 1024,
((StubbedFairScheduler) scheduler).lastPreemptMemory);
} }
} }