|
@@ -118,6 +118,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedule
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerQueueInfo;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerQueueInfoList;
|
|
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
|
|
+import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
|
|
import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
|
|
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
import org.junit.After;
|
|
@@ -1136,9 +1137,15 @@ public class TestCapacityScheduler {
|
|
|
|
|
|
private MockRM setUpMove() {
|
|
|
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
|
+ return setUpMove(conf);
|
|
|
+ }
|
|
|
+
|
|
|
+ private MockRM setUpMove(Configuration config) {
|
|
|
+ CapacitySchedulerConfiguration conf =
|
|
|
+ new CapacitySchedulerConfiguration(config);
|
|
|
setupQueueConfiguration(conf);
|
|
|
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
|
- ResourceScheduler.class);
|
|
|
+ ResourceScheduler.class);
|
|
|
MockRM rm = new MockRM(conf);
|
|
|
rm.start();
|
|
|
return rm;
|
|
@@ -2071,4 +2078,53 @@ public class TestCapacityScheduler {
|
|
|
Assert.assertEquals(0, report.getNumReservedContainers());
|
|
|
rm.stop();
|
|
|
}
|
|
|
+
|
|
|
+ @Test(timeout = 30000)
|
|
|
+ public void testAMLimitUsage() throws Exception {
|
|
|
+
|
|
|
+ CapacitySchedulerConfiguration config =
|
|
|
+ new CapacitySchedulerConfiguration();
|
|
|
+
|
|
|
+ config.set(CapacitySchedulerConfiguration.RESOURCE_CALCULATOR_CLASS,
|
|
|
+ DefaultResourceCalculator.class.getName());
|
|
|
+ verifyAMLimitForLeafQueue(config);
|
|
|
+
|
|
|
+ config.set(CapacitySchedulerConfiguration.RESOURCE_CALCULATOR_CLASS,
|
|
|
+ DominantResourceCalculator.class.getName());
|
|
|
+ verifyAMLimitForLeafQueue(config);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void verifyAMLimitForLeafQueue(CapacitySchedulerConfiguration config)
|
|
|
+ throws Exception {
|
|
|
+ MockRM rm = setUpMove(config);
|
|
|
+
|
|
|
+ String queueName = "a1";
|
|
|
+ String userName = "user_0";
|
|
|
+ ResourceScheduler scheduler = rm.getRMContext().getScheduler();
|
|
|
+ LeafQueue queueA =
|
|
|
+ (LeafQueue) ((CapacityScheduler) scheduler).getQueue(queueName);
|
|
|
+ Resource amResourceLimit = queueA.getAMResourceLimit();
|
|
|
+
|
|
|
+ Resource amResource =
|
|
|
+ Resource.newInstance(amResourceLimit.getMemory() + 1,
|
|
|
+ amResourceLimit.getVirtualCores() + 1);
|
|
|
+
|
|
|
+ rm.submitApp(amResource.getMemory(), "app-1", userName, null, queueName);
|
|
|
+
|
|
|
+ rm.submitApp(amResource.getMemory(), "app-1", userName, null, queueName);
|
|
|
+
|
|
|
+ // When AM limit is exceeded, 1 applications will be activated.Rest all
|
|
|
+ // applications will be in pending
|
|
|
+ Assert.assertEquals("PendingApplications should be 1", 1,
|
|
|
+ queueA.getNumPendingApplications());
|
|
|
+ Assert.assertEquals("Active applications should be 1", 1,
|
|
|
+ queueA.getNumActiveApplications());
|
|
|
+
|
|
|
+ Assert.assertEquals("User PendingApplications should be 1", 1, queueA
|
|
|
+ .getUser(userName).getPendingApplications());
|
|
|
+ Assert.assertEquals("User Active applications should be 1", 1, queueA
|
|
|
+ .getUser(userName).getActiveApplications());
|
|
|
+ rm.stop();
|
|
|
+ }
|
|
|
}
|