YARN-890. Ensure CapacityScheduler doesn't round-up metric for available resources. Contributed by Xuan Gong & Hitesh Shah.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1529015 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arun Murthy 2013-10-03 21:54:35 +00:00
parent fb3f338c65
commit 79a11ce09d
3 changed files with 17 additions and 12 deletions

View File

@ -134,6 +134,9 @@ Release 2.1.2 - UNRELEASED
YARN-876. Node resource is added twice when node comes back from unhealthy YARN-876. Node resource is added twice when node comes back from unhealthy
to healthy. (Peng Zhang via Sandy Ryza) to healthy. (Peng Zhang via Sandy Ryza)
YARN-890. Ensure CapacityScheduler doesn't round-up metric for available
resources. (Xuan Gong & Hitesh Shah via acmurthy)
Release 2.1.1-beta - 2013-09-23 Release 2.1.1-beta - 2013-09-23
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -103,11 +103,7 @@ public static void updateQueueStatistics(
childQueue.setUsedCapacity(usedCapacity); childQueue.setUsedCapacity(usedCapacity);
childQueue.setAbsoluteUsedCapacity(absoluteUsedCapacity); childQueue.setAbsoluteUsedCapacity(absoluteUsedCapacity);
Resource available = Resource available = Resources.subtract(queueLimit, usedResources);
Resources.roundUp(
calculator,
Resources.subtract(queueLimit, usedResources),
minimumAllocation);
childQueue.getMetrics().setAvailableResourcesToQueue( childQueue.getMetrics().setAvailableResourcesToQueue(
Resources.max( Resources.max(
calculator, calculator,

View File

@ -283,7 +283,8 @@ public void testSingleQueueOneUserMetrics() throws Exception {
// Setup some nodes // Setup some nodes
String host_0 = "127.0.0.1"; String host_0 = "127.0.0.1";
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0, 8*GB); FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
8*GB);
final int numNodes = 1; final int numNodes = 1;
Resource clusterResource = Resource clusterResource =
@ -300,7 +301,9 @@ public void testSingleQueueOneUserMetrics() throws Exception {
// Only 1 container // Only 1 container
a.assignContainers(clusterResource, node_0); a.assignContainers(clusterResource, node_0);
assertEquals(6*GB, a.getMetrics().getAvailableMB()); assertEquals(
(int)(node_0.getTotalResource().getMemory() * a.getCapacity()) - (1*GB),
a.getMetrics().getAvailableMB());
} }
@Test @Test
@ -405,7 +408,8 @@ public void testSingleQueueWithOneUser() throws Exception {
// Setup some nodes // Setup some nodes
String host_0 = "127.0.0.1"; String host_0 = "127.0.0.1";
FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0, 8*GB); FiCaSchedulerNode node_0 = TestUtils.getMockNode(host_0, DEFAULT_RACK, 0,
8*GB);
final int numNodes = 1; final int numNodes = 1;
Resource clusterResource = Resource clusterResource =
@ -493,12 +497,14 @@ public void testSingleQueueWithOneUser() throws Exception {
a.completedContainer(clusterResource, app_1, node_0, rmContainer, a.completedContainer(clusterResource, app_1, node_0, rmContainer,
null, RMContainerEventType.KILL, null); null, RMContainerEventType.KILL, null);
} }
assertEquals(0*GB, a.getUsedResources().getMemory()); assertEquals(0*GB, a.getUsedResources().getMemory());
assertEquals(0*GB, app_0.getCurrentConsumption().getMemory()); assertEquals(0*GB, app_0.getCurrentConsumption().getMemory());
assertEquals(0*GB, app_1.getCurrentConsumption().getMemory()); assertEquals(0*GB, app_1.getCurrentConsumption().getMemory());
assertEquals(0*GB, a.getMetrics().getReservedMB()); assertEquals(0*GB, a.getMetrics().getReservedMB());
assertEquals(0*GB, a.getMetrics().getAllocatedMB()); assertEquals(0*GB, a.getMetrics().getAllocatedMB());
assertEquals(1*GB, a.getMetrics().getAvailableMB()); assertEquals((int)(a.getCapacity() * node_0.getTotalResource().getMemory()),
a.getMetrics().getAvailableMB());
} }
@Test @Test