YARN-795. Fair scheduler queue metrics should subtract allocated vCores from available vCores. (ywskycn via tucu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1492025 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2013-06-12 00:49:06 +00:00
parent ed2576ac0d
commit 7ba28a1cbc
3 changed files with 32 additions and 9 deletions

View File

@ -524,6 +524,9 @@ Release 2.1.0-beta - UNRELEASED
YARN-493. Fixed some shell related flaws in YARN on Windows. (Chris Nauroth YARN-493. Fixed some shell related flaws in YARN on Windows. (Chris Nauroth
via vinodkv) via vinodkv)
YARN-795. Fair scheduler queue metrics should subtract allocated vCores from
available vCores. (ywskycn via tucu)
Release 2.0.5-alpha - 06/06/2013 Release 2.0.5-alpha - 06/06/2013
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -452,7 +452,7 @@ public class QueueMetrics implements MetricsSource {
} }
public Resource getAllocatedResources() { public Resource getAllocatedResources() {
return BuilderUtils.newResource(allocatedMB.value(), 0); return BuilderUtils.newResource(allocatedMB.value(), allocatedVCores.value());
} }
public int getAllocatedMB() { public int getAllocatedMB() {

View File

@ -219,6 +219,13 @@ public class TestFairScheduler {
createSchedulingRequestExistingApplication(request, attId); createSchedulingRequestExistingApplication(request, attId);
} }
private void createSchedulingRequestExistingApplication(int memory, int vcores,
int priority, ApplicationAttemptId attId) {
ResourceRequest request = createResourceRequest(memory, vcores, ResourceRequest.ANY,
priority, 1, true);
createSchedulingRequestExistingApplication(request, attId);
}
private void createSchedulingRequestExistingApplication(ResourceRequest request, private void createSchedulingRequestExistingApplication(ResourceRequest request,
ApplicationAttemptId attId) { ApplicationAttemptId attId) {
List<ResourceRequest> ask = new ArrayList<ResourceRequest>(); List<ResourceRequest> ask = new ArrayList<ResourceRequest>();
@ -352,17 +359,17 @@ public class TestFairScheduler {
// Add a node // Add a node
RMNode node1 = RMNode node1 =
MockNodes MockNodes
.newNodeInfo(1, Resources.createResource(1024), 1, "127.0.0.1"); .newNodeInfo(1, Resources.createResource(1024, 4), 1, "127.0.0.1");
NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
scheduler.handle(nodeEvent1); scheduler.handle(nodeEvent1);
// Add another node // Add another node
RMNode node2 = RMNode node2 =
MockNodes.newNodeInfo(1, Resources.createResource(512), 2, "127.0.0.2"); MockNodes.newNodeInfo(1, Resources.createResource(512, 2), 2, "127.0.0.2");
NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2); NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
scheduler.handle(nodeEvent2); scheduler.handle(nodeEvent2);
createSchedulingRequest(512, "queue1", "user1", 2); createSchedulingRequest(512, 2, "queue1", "user1", 2);
scheduler.update(); scheduler.update();
@ -379,13 +386,18 @@ public class TestFairScheduler {
assertEquals(1024, scheduler.getQueueManager().getQueue("queue1"). assertEquals(1024, scheduler.getQueueManager().getQueue("queue1").
getResourceUsage().getMemory()); getResourceUsage().getMemory());
assertEquals(2, scheduler.getQueueManager().getQueue("queue1").
getResourceUsage().getVirtualCores());
// verify metrics // verify metrics
QueueMetrics queue1Metrics = scheduler.getQueueManager().getQueue("queue1") QueueMetrics queue1Metrics = scheduler.getQueueManager().getQueue("queue1")
.getMetrics(); .getMetrics();
assertEquals(1024, queue1Metrics.getAllocatedMB()); assertEquals(1024, queue1Metrics.getAllocatedMB());
assertEquals(2, queue1Metrics.getAllocatedVirtualCores());
assertEquals(1024, scheduler.getRootQueueMetrics().getAllocatedMB()); assertEquals(1024, scheduler.getRootQueueMetrics().getAllocatedMB());
assertEquals(2, scheduler.getRootQueueMetrics().getAllocatedVirtualCores());
assertEquals(512, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(512, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(4, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
} }
@Test (timeout = 5000) @Test (timeout = 5000)
@ -1334,11 +1346,11 @@ public class TestFairScheduler {
// Add a node // Add a node
RMNode node1 = RMNode node1 =
MockNodes MockNodes
.newNodeInfo(1, Resources.createResource(1024), 1, "127.0.0.1"); .newNodeInfo(1, Resources.createResource(1024, 4), 1, "127.0.0.1");
NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
scheduler.handle(nodeEvent1); scheduler.handle(nodeEvent1);
ApplicationAttemptId attId = createSchedulingRequest(1024, "queue1", ApplicationAttemptId attId = createSchedulingRequest(1024, 4, "queue1",
"user1", 1, 2); "user1", 1, 2);
scheduler.update(); scheduler.update();
NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node1); NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node1);
@ -1351,15 +1363,16 @@ public class TestFairScheduler {
.getLiveContainers().iterator().next().getContainerId(); .getLiveContainers().iterator().next().getContainerId();
// Cause reservation to be created // Cause reservation to be created
createSchedulingRequestExistingApplication(1024, 2, attId); createSchedulingRequestExistingApplication(1024, 4, 2, attId);
scheduler.update(); scheduler.update();
scheduler.handle(updateEvent); scheduler.handle(updateEvent);
assertEquals(1, app.getLiveContainers().size()); assertEquals(1, app.getLiveContainers().size());
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
// Create request at higher priority // Create request at higher priority
createSchedulingRequestExistingApplication(1024, 1, attId); createSchedulingRequestExistingApplication(1024, 4, 1, attId);
scheduler.update(); scheduler.update();
scheduler.handle(updateEvent); scheduler.handle(updateEvent);
@ -1373,6 +1386,7 @@ public class TestFairScheduler {
scheduler.allocate(attId, new ArrayList<ResourceRequest>(), scheduler.allocate(attId, new ArrayList<ResourceRequest>(),
Arrays.asList(containerId), null, null); Arrays.asList(containerId), null, null);
assertEquals(1024, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(1024, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(4, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
// Schedule at opening // Schedule at opening
scheduler.update(); scheduler.update();
@ -1385,6 +1399,7 @@ public class TestFairScheduler {
Assert.assertEquals(2, liveContainer.getContainer().getPriority().getPriority()); Assert.assertEquals(2, liveContainer.getContainer().getPriority().getPriority());
} }
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
} }
@Test @Test
@ -1708,22 +1723,27 @@ public class TestFairScheduler {
@Test @Test
public void testRemoveNodeUpdatesRootQueueMetrics() { public void testRemoveNodeUpdatesRootQueueMetrics() {
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
RMNode node1 = MockNodes.newNodeInfo(1, Resources.createResource(1024), 1, RMNode node1 = MockNodes.newNodeInfo(1, Resources.createResource(1024, 4), 1,
"127.0.0.1"); "127.0.0.1");
NodeAddedSchedulerEvent addEvent = new NodeAddedSchedulerEvent(node1); NodeAddedSchedulerEvent addEvent = new NodeAddedSchedulerEvent(node1);
scheduler.handle(addEvent); scheduler.handle(addEvent);
assertEquals(1024, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(1024, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(4, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
scheduler.update(); // update shouldn't change things scheduler.update(); // update shouldn't change things
assertEquals(1024, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(1024, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(4, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
NodeRemovedSchedulerEvent removeEvent = new NodeRemovedSchedulerEvent(node1); NodeRemovedSchedulerEvent removeEvent = new NodeRemovedSchedulerEvent(node1);
scheduler.handle(removeEvent); scheduler.handle(removeEvent);
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
scheduler.update(); // update shouldn't change things scheduler.update(); // update shouldn't change things
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB()); assertEquals(0, scheduler.getRootQueueMetrics().getAvailableMB());
assertEquals(0, scheduler.getRootQueueMetrics().getAvailableVirtualCores());
} }
@Test @Test