|
@@ -28,16 +28,21 @@ import static org.mockito.Mockito.spy;
|
|
|
import static org.mockito.Mockito.times;
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
import static org.mockito.Mockito.when;
|
|
|
+import org.mockito.Matchers;
|
|
|
+import org.mockito.Mockito;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.ConcurrentMap;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
+import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
|
import org.apache.hadoop.yarn.api.records.Priority;
|
|
|
import org.apache.hadoop.yarn.api.records.QueueACL;
|
|
@@ -47,8 +52,10 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.factories.RecordFactory;
|
|
|
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ActiveUsersManager;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
|
|
|
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
|
|
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
|
|
@@ -56,6 +63,7 @@ import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
+import org.junit.Ignore;
|
|
|
|
|
|
public class TestApplicationLimits {
|
|
|
|
|
@@ -119,8 +127,6 @@ public class TestApplicationLimits {
|
|
|
// Some default values
|
|
|
doReturn(100).when(queue).getMaxApplications();
|
|
|
doReturn(25).when(queue).getMaxApplicationsPerUser();
|
|
|
- doReturn(10).when(queue).getMaximumActiveApplications();
|
|
|
- doReturn(2).when(queue).getMaximumActiveApplicationsPerUser();
|
|
|
}
|
|
|
|
|
|
private static final String A = "a";
|
|
@@ -136,10 +142,14 @@ public class TestApplicationLimits {
|
|
|
final String Q_B = CapacitySchedulerConfiguration.ROOT + "." + B;
|
|
|
conf.setCapacity(Q_B, 90);
|
|
|
|
|
|
+ conf.setUserLimit(CapacitySchedulerConfiguration.ROOT + "." + A, 50);
|
|
|
+ conf.setUserLimitFactor(CapacitySchedulerConfiguration.ROOT + "." + A, 5.0f);
|
|
|
+
|
|
|
LOG.info("Setup top-level queues a and b");
|
|
|
}
|
|
|
|
|
|
- private FiCaSchedulerApp getMockApplication(int appId, String user) {
|
|
|
+ private FiCaSchedulerApp getMockApplication(int appId, String user,
|
|
|
+ Resource amResource) {
|
|
|
FiCaSchedulerApp application = mock(FiCaSchedulerApp.class);
|
|
|
ApplicationAttemptId applicationAttemptId =
|
|
|
TestUtils.getMockApplicationAttemptId(appId, 0);
|
|
@@ -147,9 +157,89 @@ public class TestApplicationLimits {
|
|
|
when(application).getApplicationId();
|
|
|
doReturn(applicationAttemptId). when(application).getApplicationAttemptId();
|
|
|
doReturn(user).when(application).getUser();
|
|
|
+ doReturn(amResource).when(application).getAMResource();
|
|
|
return application;
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testAMResourceLimit() throws Exception {
|
|
|
+ final String user_0 = "user_0";
|
|
|
+ final String user_1 = "user_1";
|
|
|
+
|
|
|
+ // This uses the default 10% of cluster value for the max am resources
|
|
|
+ // which are allowed, at 80GB = 8GB for AM's at the queue level. The user
|
|
|
+ // am limit is 4G initially (based on the queue absolute capacity)
|
|
|
+ // when there is only 1 user, and drops to 2G (the userlimit) when there
|
|
|
+ // is a second user
|
|
|
+ queue.updateClusterResource(Resource.newInstance(80 * GB, 40));
|
|
|
+
|
|
|
+ ActiveUsersManager activeUsersManager = mock(ActiveUsersManager.class);
|
|
|
+ when(queue.getActiveUsersManager()).thenReturn(activeUsersManager);
|
|
|
+
|
|
|
+ assertEquals(Resource.newInstance(8 * GB, 1), queue.getAMResourceLimit());
|
|
|
+ assertEquals(Resource.newInstance(4 * GB, 1),
|
|
|
+ queue.getUserAMResourceLimit());
|
|
|
+
|
|
|
+ // Two apps for user_0, both start
|
|
|
+ int APPLICATION_ID = 0;
|
|
|
+ FiCaSchedulerApp app_0 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resource.newInstance(2 * GB, 1));
|
|
|
+ queue.submitApplicationAttempt(app_0, user_0);
|
|
|
+ assertEquals(1, queue.getNumActiveApplications());
|
|
|
+ assertEquals(0, queue.getNumPendingApplications());
|
|
|
+ assertEquals(1, queue.getNumActiveApplications(user_0));
|
|
|
+ assertEquals(0, queue.getNumPendingApplications(user_0));
|
|
|
+
|
|
|
+ when(activeUsersManager.getNumActiveUsers()).thenReturn(1);
|
|
|
+
|
|
|
+ FiCaSchedulerApp app_1 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resource.newInstance(2 * GB, 1));
|
|
|
+ queue.submitApplicationAttempt(app_1, user_0);
|
|
|
+ assertEquals(2, queue.getNumActiveApplications());
|
|
|
+ assertEquals(0, queue.getNumPendingApplications());
|
|
|
+ assertEquals(2, queue.getNumActiveApplications(user_0));
|
|
|
+ assertEquals(0, queue.getNumPendingApplications(user_0));
|
|
|
+
|
|
|
+ // AMLimits unchanged
|
|
|
+ assertEquals(Resource.newInstance(8 * GB, 1), queue.getAMResourceLimit());
|
|
|
+ assertEquals(Resource.newInstance(4 * GB, 1),
|
|
|
+ queue.getUserAMResourceLimit());
|
|
|
+
|
|
|
+ // One app for user_1, starts
|
|
|
+ FiCaSchedulerApp app_2 = getMockApplication(APPLICATION_ID++, user_1,
|
|
|
+ Resource.newInstance(2 * GB, 1));
|
|
|
+ queue.submitApplicationAttempt(app_2, user_1);
|
|
|
+ assertEquals(3, queue.getNumActiveApplications());
|
|
|
+ assertEquals(0, queue.getNumPendingApplications());
|
|
|
+ assertEquals(1, queue.getNumActiveApplications(user_1));
|
|
|
+ assertEquals(0, queue.getNumPendingApplications(user_1));
|
|
|
+
|
|
|
+ when(activeUsersManager.getNumActiveUsers()).thenReturn(2);
|
|
|
+
|
|
|
+ // Now userAMResourceLimit drops to the queue configured 50% as there is
|
|
|
+ // another user active
|
|
|
+ assertEquals(Resource.newInstance(8 * GB, 1), queue.getAMResourceLimit());
|
|
|
+ assertEquals(Resource.newInstance(2 * GB, 1),
|
|
|
+ queue.getUserAMResourceLimit());
|
|
|
+
|
|
|
+ // Second user_1 app cannot start
|
|
|
+ FiCaSchedulerApp app_3 = getMockApplication(APPLICATION_ID++, user_1,
|
|
|
+ Resource.newInstance(2 * GB, 1));
|
|
|
+ queue.submitApplicationAttempt(app_3, user_1);
|
|
|
+ assertEquals(3, queue.getNumActiveApplications());
|
|
|
+ assertEquals(1, queue.getNumPendingApplications());
|
|
|
+ assertEquals(1, queue.getNumActiveApplications(user_1));
|
|
|
+ assertEquals(1, queue.getNumPendingApplications(user_1));
|
|
|
+
|
|
|
+ // Now finish app so another should be activated
|
|
|
+ queue.finishApplicationAttempt(app_2, A);
|
|
|
+ assertEquals(3, queue.getNumActiveApplications());
|
|
|
+ assertEquals(0, queue.getNumPendingApplications());
|
|
|
+ assertEquals(1, queue.getNumActiveApplications(user_1));
|
|
|
+ assertEquals(0, queue.getNumPendingApplications(user_1));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testLimitsComputation() throws Exception {
|
|
|
CapacitySchedulerConfiguration csConf =
|
|
@@ -172,7 +262,8 @@ public class TestApplicationLimits {
|
|
|
when(csContext.getRMContext()).thenReturn(rmContext);
|
|
|
|
|
|
// Say cluster has 100 nodes of 16G each
|
|
|
- Resource clusterResource = Resources.createResource(100 * 16 * GB, 100 * 16);
|
|
|
+ Resource clusterResource =
|
|
|
+ Resources.createResource(100 * 16 * GB, 100 * 16);
|
|
|
when(csContext.getClusterResource()).thenReturn(clusterResource);
|
|
|
|
|
|
Map<String, CSQueue> queues = new HashMap<String, CSQueue>();
|
|
@@ -183,28 +274,14 @@ public class TestApplicationLimits {
|
|
|
LeafQueue queue = (LeafQueue)queues.get(A);
|
|
|
|
|
|
LOG.info("Queue 'A' -" +
|
|
|
- " maxActiveApplications=" + queue.getMaximumActiveApplications() +
|
|
|
- " maxActiveApplicationsPerUser=" +
|
|
|
- queue.getMaximumActiveApplicationsPerUser());
|
|
|
- int expectedMaxActiveApps =
|
|
|
- Math.max(1,
|
|
|
- (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) *
|
|
|
- csConf.
|
|
|
- getMaximumApplicationMasterResourcePerQueuePercent(
|
|
|
- queue.getQueuePath()) *
|
|
|
- queue.getAbsoluteMaximumCapacity()));
|
|
|
- assertEquals(expectedMaxActiveApps,
|
|
|
- queue.getMaximumActiveApplications());
|
|
|
- int expectedMaxActiveAppsUsingAbsCap =
|
|
|
- Math.max(1,
|
|
|
- (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) *
|
|
|
- csConf.getMaximumApplicationMasterResourcePercent() *
|
|
|
- queue.getAbsoluteCapacity()));
|
|
|
- assertEquals(
|
|
|
- (int)Math.ceil(
|
|
|
- expectedMaxActiveAppsUsingAbsCap * (queue.getUserLimit() / 100.0f) *
|
|
|
- queue.getUserLimitFactor()),
|
|
|
- queue.getMaximumActiveApplicationsPerUser());
|
|
|
+ " aMResourceLimit=" + queue.getAMResourceLimit() +
|
|
|
+ " UserAMResourceLimit=" +
|
|
|
+ queue.getUserAMResourceLimit());
|
|
|
+
|
|
|
+ assertEquals(queue.getAMResourceLimit(), Resource.newInstance(160*GB, 1));
|
|
|
+ assertEquals(queue.getUserAMResourceLimit(),
|
|
|
+ Resource.newInstance(80*GB, 1));
|
|
|
+
|
|
|
assertEquals(
|
|
|
(int)(clusterResource.getMemory() * queue.getAbsoluteCapacity()),
|
|
|
queue.getMetrics().getAvailableMB()
|
|
@@ -213,24 +290,11 @@ public class TestApplicationLimits {
|
|
|
// Add some nodes to the cluster & test new limits
|
|
|
clusterResource = Resources.createResource(120 * 16 * GB);
|
|
|
root.updateClusterResource(clusterResource);
|
|
|
- expectedMaxActiveApps =
|
|
|
- Math.max(1,
|
|
|
- (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) *
|
|
|
- csConf.
|
|
|
- getMaximumApplicationMasterResourcePerQueuePercent(
|
|
|
- queue.getQueuePath()) *
|
|
|
- queue.getAbsoluteMaximumCapacity()));
|
|
|
- assertEquals(expectedMaxActiveApps,
|
|
|
- queue.getMaximumActiveApplications());
|
|
|
- expectedMaxActiveAppsUsingAbsCap =
|
|
|
- Math.max(1,
|
|
|
- (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) *
|
|
|
- csConf.getMaximumApplicationMasterResourcePercent() *
|
|
|
- queue.getAbsoluteCapacity()));
|
|
|
- assertEquals(
|
|
|
- (int)Math.ceil(expectedMaxActiveAppsUsingAbsCap *
|
|
|
- (queue.getUserLimit() / 100.0f) * queue.getUserLimitFactor()),
|
|
|
- queue.getMaximumActiveApplicationsPerUser());
|
|
|
+
|
|
|
+ assertEquals(queue.getAMResourceLimit(), Resource.newInstance(192*GB, 1));
|
|
|
+ assertEquals(queue.getUserAMResourceLimit(),
|
|
|
+ Resource.newInstance(96*GB, 1));
|
|
|
+
|
|
|
assertEquals(
|
|
|
(int)(clusterResource.getMemory() * queue.getAbsoluteCapacity()),
|
|
|
queue.getMetrics().getAvailableMB()
|
|
@@ -271,18 +335,15 @@ public class TestApplicationLimits {
|
|
|
clusterResource = Resources.createResource(100 * 16 * GB);
|
|
|
|
|
|
queue = (LeafQueue)queues.get(A);
|
|
|
- expectedMaxActiveApps =
|
|
|
- Math.max(1,
|
|
|
- (int)Math.ceil(((float)clusterResource.getMemory() / (1*GB)) *
|
|
|
- csConf.
|
|
|
- getMaximumApplicationMasterResourcePerQueuePercent(
|
|
|
- queue.getQueuePath()) *
|
|
|
- queue.getAbsoluteMaximumCapacity()));
|
|
|
|
|
|
assertEquals((long) 0.5,
|
|
|
- (long) csConf.getMaximumApplicationMasterResourcePerQueuePercent(queue.getQueuePath()));
|
|
|
- assertEquals(expectedMaxActiveApps,
|
|
|
- queue.getMaximumActiveApplications());
|
|
|
+ (long) csConf.getMaximumApplicationMasterResourcePerQueuePercent(
|
|
|
+ queue.getQueuePath())
|
|
|
+ );
|
|
|
+
|
|
|
+ assertEquals(queue.getAMResourceLimit(), Resource.newInstance(800*GB, 1));
|
|
|
+ assertEquals(queue.getUserAMResourceLimit(),
|
|
|
+ Resource.newInstance(400*GB, 1));
|
|
|
|
|
|
// Change the per-queue max applications.
|
|
|
csConf.setInt(
|
|
@@ -308,10 +369,16 @@ public class TestApplicationLimits {
|
|
|
public void testActiveApplicationLimits() throws Exception {
|
|
|
final String user_0 = "user_0";
|
|
|
final String user_1 = "user_1";
|
|
|
+ final String user_2 = "user_2";
|
|
|
+
|
|
|
+ assertEquals(Resource.newInstance(16 * GB, 1), queue.getAMResourceLimit());
|
|
|
+ assertEquals(Resource.newInstance(8 * GB, 1),
|
|
|
+ queue.getUserAMResourceLimit());
|
|
|
|
|
|
int APPLICATION_ID = 0;
|
|
|
// Submit first application
|
|
|
- FiCaSchedulerApp app_0 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_0 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_0, user_0);
|
|
|
assertEquals(1, queue.getNumActiveApplications());
|
|
|
assertEquals(0, queue.getNumPendingApplications());
|
|
@@ -319,15 +386,17 @@ public class TestApplicationLimits {
|
|
|
assertEquals(0, queue.getNumPendingApplications(user_0));
|
|
|
|
|
|
// Submit second application
|
|
|
- FiCaSchedulerApp app_1 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_1 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_1, user_0);
|
|
|
assertEquals(2, queue.getNumActiveApplications());
|
|
|
assertEquals(0, queue.getNumPendingApplications());
|
|
|
assertEquals(2, queue.getNumActiveApplications(user_0));
|
|
|
assertEquals(0, queue.getNumPendingApplications(user_0));
|
|
|
|
|
|
- // Submit third application, should remain pending
|
|
|
- FiCaSchedulerApp app_2 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ // Submit third application, should remain pending due to user amlimit
|
|
|
+ FiCaSchedulerApp app_2 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_2, user_0);
|
|
|
assertEquals(2, queue.getNumActiveApplications());
|
|
|
assertEquals(1, queue.getNumPendingApplications());
|
|
@@ -342,18 +411,17 @@ public class TestApplicationLimits {
|
|
|
assertEquals(0, queue.getNumPendingApplications(user_0));
|
|
|
|
|
|
// Submit another one for user_0
|
|
|
- FiCaSchedulerApp app_3 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_3 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_3, user_0);
|
|
|
assertEquals(2, queue.getNumActiveApplications());
|
|
|
assertEquals(1, queue.getNumPendingApplications());
|
|
|
assertEquals(2, queue.getNumActiveApplications(user_0));
|
|
|
assertEquals(1, queue.getNumPendingApplications(user_0));
|
|
|
|
|
|
- // Change queue limit to be smaller so 2 users can fill it up
|
|
|
- doReturn(3).when(queue).getMaximumActiveApplications();
|
|
|
-
|
|
|
// Submit first app for user_1
|
|
|
- FiCaSchedulerApp app_4 = getMockApplication(APPLICATION_ID++, user_1);
|
|
|
+ FiCaSchedulerApp app_4 = getMockApplication(APPLICATION_ID++, user_1,
|
|
|
+ Resources.createResource(8 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_4, user_1);
|
|
|
assertEquals(3, queue.getNumActiveApplications());
|
|
|
assertEquals(1, queue.getNumPendingApplications());
|
|
@@ -362,15 +430,17 @@ public class TestApplicationLimits {
|
|
|
assertEquals(1, queue.getNumActiveApplications(user_1));
|
|
|
assertEquals(0, queue.getNumPendingApplications(user_1));
|
|
|
|
|
|
- // Submit second app for user_1, should block due to queue-limit
|
|
|
- FiCaSchedulerApp app_5 = getMockApplication(APPLICATION_ID++, user_1);
|
|
|
- queue.submitApplicationAttempt(app_5, user_1);
|
|
|
+ // Submit first app for user_2, should block due to queue amlimit
|
|
|
+ FiCaSchedulerApp app_5 = getMockApplication(APPLICATION_ID++, user_2,
|
|
|
+ Resources.createResource(8 * GB, 0));
|
|
|
+ queue.submitApplicationAttempt(app_5, user_2);
|
|
|
assertEquals(3, queue.getNumActiveApplications());
|
|
|
assertEquals(2, queue.getNumPendingApplications());
|
|
|
assertEquals(2, queue.getNumActiveApplications(user_0));
|
|
|
assertEquals(1, queue.getNumPendingApplications(user_0));
|
|
|
assertEquals(1, queue.getNumActiveApplications(user_1));
|
|
|
- assertEquals(1, queue.getNumPendingApplications(user_1));
|
|
|
+ assertEquals(0, queue.getNumPendingApplications(user_1));
|
|
|
+ assertEquals(1, queue.getNumPendingApplications(user_2));
|
|
|
|
|
|
// Now finish one app of user_1 so app_5 should be activated
|
|
|
queue.finishApplicationAttempt(app_4, A);
|
|
@@ -378,21 +448,22 @@ public class TestApplicationLimits {
|
|
|
assertEquals(1, queue.getNumPendingApplications());
|
|
|
assertEquals(2, queue.getNumActiveApplications(user_0));
|
|
|
assertEquals(1, queue.getNumPendingApplications(user_0));
|
|
|
- assertEquals(1, queue.getNumActiveApplications(user_1));
|
|
|
+ assertEquals(0, queue.getNumActiveApplications(user_1));
|
|
|
assertEquals(0, queue.getNumPendingApplications(user_1));
|
|
|
+ assertEquals(1, queue.getNumActiveApplications(user_2));
|
|
|
+ assertEquals(0, queue.getNumPendingApplications(user_2));
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Test
|
|
|
public void testActiveLimitsWithKilledApps() throws Exception {
|
|
|
final String user_0 = "user_0";
|
|
|
|
|
|
int APPLICATION_ID = 0;
|
|
|
|
|
|
- // set max active to 2
|
|
|
- doReturn(2).when(queue).getMaximumActiveApplications();
|
|
|
-
|
|
|
// Submit first application
|
|
|
- FiCaSchedulerApp app_0 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_0 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_0, user_0);
|
|
|
assertEquals(1, queue.getNumActiveApplications());
|
|
|
assertEquals(0, queue.getNumPendingApplications());
|
|
@@ -401,7 +472,8 @@ public class TestApplicationLimits {
|
|
|
assertTrue(queue.activeApplications.contains(app_0));
|
|
|
|
|
|
// Submit second application
|
|
|
- FiCaSchedulerApp app_1 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_1 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_1, user_0);
|
|
|
assertEquals(2, queue.getNumActiveApplications());
|
|
|
assertEquals(0, queue.getNumPendingApplications());
|
|
@@ -410,7 +482,8 @@ public class TestApplicationLimits {
|
|
|
assertTrue(queue.activeApplications.contains(app_1));
|
|
|
|
|
|
// Submit third application, should remain pending
|
|
|
- FiCaSchedulerApp app_2 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_2 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_2, user_0);
|
|
|
assertEquals(2, queue.getNumActiveApplications());
|
|
|
assertEquals(1, queue.getNumPendingApplications());
|
|
@@ -419,7 +492,8 @@ public class TestApplicationLimits {
|
|
|
assertTrue(queue.pendingApplications.contains(app_2));
|
|
|
|
|
|
// Submit fourth application, should remain pending
|
|
|
- FiCaSchedulerApp app_3 = getMockApplication(APPLICATION_ID++, user_0);
|
|
|
+ FiCaSchedulerApp app_3 = getMockApplication(APPLICATION_ID++, user_0,
|
|
|
+ Resources.createResource(4 * GB, 0));
|
|
|
queue.submitApplicationAttempt(app_3, user_0);
|
|
|
assertEquals(2, queue.getNumActiveApplications());
|
|
|
assertEquals(2, queue.getNumPendingApplications());
|
|
@@ -506,6 +580,18 @@ public class TestApplicationLimits {
|
|
|
RecordFactory recordFactory =
|
|
|
RecordFactoryProvider.getRecordFactory(null);
|
|
|
RMContext rmContext = TestUtils.getMockRMContext();
|
|
|
+ RMContext spyRMContext = spy(rmContext);
|
|
|
+
|
|
|
+ ConcurrentMap<ApplicationId, RMApp> spyApps =
|
|
|
+ spy(new ConcurrentHashMap<ApplicationId, RMApp>());
|
|
|
+ RMApp rmApp = mock(RMApp.class);
|
|
|
+ ResourceRequest amResourceRequest = mock(ResourceRequest.class);
|
|
|
+ Resource amResource = Resources.createResource(0, 0);
|
|
|
+ when(amResourceRequest.getCapability()).thenReturn(amResource);
|
|
|
+ when(rmApp.getAMResourceRequest()).thenReturn(amResourceRequest);
|
|
|
+ Mockito.doReturn(rmApp).when(spyApps).get((ApplicationId)Matchers.any());
|
|
|
+ when(spyRMContext.getRMApps()).thenReturn(spyApps);
|
|
|
+
|
|
|
|
|
|
Priority priority_1 = TestUtils.createMockPriority(1);
|
|
|
|
|
@@ -513,9 +599,9 @@ public class TestApplicationLimits {
|
|
|
// and check headroom
|
|
|
final ApplicationAttemptId appAttemptId_0_0 =
|
|
|
TestUtils.getMockApplicationAttemptId(0, 0);
|
|
|
- FiCaSchedulerApp app_0_0 =
|
|
|
- spy(new FiCaSchedulerApp(appAttemptId_0_0, user_0, queue,
|
|
|
- queue.getActiveUsersManager(), rmContext));
|
|
|
+ FiCaSchedulerApp app_0_0 = new FiCaSchedulerApp(
|
|
|
+ appAttemptId_0_0, user_0, queue,
|
|
|
+ queue.getActiveUsersManager(), spyRMContext);
|
|
|
queue.submitApplicationAttempt(app_0_0, user_0);
|
|
|
|
|
|
List<ResourceRequest> app_0_0_requests = new ArrayList<ResourceRequest>();
|
|
@@ -532,9 +618,9 @@ public class TestApplicationLimits {
|
|
|
// Submit second application from user_0, check headroom
|
|
|
final ApplicationAttemptId appAttemptId_0_1 =
|
|
|
TestUtils.getMockApplicationAttemptId(1, 0);
|
|
|
- FiCaSchedulerApp app_0_1 =
|
|
|
- spy(new FiCaSchedulerApp(appAttemptId_0_1, user_0, queue,
|
|
|
- queue.getActiveUsersManager(), rmContext));
|
|
|
+ FiCaSchedulerApp app_0_1 = new FiCaSchedulerApp(
|
|
|
+ appAttemptId_0_1, user_0, queue,
|
|
|
+ queue.getActiveUsersManager(), spyRMContext);
|
|
|
queue.submitApplicationAttempt(app_0_1, user_0);
|
|
|
|
|
|
List<ResourceRequest> app_0_1_requests = new ArrayList<ResourceRequest>();
|
|
@@ -551,9 +637,9 @@ public class TestApplicationLimits {
|
|
|
// Submit first application from user_1, check for new headroom
|
|
|
final ApplicationAttemptId appAttemptId_1_0 =
|
|
|
TestUtils.getMockApplicationAttemptId(2, 0);
|
|
|
- FiCaSchedulerApp app_1_0 =
|
|
|
- spy(new FiCaSchedulerApp(appAttemptId_1_0, user_1, queue,
|
|
|
- queue.getActiveUsersManager(), rmContext));
|
|
|
+ FiCaSchedulerApp app_1_0 = new FiCaSchedulerApp(
|
|
|
+ appAttemptId_1_0, user_1, queue,
|
|
|
+ queue.getActiveUsersManager(), spyRMContext);
|
|
|
queue.submitApplicationAttempt(app_1_0, user_1);
|
|
|
|
|
|
List<ResourceRequest> app_1_0_requests = new ArrayList<ResourceRequest>();
|